summaryrefslogtreecommitdiffstats
path: root/prog/jelka/chroot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'prog/jelka/chroot.sh')
-rwxr-xr-xprog/jelka/chroot.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/prog/jelka/chroot.sh b/prog/jelka/chroot.sh
new file mode 100755
index 0000000..3d92d2c
--- /dev/null
+++ b/prog/jelka/chroot.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -xeuo pipefail
+mount -t tmpfs -o nr_blocks=1,mode=0755 tmp $2
+if [ x$1 = xstart ]
+then
+ for i in /bin /dev/null /etc /lib /lib64 /usr
+ do
+ [ -d $i ] && mkdir -p $2/$i || { mkdir -p $2/`rev <<<$i | cut -d/ -f2- | rev` && touch $2/$i; }
+ mount --bind -onosuid,ro $i $2/$i
+ done
+ mkdir -p $2/jelka
+ mount --bind -onosuid,ro . $2/jelka
+ mkdir -p $2/dev/shm
+else
+ mount | grep $2 | cut -d\ -f3 | xargs -I '{}' umount '{}'
+fi