projects
/
rrq
/
overlay-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
278dd15
)
stop services in reverse order
author
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sat, 26 Mar 2022 23:09:21 +0000
(10:09 +1100)
committer
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sat, 26 Mar 2022 23:09:21 +0000
(10:09 +1100)
overlay-stop
patch
|
blob
|
history
diff --git
a/overlay-stop
b/overlay-stop
index d1e89acf581b8459e5aaf7a7f06627aa3a53e440..82961ec118b88eb53a6a98a7aeee1b53cc1791bd 100755
(executable)
--- a/
overlay-stop
+++ b/
overlay-stop
@@
-2,12
+2,17
@@
#
# Script to stop the nominated overlay subhost
#
# Script to stop the nominated overlay subhost
+OVERLAYDIR="$(dirname $(realpath $0))"
+
[ $(id -u) = 0 ] || exec sudo $0 $@
[ $(id -u) = 0 ] || exec sudo $0 $@
-. $
(dirname $(realpath $0))/functions XXX
+. $
OVERLAYDIR/functions $*
-NAME="$1"
+CONFIG="$1"
+[ -r "$CONFIG" ] || die "Missing configuration $CONFIG"
-[ -z "$NAME" ] && echo "Select subhost: $(list_running)" && exit 0
+config NAME $(basename $1 .${1##*.})
+config START "ssh networking"
+config LIVE
read USPID RSPID <<EOF
$(is_live $NAME)
read USPID RSPID <<EOF
$(is_live $NAME)
@@
-23,5
+28,16
@@
EOF
exit 1
fi
exit 1
fi
-CHILDPIDS="$(nsenter -t $RSPID -p -m ps -hopid --ppid 1)"
-nsenter -t $RSPID -p -m kill $CHILDPIDS
+# function to reverse the $* words
+reverse() {
+ local OUT=""
+ for w in $* ; do ; OUT="$w $OUT" ; done
+ echo "${OUT% }"
+}
+
+START="$(reverse "$START")"
+if nsenter -t $RSPID -p -m -i -u ip netns exec $NAME chroot $LIVE /bin/sh \
+ -c "for srv in $START ; do service \$srv stop ; done" ; then
+ CHILDPIDS="$(nsenter -t $RSPID -p -m ps -hopid --ppid 1)"
+ nsenter -t $RSPID -p -m kill $CHILDPIDS
+fi