Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ROOTFS=/tmp/jail
- # ensure that the TC initrd file is available
- mount | grep -qF '/dev/hdc' || mount /dev/hdc
- [ -f /mnt/hdc/boot/tinycore.gz ] || ! echo "can not find initrd file" || exit 1
- # remove all traces of a previous run
- MOUNTS=$(mount | grep -F " on ${ROOTFS}/" | sed -e 's#.* on ##' -e 's# .*##')
- [ -z "$MOUNTS" ] || echo "$MOUNTS" | xargs -n 1 umount \
- || ! echo "umount failed" || exit 3
- sudo rm -rf $ROOTFS 2> /dev/null || ! echo "rm $ROOTFS failed" || exit 4
- # prepare the "jail" (step 1): extract initrd
- mkdir -p $ROOTFS
- cd $ROOTFS
- zcat /mnt/hdc/boot/tinycore.gz | sudo cpio -idum > /dev/null
- # prepare the "jail" (step 2): execute a subset of /etc/init.d/tc-config + more
- for D in usr/local/tce.icons usr/local/tce.installed usr/local/tce.menu \
- tmp/tce tmp/tcloop ; do
- [ -d "$D" ] || sudo mkdir "$D"
- sudo chgrp staff "$D"
- sudo chmod g+w "$D"
- done
- echo '/tmp/tce' > opt/.tce_dir
- # ensure the presence of ~/.Xauthority
- [ -f $HOME/.Xauthority ] && cp -p $HOME/.Xauthority ${HOME#/}
- # prepare the "jail" (step 3): mount the required file systems
- sudo mount -o bind /proc $ROOTFS/proc
- sudo mount -o bind /dev/pts $ROOTFS/dev/pts
- sudo mount -o bind /tmp $ROOTFS/tmp
- echo "you should now be able to execute: sudo chroot $ROOTFS su $USER"
Advertisement
Add Comment
Please, Sign In to add comment