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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2831 - (hide annotations) (download) (as text)
Wed Aug 15 14:49:41 2007 UTC (11 years, 8 months ago) by uberlord
File MIME type: text/x-sh
File size: 2999 byte(s)
    `config /etc/fstab' can now be used in depend() functions to show that
    the deptree should be regenerated if /etc/fstab has changed.
1 uberlord 2547 #!/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 uberlord 2721 # Really kill things off before unmounting
18     if [ -x /sbin/killall5 ] ; then
19     killall5 -15
20     killall5 -9
21     fi
22    
23 uberlord 2547 # 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 uberlord 2831 cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
46     "${RC_SVCDIR}"/softlevel "${RC_SVCDIR}"/nettree \
47     "${RC_LIBDIR}" 2>/dev/null
48 uberlord 2547 umount "${RC_SVCDIR}"
49     rm -rf "${RC_SVCDIR}"/*
50     # Pipe errors to /dev/null as we may have future timestamps
51 uberlord 2831 cp -p "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/depconfig \
52     "${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree \
53     "${RC_SVCDIR}" 2>/dev/null
54     rm -f "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/depconfig \
55     "${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree
56 uberlord 2547 # Release the memory disk if we used it
57     case "${mnt}" in
58     "/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}" ;;
59     esac
60     fi
61    
62     unmounted=0
63     # Remount the remaining filesystems read-only
64 uberlord 2691 # Most BSD's don't need this as the kernel handles it nicely
65     if [ "${RC_UNAME}" = "Linux" ] ; then
66 uberlord 2547 ebegin "Remounting remaining filesystems read-only"
67     # We need the do_unmount function
68     . "${RC_LIBDIR}"/sh/rc-mount.sh
69     eindent
70 uberlord 2771 fs=
71     for x in ${RC_NET_FS_LIST} ; do
72     fs="${fs}${fs:+|}${x}"
73     done
74     [ -n "${fs}" ] && fs="^(${fs})$"
75     do_unmount "mount -n -o remount,ro" "^(/dev|/dev/pts|/dev/shm|/proc|/proc/.*|/sys)$" "" "" "${fs}"
76 uberlord 2547 eoutdent
77     eend $?
78     unmounted=$?
79     fi
80    
81     # This UPS code should be moved to out of here and to an addon
82     if [ -f /etc/killpower ] ; then
83     UPS_CTL=/sbin/upsdrvctl
84     UPS_POWERDOWN="${UPS_CTL} shutdown"
85     elif [ -f /etc/apcupsd/powerfail ] ; then
86     UPS_CTL=/etc/apcupsd/apccontrol
87     UPS_POWERDOWN="${UPS_CTL} killpower"
88     fi
89     if [ -x "${UPS_CTL}" ] ; then
90     ewarn "Signalling ups driver(s) to kill the load!"
91     ${UPS_POWERDOWN}
92     ewarn "Halt system and wait for the UPS to kill our power"
93     halt -id
94     sleep 60
95     fi
96    
97     if [ ${unmounted} -ne 0 ] ; then
98     [ -x /sbin/sulogin ] && sulogin -t 10 /dev/console
99     exit 1
100     fi
101    
102     # Load the final script - not needed on BSD so they should not exist
103     [ -e /etc/init.d/"$1".sh ] && . /etc/init.d/"$1".sh
104    
105     # Always exit 0 here
106     exit 0
107    
108     # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20