-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathChroot
More file actions
executable file
·37 lines (29 loc) · 992 Bytes
/
Chroot
File metadata and controls
executable file
·37 lines (29 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
if [ $UID = 0 ]
then SUDO=
else SUDO="sudo -E"
fi
if [ ! -e $(dirname "$0")/.workdir.conf ]
then
echo "$(dirname $0)/.workdir.conf does not exist."
echo "Please run the GoboALFS script before launching this script."
exit 1
fi
source $(dirname "$0")/.workdir.conf
BUILDDIR=$WORKDIR/RootFS
umount_sys=
umount_proc=
umount_dev=
mountpoint -q "$BUILDDIR/sys" || { $SUDO mount -o bind /sys "$BUILDDIR/sys"; umount_sys=yes; }
mountpoint -q "$BUILDDIR/proc" || { $SUDO mount -o bind /proc "$BUILDDIR/proc"; umount_proc=yes; }
mountpoint -q "$BUILDDIR/dev" || { $SUDO mount -o bind /dev "$BUILDDIR/dev"; umount_dev=yes; }
export PATH=/bin:/sbin:$PATH
export SUDO_OK=1
export SUDO_PS1="[\u@gobolinux-chroot \W]\$ "
unset LC_ALL
unset LANG
unset LANGUAGE
$SUDO chroot "$BUILDDIR" /bin/bash
[ "$umount_dev" = "yes" ] && $SUDO umount "$BUILDDIR/dev"
[ "$umount_proc" = "yes" ] && $SUDO umount "$BUILDDIR/proc"
[ "$umount_sys" = "yes" ] && $SUDO umount "$BUILDDIR/sys"