Created
November 19, 2019 10:58
-
-
Save dbeecham/183c122059f7ba288397e8c3320234d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
if test ! -d ./overlay; then | |
read -p "No overlay found here. Want to create one? (y/N)" yn | |
case $yn in | |
[Yy]* ) install -d overlay/upperdir && install -d overlay/workdir && install -d overlay/mnt; break;; | |
* ) exit;; | |
esac | |
fi | |
if test ! -d ./overlay/upperdir; then | |
echo "Missing overlay/upperdir. Broken overlay?" | |
exit | |
fi | |
if test ! -d ./overlay/workdir; then | |
echo "Missing overlay/workdir. Broken overlay?" | |
exit | |
fi | |
if test ! -d ./overlay/mnt; then | |
echo "Missing overlay/mnt. Broken overlay?" | |
exit | |
fi | |
echo "Entering own mount namespace..." | |
sudo unshare -m sh -c "echo 'Mounting local overlay...' && \ | |
mount -t overlay overlay -o upperdir=$(pwd)/overlay/upperdir,workdir=$(pwd)/overlay/workdir,lowerdir=/ $(pwd)/overlay/mnt && \ | |
mount -o bind /sys overlay/mnt/sys && \ | |
mount -t proc none overlay/mnt/proc && \ | |
mount -o bind /dev overlay/mnt/dev && \ | |
mount -o bind /dev/pts overlay/mnt/dev/pts && \ | |
echo 'chrooting...' && \ | |
sudo chroot overlay/mnt sh -c 'export action=\"(chroot) \"; cd $(pwd) && sudo -E -u $(whoami) $SHELL'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment