summaryrefslogtreecommitdiff
path: root/sinit/rc.shutdown
blob: 24cc606a71224e17795c578a08745b7ac06a3bf2 (plain)
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
#!/bin/sh
umask 022

. /etc/rc.conf

case "$1" in
reboot|poweroff) ;;
*)
	echo "Invalid action '$1' for rc.shutdown" >&2
	exit 1
	;;
esac

# avoid staircase effect by setting linefeed mode
echo; /bin/stty onlcr

echo Shutting down

echo Saving system clock
[ -n "$TIMEZONE" ] && export TZ="$TIMEZONE"
/bin/hwclock -w -u /dev/rtc0
unset TZ

/bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null

echo Sending TERM to all processes
/bin/killall5 -s TERM
/bin/sleep 3
echo Sending KILL to all processes
/bin/killall5 -s KILL

echo Remounting root as read-only
/bin/mount -o remount,ro /

echo Unmounting filesystems
/bin/umount -a

/bin/sync
/bin/sleep 3
wait

echo Good bye.

case "$1" in
reboot) /bin/halt -r ;;
poweroff) /bin/halt -p ;;
esac