forked from f-izzo/fastgate-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchroot.sh
33 lines (26 loc) · 1.07 KB
/
chroot.sh
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
#!/statusapi/bin/busybox sh
chroot="/mnt/sda1/sid-armel"
bin="/bin/bash"
usb="/dev/sda1"
bb="/statusapi/bin/busybox"
# Run bash by default
if [ ! "x$1" = "x" ]; then
bin="$1"
fi
# Create mountpoints
$bb mkdir -p "${chroot}/dev"
$bb mkdir -p "${chroot}/proc"
$bb mkdir -p "${chroot}/sys"
$bb mkdir -p "${chroot}/fastgate"
$bb mkdir -p "${chroot}/usb"
# Mount stuff if not already mounted
$bb mount | $bb grep -q "${chroot}/fastgate" || $bb mount -o bind / "${chroot}/fastgate"
$bb mount | $bb grep -q "${chroot}/dev" || $bb mount -o bind /dev "${chroot}/dev"
$bb mount | $bb grep -q "${chroot}/dev/pts" || $bb mount -o bind /dev/pts "${chroot}/dev/pts"
$bb mount | $bb grep -q "${chroot}/proc" || $bb mount -o bind /proc "${chroot}/proc"
$bb mount | $bb grep -q "${chroot}/sys" || $bb mount -o bind /sys "${chroot}/sys"
$bb mount | $bb grep -q "${chroot}/usb" || $bb mount "$usb" "${chroot}/usb"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin"
export HOME="/root"
export USER="root"
$bb chroot "$chroot" "$bin"