/
2.shell
executable file
·21 lines (16 loc) · 1.59 KB
/
2.shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#############
[ "${#}" == "0" ] && user="root" || user="nobody"
#############
mountpoint -q "rootfs/dev" || { install -d -o 0 -g 0 -m 0700 "rootfs/dev" ; mount -t devtmpfs -o rw,dev,nosuid,noexec,noatime,size=0% "stage3" "rootfs/dev" ; }
mountpoint -q "rootfs/dev/pts" || { install -d -o 0 -g 0 -m 0700 "rootfs/dev/pts" ; mount -t devpts -o rw,dev,nosuid,noexec,noatime,mode=0600,ptmxmode=0000 "stage3" "rootfs/dev/pts" ; }
mountpoint -q "rootfs/dev/shm" || { install -d -o 0 -g 0 -m 0700 "rootfs/dev/shm" ; mount -t tmpfs -o rw,nodev,nosuid,noexec,noatime,noswap,quota,uid=0,gid=0,mode=1777,size=3% "stage3" "rootfs/dev/shm" ; }
mountpoint -q "rootfs/proc" || { install -d -o 0 -g 0 -m 0700 "rootfs/proc" ; mount -t proc -o rw,nodev,nosuid,noexec,noatime,hidepid=1 "stage3" "rootfs/proc" ; }
mountpoint -q "rootfs/sys" || { install -d -o 0 -g 0 -m 0700 "rootfs/sys" ; mount -t sysfs -o rw,nodev,nosuid,noexec,noatime "stage3" "rootfs/sys" ; }
mountpoint -q "rootfs/tmp" || { install -d -o 0 -g 0 -m 0700 "rootfs/tmp" ; mount -t tmpfs -o rw,nodev,nosuid,exec,noatime,noswap,quota,uid=0,gid=0,mode=1777,size=8G "stage3" "rootfs/tmp" ; }
mount|grep -q "stage3/rootfs/root" || { install -d -o 0 -g 0 -m 0700 "rootfs/root" && mount --bind "config" "rootfs/root" ; }
mount|grep -q "stage3/rootfs/binhost" || { install -d -o 0 -g 0 -m 0700 "rootfs/binhost" && mount --bind "binhost" "rootfs/binhost" ; }
#############
install -d -o 65534 -g 65534 -m 0700 "rootfs/var/empty"
#############
cd rootfs && chroot . /usr/bin/busybox su -l -s /usr/bin/ash "${user}"
#############