reboot_prepare 1.02 KB
Newer Older
1
2
#!/bin/sh

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
. /etc/emulab/paths.sh

#
# XEN vms will just restart, so halt to really stop it.
# Luckily, OpenVZ VMs respect halt as well, so we can always halt
# inside of VMs.
#
dohalt=0
if [ -e "$BOOTDIR/vmname" ]; then
    dohalt=1
fi

reboot=1
if [ $# -eq 1 ]; then
    if [ "$1" = "-noreboot" ]; then
	reboot=0
    fi
fi

22
23
24
25
#
# Arrange for "prepare" to be run on the way down.
#
touch /var/lock/subsys/tbprepare
26
27
28
29
30
31
32
33
34
35
36
37
38

#
# If this Linux is using systemd as its init, make sure to "start" the tbprepare
# service.  systemd will not honor the K89tbprepare rc*.d symlinks *unless the
# tbprepare service has been started* -- and of course it doesn't "start" via
# an S89tbprepare link.  So we make sure systemd thinks it got started, and 
# then the K89tbprepare links will be run appropriately...
#
if [ -x /bin/systemd ]; then
    echo "Emulab scheduling tbprepare to run via systemd."
    systemctl start tbprepare.service
fi

39
if [ $reboot -eq 1 ]; then
40
41
42
43
44
    if [ $dohalt -eq 1 ]; then
        /sbin/halt
    else
        /sbin/reboot
    fi
45
fi
46
exit 0