summary refs log tree commit diff
path: root/3
blob: 726d26adf5b3b0bc3b383c0911630d649234a641 (plain) (blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# vim: set ts=4 sw=4 et:

PATH=/usr/bin:/usr/sbin

. /etc/runit/functions
detect_virt
[ -r /etc/rc.conf ] && . /etc/rc.conf

echo
msg "Waiting for services to stop..."
sv force-stop /var/service/*
sv exit /var/service/*

[ -x /etc/rc.shutdown ] && /etc/rc.shutdown

if [ -z "$VIRTUALIZATION" ]; then
    seedrng
fi

if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then
    hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
fi

halt -w  # for wtmp

if [ -z "$VIRTUALIZATION" ]; then
    msg "Stopping udev..."
    udevadm control --exit
fi

msg "Sending TERM signal to processes..."
pkill --inverse -s0,1 -TERM
sleep 1
msg "Sending KILL signal to processes..."
pkill --inverse -s0,1 -KILL

if [ -z "$VIRTUALIZATION" ]; then
    msg "Unmounting filesystems, disabling swap..."
    swapoff -a
    umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs
    msg "Remounting rootfs read-only..."
    mount -o remount,ro /
fi

sync

if [ -z "$VIRTUALIZATION" ]; then
    deactivate_vgs
    deactivate_crypt
    if [ -e /run/runit/reboot ] && command -v kexec >/dev/null; then
        msg "Triggering kexec..."
        kexec -e 2>/dev/null
        # not reached when kexec was successful.
    fi
fi