X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=overlay-boot;h=5e6bef92a9b7451627b5d257ce14ade89a66381b;hb=a3b6bd2a94624852e5fef890fda9fde9548080f3;hp=431263da2474e30bcd370d270aa820269f5b1393;hpb=1962381a074900c46e81c122049bd4ce64cf4e59;p=rrq%2Foverlay-boot.git diff --git a/overlay-boot b/overlay-boot index 431263d..5e6bef9 100755 --- a/overlay-boot +++ b/overlay-boot @@ -4,10 +4,14 @@ # is an overlay of the subhost's root and an OS root. The service # subhost is defined by a configuration file named on teh command line +OVERLAYDIR="$(realpath $(dirname $0))" + [ $(id -u) = 0 ] || exec sudo $0 $@ . $(dirname $(realpath $0))/functions $* + CONFIG="$1" [ -r "$CONFIG" ] || die "Missing configuration $CONFIG" + config NAME $(basename $1 .${1##*.}) config LOG /tmp/oly-$NAME.log @@ -28,6 +32,10 @@ fi config BASE BASE="$(cd $(dirname $CONFIG); realpath $BASE)" +[ -z "$BASE" ] && die "BASE is unset; bogus $CONFIG ?" +[ -d "$BASE" ] || die "$BASE is not a directory; bogus $CONFIG ?" +cd "$BASE" || die "$BASE is inaccessible" + config LIVE "$BASE/live" config UPPER "$BASE/root" config WORK "$BASE/work" @@ -45,19 +53,35 @@ setup_overlay "$NAME" "$LIVE" "$LOWER" "$UPPER" "$WORK" exithandler() { ip netns del $NAME - umount -R "$LIVE" + [ "$LOWER" != "$LIVE" ] && umount -R "$LIVE" + [ -f "${UPPER%% *}" ] && [ -x "${UPPER%% *}" ] && \ + env ACTION=teardown $UPPER } trap "exithandler" 0 CMD="unshare -fp --mount-proc ip netns exec $NAME chroot $LIVE /bin/sh" echo "$CMD" +config RAM_SIZE 50M + cat <&2 + set +x + [ -p /run/dummy_service ] || mkfifo /run/dummy_service + ( printf dummy_service > /proc/self/comm ; read X < /run/dummy_service ) & + set -x +} +dummy_service /proc/*/comm exec /.reaper $NAME EOF echo "EXITED $CMD"