]> code.delx.au - monosys/commitdiff
Chroot script
authorJames Bunton <jamesbunton@fastmail.fm>
Mon, 24 Mar 2008 13:46:05 +0000 (00:46 +1100)
committerJames Bunton <jamesbunton@fastmail.fm>
Mon, 24 Mar 2008 13:46:05 +0000 (00:46 +1100)
scripts/chroot [new file with mode: 0755]

diff --git a/scripts/chroot b/scripts/chroot
new file mode 100755 (executable)
index 0000000..7fcf134
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+CHROOT_PATH="/path/to/chroot"
+
+function noremount {
+       if ! mount | grep -q "$2"; then
+               echo "Mounting $1 into chroot"
+               sudo mount --bind "$1" "$2"
+       fi
+}
+
+noremount /dev/pts "${CHROOT_PATH}/dev/pts"
+noremount /proc "${CHROOT_PATH}/proc"
+exec nice -n 5 sudo chroot "$CHROOT_PATH" sudo -u root env EMAIL="$EMAIL" COLORFGBG="$COLORFGBG" bash -l
+