CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Imported core-cross ports from 2.5
[crossrootfs.git] / rc / rc.shutdown
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
12 echo "The system is coming down. Please wait."
13
14 if [ "$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
26 fi
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
46 /bin/umount -a -r
47
48 # Remount root filesystem read-only
49 /bin/mount -n -o remount,ro /
50
51 # Power off or reboot
52 if [ "$RUNLEVEL" = "0" ]; then
53 /sbin/poweroff -d -f -i
54 else
55 /sbin/reboot -d -f -i
56 fi
57
58 # End of file