CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
udev:added forgotten patch
[crossrootfs.git] / rc / rc.shutdown
CommitLineData
6dca1d21
JB
1#!/bin/bash
2#
3# /etc/rc.shutdown: system shutdown script
4#
5
6# Load configuration
7. /etc/rc.conf
8
9# Set linefeed mode to avoid staircase effect
10/bin/stty onlcr
11
12echo "The system is coming down. Please wait."
13
14if [ "$PREVLEVEL" = "2" ]; then
15 # Shutdown services
16 if [ "${SERVICES[*]}" ]; then
17 for service in "${SERVICES[@]}"; do
18 R_SERVICES=($service ${R_SERVICES[@]})
19 done
20 for service in "${R_SERVICES[@]}"; do
21 /etc/rc.d/$service stop &> /tmp/rc.$$
22 /usr/bin/logger -t $service -f /tmp/rc.$$
23 /bin/rm -f /tmp/rc.$$
24 done
25 fi
26fi
27
28# Terminate all processes
29/sbin/killall5 -15
30/bin/sleep 5
31/sbin/killall5 -9
32
33# Save random seed
34/bin/dd if=/dev/urandom of=/var/lib/urandom/seed count=1 2> /dev/null
35
36# Save system clock
37/sbin/hwclock --systohc
38
39# Write to wtmp file before unmounting
40/sbin/halt -w
41
42# Turn off swap
43/sbin/swapoff -a
44
45# Unmount file systems
dec3d7f0
VM
46/bin/umount -a -r -t nosysfs,noproc
47if [ -x /sbin/lvm ]; then
48 /sbin/vgchange --ignorelockingfailure -a n
49fi
6dca1d21
JB
50/bin/umount -a -r
51
52# Remount root filesystem read-only
53/bin/mount -n -o remount,ro /
54
55# Power off or reboot
56if [ "$RUNLEVEL" = "0" ]; then
57 /sbin/poweroff -d -f -i
58else
59 /sbin/reboot -d -f -i
60fi
61
62# End of file