lintian fixes
[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 read USPID RSPID <<EOF
11 $(is_live $NAME)
12 EOF
13
14 [ -z "$USPID" ] && echo "$NAME i snot running" >&2 && exit 1
15
16 if [ -z "$RSPID" ] ; then
17     cat <<EOF >&2
18 ***  $NAME is started (pid $USPID) but doesn't seem to be running
19 *** /.reaper and might need manual fixing.
20 EOF
21     exit 1
22 fi
23
24 CHILDPIDS="$(nsenter -t $RSPID -p -m ps -hopid --ppid 1)"
25 nsenter -t $RSPID -p -m kill $CHILDPIDS