also unshare ipc and utc on boot
[rrq/overlay-boot.git] / overlay-stop
1 #!/bin/sh
2 #
3 # Script to stop the nominated overlay subhost
4
5 [ $(id -u) = 0 ] || exec sudo $0 $@
6 . $(dirname $(realpath $0))/functions XXX
7
8 NAME="$1"
9
10 [ -z "$NAME" ] && echo "Select subhost: $(list_running)" && exit 0
11
12 read USPID RSPID <<EOF
13 $(is_live $NAME)
14 EOF
15
16 [ -z "$USPID" ] && echo "$NAME is snot running" >&2 && exit 1
17
18 if [ -z "$RSPID" ] ; then
19     cat <<EOF >&2
20 ***  $NAME is started (pid $USPID) but doesn't seem to be running
21 *** /.reaper and might need manual fixing.
22 EOF
23     exit 1
24 fi
25
26 CHILDPIDS="$(nsenter -t $RSPID -p -m ps -hopid --ppid 1)"
27 nsenter -t $RSPID -p -m kill $CHILDPIDS