
Code: Select all
#/bin/sh
if [ -z "$1" ]; then
echo "$0 <mount>"
echo
echo "Root shell:"
echo "The rootsh command will bind local proc,sys and dev mounts onto a"
echo "mounted system and chroot to give root shell."
exit 0
elif ! mountpoint -q "$1" ; then
echo "Mount point at $1 does not exist"
exit 5
fi
sudo mount -t proc proc "$1/proc"
sudo mount -t sysfs sysfs "$1/sys"
sudo mount -o bind /dev "$1/dev"
sudo mount -t devpts pts "$1/dev/pts"
sudo chroot "$1"
sudo umount "$1/dev/pts"
sudo umount "$1/dev"
sudo umount "$1/sys"
sudo umount "$1/proc"
exit 0