added stop script
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 21 Mar 2022 03:29:08 +0000 (14:29 +1100)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 21 Mar 2022 03:29:08 +0000 (14:29 +1100)
overlay-stop [new file with mode: 0755]

diff --git a/overlay-stop b/overlay-stop
new file mode 100755 (executable)
index 0000000..2c57c52
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Script to stop the nominated overlay subhost
+
+[ $(id -u) = 0 ] || exec sudo $0 $@
+. $(dirname $(realpath $0))/functions XXX
+
+NAME="$1"
+
+read USPID RSPID <<EOF
+$(is_live $NAME)
+EOF
+
+[ -z "$USPID" ] && echo "$NAME i snot running" >&2 && exit 1
+
+if [ -z "$RSPID" ] ; then
+    cat <<EOF >&2
+***  $NAME is started (pid $USPID) but doesn't seem to be running
+*** /.reaper and might need manual fixing.
+EOF
+    exit 1
+fi
+
+CHILDPIDS="$(nsenter -t $RSPID -p -m ps -hopid --ppid 1)"
+nsenter -t $RSPID -p -m kill $CHILDPIDS