-
Notifications
You must be signed in to change notification settings - Fork 4
/
rc.shutdown
executable file
·50 lines (35 loc) · 1.17 KB
/
rc.shutdown
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
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
[ -r /etc/runit/runit.conf ] && . /etc/runit/runit.conf
COLOUR="\e[1;90m"
CRESET="\e[0m"
msg() {
printf "${COLOUR}*${CRESET} $*\n"
}
[ -x /etc/runit/rc.shutdown.local ] && /etc/runit/rc.shutdown.local
msg "Saving random seed..."
dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null
if [ "$HARDWARECLOCK" ]; then
msg "Saving system time to hardware clock..."
hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
fi
msg "Stopping udev..."
udevadm control --exit
msg "Sending TERM signal to processes..."
pkill --inverse -s0,1 -TERM
sleep 1
msg "Sending KILL signal to processes..."
pkill --inverse -s0,1 -KILL
msg "Deactivating all swap files/partitions..."
swapoff -a
msg "Bringing down the loopback interface..."
ip link set lo down
msg "Unmounting all other currently mounted file systems..."
umount --all --detach-loop --read-only \
--types notmpfs,nosysfs,nodevtmpfs,noproc,nodevpts >/dev/null
msg "Remount root filesystem in read-only mode..."
mount --options remount,ro /
msg "Bringing down the loopback interface..."
ip link set lo down
msg "Flushing filesystem buffers..."
sync