~ubuntu-branches/debian/experimental/sysvinit/experimental

« back to all changes in this revision

Viewing changes to debian/initscripts/etc/init.d/halt

  • Committer: Bazaar Package Importer
  • Author(s): Petter Reinholdtsen
  • Date: 2008-08-12 16:07:50 UTC
  • Revision ID: james.westby@ubuntu.com-20080812160750-65gpyv74vh4qr69w
Tags: 2.86.ds1-61
* Fix typo in rcS(5), proberly->properly (Closes: #484233).  Thanks to
  Julien Danjou for noticing.
* Fix typo in rcS(5), maually->manually (Closes: #493680).  Thanks to
  Xr for noticing.
* Modify runlevel detection code in invoke-rc.d to notice the
  difference between runlevels 0 and 6, and the boot runlevel, to
  make it possible to use invoke-rc.d during boot (Closes: 384509).
* Make sure to call restorecon after mounting tmpfs file systems, to
  set SELinux permissions (Closes: #493679).  Patch from Russell
  Coker.
* Move responsibility of stopping the splash screen process from
  individual init.d scripts to init.d/rc.  This make sure the
  progress calculation reflect reality, and that the splash screen
  is taken down in runlevel 1 (Closes: #431560) and that it stop
  before gdm and kdm (Closes: #422922, #489734).
* Skip error message from checkfs.sh when / is read-only.  Patch
  from Mirek Slugen (Closes: #492214).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
 
#
3
 
# halt          Execute the halt command.
4
 
#
5
 
# Version:      @(#)halt  2.85-22  19-Jun-2004  miquels@cistron.nl
6
 
#
7
 
 
8
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
9
 
 
10
 
# Get the default from /etc/default/halt.
 
2
### BEGIN INIT INFO
 
3
# Provides:          halt
 
4
# Required-Start:
 
5
# Required-Stop:
 
6
# Default-Start:
 
7
# Default-Stop:      0
 
8
# Short-Description: Execute the halt command.
 
9
# Description:
 
10
### END INIT INFO
 
11
 
 
12
NETDOWN=yes
 
13
 
 
14
PATH=/sbin:/usr/sbin:/bin:/usr/bin
11
15
[ -f /etc/default/halt ] && . /etc/default/halt
12
16
 
13
 
if [ "$INIT_HALT" = "" ]
14
 
then
15
 
        case "$HALT" in
16
 
                [Pp]*)
 
17
. /lib/lsb/init-functions
 
18
 
 
19
do_stop () {
 
20
        if [ "$INIT_HALT" = "" ]
 
21
        then
 
22
                case "$HALT" in
 
23
                  [Pp]*)
17
24
                        INIT_HALT=POWEROFF
18
25
                        ;;
19
 
                [Hh]*)
 
26
                  [Hh]*)
20
27
                        INIT_HALT=HALT
21
28
                        ;;
22
 
                *)
 
29
                  *)
23
30
                        INIT_HALT=POWEROFF
24
31
                        ;;
25
 
        esac
26
 
fi
27
 
 
28
 
# See if we need to cut the power.
29
 
if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ]
30
 
then
31
 
        /etc/init.d/ups-monitor poweroff
32
 
fi
33
 
 
34
 
# Don't shut down drives if we're using RAID.
35
 
hddown="-h"
36
 
if grep -qs '^md.*active' /proc/mdstat
37
 
then
38
 
        hddown=""
39
 
fi
40
 
 
41
 
# If INIT_HALT=HALT don't poweroff.
42
 
poweroff="-p"
43
 
if [ "$INIT_HALT" = "HALT" ]
44
 
then
45
 
        poweroff=""
46
 
fi
47
 
 
48
 
halt -d -f -i $poweroff $hddown
49
 
 
50
 
: exit 0
 
32
                esac
 
33
        fi
 
34
 
 
35
        # See if we need to cut the power.
 
36
        if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ]
 
37
        then
 
38
                /etc/init.d/ups-monitor poweroff
 
39
        fi
 
40
 
 
41
        # Don't shut down drives if we're using RAID.
 
42
        hddown="-h"
 
43
        if grep -qs '^md.*active' /proc/mdstat
 
44
        then
 
45
                hddown=""
 
46
        fi
 
47
 
 
48
        # If INIT_HALT=HALT don't poweroff.
 
49
        poweroff="-p"
 
50
        if [ "$INIT_HALT" = "HALT" ]
 
51
        then
 
52
                poweroff=""
 
53
        fi
 
54
 
 
55
        # Make it possible to not shut down network interfaces,
 
56
        # needed to use wake-on-lan
 
57
        netdown="-i"
 
58
        if [ "$NETDOWN" = "no" ]; then
 
59
                netdown=""
 
60
        fi
 
61
 
 
62
        log_action_msg "Will now halt"
 
63
        halt -d -f $netdown $poweroff $hddown
 
64
}
 
65
 
 
66
case "$1" in
 
67
  start)
 
68
        # No-op
 
69
        ;;
 
70
  restart|reload|force-reload)
 
71
        echo "Error: argument '$1' not supported" >&2
 
72
        exit 3
 
73
        ;;
 
74
  stop)
 
75
        do_stop
 
76
        ;;
 
77
  *)
 
78
        echo "Usage: $0 start|stop" >&2
 
79
        exit 3
 
80
        ;;
 
81
esac
 
82
 
 
83
: