Add bind-mount for /etc/adjtime to make subhost use host clock without ado
[rrq/overlay-boot.git] / overlay-stop
1 #!/bin/sh
2 #
3 # Script to stop the nominated overlay subhost
4
5 OVERLAYDIR="$(dirname $(realpath $0))"
6 . $OVERLAYDIR/functions $*
7
8 subhost_name "$1"
9 subhost_config
10
11 read USPID RSPID <<EOF
12 $(is_live $NAME)
13 EOF
14
15 if [ -z "$USPID" ] ; then
16     [ -r /run/netns/$NAME ] && ip netns del $NAME
17     echo "$NAME is not running" >&2
18     exit 1
19 fi
20
21 if [ -z "$RSPID" ] ; then
22     cat <<EOF >&2
23 ***  $NAME is started (pid $USPID) but doesn't seem to be running
24 *** /.reaper and might need manual fixing.
25 EOF
26     exit 1
27 fi
28
29 START="$(reverse "$START")"
30 nsenter -t $RSPID -p -m -i -u \
31         ip netns exec $NAME chroot $(realpath $LIVE) \
32         /bin/sh -c "for srv in $START ; do service \$srv stop ; done"
33
34 for p in $RSPID $USPID ; do
35     for S in 15 1 2 9 ; do
36         ps -hocmd $p || break
37         kill -$S $p
38     done
39 done
40
41 [ -r /run/netns/$NAME ] && ip netns del $NAME
42
43 true