/[baselayout]/trunk/init.d/halt.sh
Gentoo

Contents of /trunk/init.d/halt.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2721 - (show annotations) (download) (as text)
Wed May 30 22:30:54 2007 UTC (7 years, 2 months ago) by uberlord
File MIME type: text/x-sh
File size: 2799 byte(s)
    Use killall5 again so we can cleanly remount / readonly, #168977
    and #177689.
1 #!/bin/sh
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 . /etc/init.d/functions.sh
6 . "${RC_LIBDIR}"/sh/rc-functions.sh
7
8 # Support LiveCD foo
9 if [ -r /sbin/livecd-functions.sh ] ; then
10 . /sbin/livecd-functions.sh
11 livecd_read_commandline
12 fi
13
14 stop_addon devfs
15 stop_addon udev
16
17 # Really kill things off before unmounting
18 if [ -x /sbin/killall5 ] ; then
19 killall5 -15
20 killall5 -9
21 fi
22
23 # Flush all pending disk writes now
24 sync ; sync
25
26 # If we are in a VPS, we don't need anything below here, because
27 # 1) we don't need (and by default can't) umount anything (VServer) or
28 # 2) the host utils take care of all umounting stuff (OpenVZ)
29 if [ "${RC_SYS}" = "VPS" ] ; then
30 if [ -e /etc/init.d/"$1".sh ] ; then
31 . /etc/init.d/"$1".sh
32 else
33 exit 0
34 fi
35 fi
36
37 # If $svcdir is still mounted, preserve it if we can
38 if mountinfo "${RC_SVCDIR}" >/dev/null && [ -w "${RC_LIBDIR}" ] ; then
39 f_opts="-m -c"
40 [ "${RC_UNAME}" = "Linux" ] && f_opts="-c"
41 if [ -n "$(fuser ${f_opts} "${svcdir}" 2>/dev/null)" ] ; then
42 fuser -k ${f_opts} "${svcdir}" 1>/dev/null 2>/dev/null
43 sleep 2
44 fi
45 cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/softlevel \
46 "${RC_SVCDIR}"/nettree "${RC_LIBDIR}" 2>/dev/null
47 umount "${RC_SVCDIR}"
48 rm -rf "${RC_SVCDIR}"/*
49 # Pipe errors to /dev/null as we may have future timestamps
50 cp -p "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/softlevel \
51 "${RC_LIBDIR}"/nettree "${RC_SVCDIR}" 2>/dev/null
52 rm -f "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/softlevel \
53 "${RC_LIBDIR}"/nettree
54 # Release the memory disk if we used it
55 case "${mnt}" in
56 "/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}" ;;
57 esac
58 fi
59
60 unmounted=0
61 # Remount the remaining filesystems read-only
62 # Most BSD's don't need this as the kernel handles it nicely
63 if [ "${RC_UNAME}" = "Linux" ] ; then
64 ebegin "Remounting remaining filesystems read-only"
65 # We need the do_unmount function
66 . "${RC_LIBDIR}"/sh/rc-mount.sh
67 eindent
68 do_unmount "mount -n -o remount,ro" "^(/dev|/dev/pts|/dev/shm|/proc|/proc/.*|/sys)$"
69 eoutdent
70 eend $?
71 unmounted=$?
72 fi
73
74 # This UPS code should be moved to out of here and to an addon
75 if [ -f /etc/killpower ] ; then
76 UPS_CTL=/sbin/upsdrvctl
77 UPS_POWERDOWN="${UPS_CTL} shutdown"
78 elif [ -f /etc/apcupsd/powerfail ] ; then
79 UPS_CTL=/etc/apcupsd/apccontrol
80 UPS_POWERDOWN="${UPS_CTL} killpower"
81 fi
82 if [ -x "${UPS_CTL}" ] ; then
83 ewarn "Signalling ups driver(s) to kill the load!"
84 ${UPS_POWERDOWN}
85 ewarn "Halt system and wait for the UPS to kill our power"
86 halt -id
87 sleep 60
88 fi
89
90 if [ ${unmounted} -ne 0 ] ; then
91 [ -x /sbin/sulogin ] && sulogin -t 10 /dev/console
92 exit 1
93 fi
94
95 # Load the final script - not needed on BSD so they should not exist
96 [ -e /etc/init.d/"$1".sh ] && . /etc/init.d/"$1".sh
97
98 # Always exit 0 here
99 exit 0
100
101 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20