3 # Script to stop the nominated overlay subhost
5 OVERLAYDIR="$(dirname $(realpath $0))"
7 [ $(id -u) = 0 ] || exec sudo $0 $@
8 . $OVERLAYDIR/functions $*
11 [ -r "$CONFIG" ] || die "Missing configuration $CONFIG"
13 config NAME $(basename $1 .${1##*.})
14 config START "ssh networking"
17 read USPID RSPID <<EOF
21 [ -z "$USPID" ] && echo "$NAME is snot running" >&2 && exit 1
23 if [ -z "$RSPID" ] ; then
25 *** $NAME is started (pid $USPID) but doesn't seem to be running
26 *** /.reaper and might need manual fixing.
31 # function to reverse the $* words
34 for w in $* ; do ; OUT="$w $OUT" ; done
38 START="$(reverse "$START")"
39 if nsenter -t $RSPID -p -m -i -u ip netns exec $NAME chroot $LIVE /bin/sh \
40 -c "for srv in $START ; do service \$srv stop ; done" ; then
41 CHILDPIDS="$(nsenter -t $RSPID -p -m ps -hopid --ppid 1)"
42 nsenter -t $RSPID -p -m kill $CHILDPIDS