File: overlay-stop

package info (click to toggle)
overlay-boot 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 184 kB
  • sloc: sh: 253; makefile: 59; ansic: 26
file content (43 lines) | stat: -rwxr-xr-x 835 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
#
# Script to stop the nominated overlay subhost

OVERLAYDIR="$(dirname $(realpath $0))"
. $OVERLAYDIR/functions $*

subhost_name "$1"
subhost_config

read USPID RSPID <<EOF
$(is_live $NAME)
EOF

if [ -z "$USPID" ] ; then
    [ -r /run/netns/$NAME ] && ip netns del $NAME
    echo "$NAME is not running" >&2
    exit 1
fi

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

START="$(reverse "$START")"
nsenter -t $RSPID -p -m -i -u \
	ip netns exec $NAME chroot $(realpath $LIVE) \
	/bin/sh -c "for srv in $START ; do service \$srv stop ; done"

for p in $RSPID $USPID ; do
    for S in 15 1 2 9 ; do
	ps -hocmd $p || break
	kill -$S $p
    done
done

[ -r /run/netns/$NAME ] && ip netns del $NAME

true