29 lines
915 B
Bash
Executable file
29 lines
915 B
Bash
Executable file
#!/bin/bash
|
|
FS=$1
|
|
SH=$2
|
|
|
|
|
|
if [ ! -e /tmp/*.gntmnt ]; then # If nobody is in the system then we should mount the needed filesystems
|
|
echo "No Mount detected"
|
|
echo "Mounting Necessary Filesystems..."
|
|
mount --types proc /proc ${FS}/proc
|
|
mount --rbind /sys ${FS}/sys
|
|
mount --make-rslave ${FS}/sys
|
|
mount --rbind /dev ${FS}/dev
|
|
mount --make-rslave ${FS}/dev
|
|
fi
|
|
echo "Chrooting into Gentoo system..."
|
|
touch /tmp/${$}.gntmnt # Create a temporary file to tell the script that we are inside the system
|
|
chroot ${FS} ${SH}
|
|
|
|
|
|
# By this point the user has exitted from the Chroot, its time to unmount filesystems - assuming this is the only shell still in it...
|
|
rm /tmp/${$}.gntmnt
|
|
|
|
if [ ! -e /tmp/*.gntmnt ]; then
|
|
|
|
echo "Unmounting Filesystems..."
|
|
umount -l ${FS}/dev{/shm,/pts,}
|
|
else
|
|
echo "Other shells chrooted, not unmounting filesystems..."
|
|
fi
|