chiark / gitweb /
document chroot package requirements; ensure directories exist; bind-mount ~/.ssh...
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Sat, 11 Oct 2008 20:23:56 +0000 (20:23 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Sat, 11 Oct 2008 20:23:56 +0000 (20:23 +0000)
chroot-setup
chroot-teardown

index 015acda..5cd1c19 100755 (executable)
@@ -1,5 +1,12 @@
 #! /bin/sh -e
+# Install keychain xauth x11-xserver-utils in the chroot first.
 if [ -e "$1/proc/cmdline" ]; then exit; fi
+
+ensure_dir_mine () {
+       sudo mkdir -p "$1"
+       sudo chown cjwatson:cjwatson "$1"
+}
+
 sudo mount --bind /proc "$1/proc"
 sudo mount --bind /sys "$1/sys"
 sudo mount --bind /dev "$1/dev"
@@ -8,20 +15,27 @@ mkdir -p "$1/tmp/.X11-unix" "$1/tmp/.ICE-unix"
 sudo mount --bind /tmp/.X11-unix "$1/tmp/.X11-unix"
 sudo mount --bind /tmp/.ICE-unix "$1/tmp/.ICE-unix"
 if [ "$SSH_AUTH_SOCK" ]; then
-       sudo mkdir -p "$1$(dirname "$SSH_AUTH_SOCK")"
+       ensure_dir_mine "$1$(dirname "$SSH_AUTH_SOCK")"
        sudo mount --bind "$(dirname "$SSH_AUTH_SOCK")" "$1$(dirname "$SSH_AUTH_SOCK")"
 fi
+if [ -d /home/cjwatson/.ssh/control ]; then
+       ensure_dir_mine "$1/home/cjwatson/.ssh"
+       ensure_dir_mine "$1/home/cjwatson/.ssh/control"
+       sudo mount --bind /home/cjwatson/.ssh/control "$1/home/cjwatson/.ssh/control"
+fi
 if [ "$GPG_AGENT_INFO" ]; then
-       sudo mkdir -p "$1$(dirname "$GPG_AGENT_INFO")"
+       ensure_dir_mine "$1$(dirname "$GPG_AGENT_INFO")"
        sudo mount --bind "$(dirname "$GPG_AGENT_INFO")" "$1$(dirname "$GPG_AGENT_INFO")"
 fi
 if [ -d /home/cjwatson/.keychain ]; then
+       ensure_dir_mine "$1/home/cjwatson/.keychain"
        sudo mount --bind /home/cjwatson/.keychain "$1/home/cjwatson/.keychain"
 fi
 xauth list | sudo chroot "$1" su cjwatson -c 'xargs -l1 xauth add'
 rm -f "$1/home/cjwatson/.ICEauthority"
 iceauth list | sudo chroot "$1" su cjwatson -c 'xargs -l1 iceauth add'
 sudo cp -a /etc/resolv.conf "$1/etc/"
-if [ -d /home/cjwatson/src ] && [ -d "$1/home/cjwatson/src" ]; then
+if [ -d /home/cjwatson/src ]; then
+       ensure_dir_mine "$1/home/cjwatson/src"
        sudo mount --bind /home/cjwatson/src "$1/home/cjwatson/src"
 fi
index f7ceed9..4b5693b 100755 (executable)
@@ -18,6 +18,7 @@ maybe_umount /home/cjwatson/.keychain
 if [ "$GPG_AGENT_INFO" ]; then
        maybe_umount "$(dirname "$GPG_AGENT_INFO")"
 fi
+maybe_umount /home/cjwatson/.ssh/control
 if [ "$SSH_AUTH_SOCK" ]; then
        maybe_umount "$(dirname "$SSH_AUTH_SOCK")"
 fi