Skip to content

Instantly share code, notes, and snippets.

@E5ten
E5ten / chrootwrapper.sh
Created October 22, 2018 16:05
chroot wrapper that mounts important filesystems and copies resolv.conf beforehands to make internet, sudo, and more work correctly inside the chroot
#!/bin/bash
[[ ! "$(id -u)" = "0" ]] && echo "This script must be ran as root!" && exit 1
CHROOTDIR="$(readlink -f $1)"; shift
# Functions
mount_dirs() {
! mount | grep "$CHROOTDIR$1" &>/dev/null && mount --bind "$1" "$CHROOTDIR$1"
}

Keybase proof

I hereby claim:

  • I am e5ten on github.
  • I am e5ten (https://keybase.io/e5ten) on keybase.
  • I have a public key whose fingerprint is 82A8 5828 0A08 CD85 FF95 3B21 F58C 938F 964F 3782

To claim this, I am signing this object: