about summary refs log tree commit diff
path: root/3
blob: 577568d675c8b3b3cbd7974d6204e8b745330b90 (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
#!/bin/sh
# vim: set ts=4 sw=4 et:

PATH=/usr/bin:/usr/sbin

. /etc/rc.conf

if [ -e /run/runit/reboot ]; then
    touch /etc/runit/reboot
    chmod 100 /etc/runit/reboot
fi

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

stty onlcr

echo "Saving random seed..."
dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 >/dev/null 2>&1

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

halt -w  # for utmp

echo "Stopping udev..."
udevadm control --exit

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

echo "Unmounting filesystems, disabling swap..."
umount /tmp
swapoff -a
umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs

echo "Remounting rootfs read-only..."
mount -o remount,ro /
sleep 1
sync