-
Notifications
You must be signed in to change notification settings - Fork 6
/
rc.shutdown
executable file
·71 lines (55 loc) · 1.38 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
#
# /etc/rc.shutdown: System Shutdown Script
#
. /etc/rc.conf
. /etc/rc.subr
echo
[ -x /etc/rc.shutdown.local ] && /etc/rc.shutdown.local
if [ "$PREVLEVEL" = "2" ]; then
if [ "$DAEMONS" ]; then
for daemon in $DAEMONS; do
R_DAEMONS="$daemon $R_DAEMONS"
done
for daemon in $R_DAEMONS; do
if [ -x /etc/rc.d/$daemon ]; then
/etc/rc.d/$daemon stop
fi
done
fi
fi
msg "Stopping udev..."
udevadm control --exit
msg "Sending all processes the TERM signal..."
killall5 -15
sleep 1
msg "Sending all processes the KILL signal..."
killall5 -9
msg "Saving random seed..."
dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null
msg "Saving system time to hardware clock..."
hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK | tr A-Z a-z)}
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 -a -d -r -t notmpfs,nosysfs,nodevtmpfs,noproc,nodevpts
msg "Remount root filesystem in read-only mode..."
mount -o remount,ro /
if [ "$RUNLEVEL" = 0 ]; then
msg "Writing a halt record to wtmp..."
halt -w
else
msg "Writing a reboot record to wtmp..."
reboot -w
fi
msg "Flushing filesystem buffers..."
sync
if [ "$RUNLEVEL" = 0 ]; then
msg "Powering off..."
halt -d -f -i -p
else
msg "Rebooting..."
reboot -d -f -i
fi