~ubuntu-dev/ubuntu/lucid/acpid/lucid-201002110914

« back to all changes in this revision

Viewing changes to debian/init

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2006-07-11 17:50:13 UTC
  • mfrom: (1.1.2 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20060711175013-fg69dxvr9u2gcfh7
Tags: 1.0.4-5ubuntu1
* Merge from debian unstable, remaining changes:
  - Lock file and groups,
  - LSB init script,
  - init script level change,
  - load all modules by default,
  - Power button handling changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh -e
2
 
 
3
 
# Check for daemon presence
4
 
test -x /usr/sbin/acpid || exit 0
5
 
 
6
 
# Check for ACPI support on kernel side
7
 
[ -d /proc/acpi ] || exit 0
8
 
 
9
 
# Include acpid defaults if available
10
 
OPTIONS=""
11
 
if [ -f /etc/default/acpid ] ; then
12
 
        . /etc/default/acpid
13
 
fi
14
 
 
15
 
# Get lsb functions
16
 
. /lib/lsb/init-functions
17
 
. /etc/default/rcS
18
 
 
19
 
if [ "x$VERBOSE" = "xno" ]; then
20
 
        MODPROBE_OPTIONS="$MODPROBE_OPTIONS -Q"
21
 
        export MODPROBE_OPTIONS
22
 
fi
23
 
 
24
 
# As the name says. If the kernel supports modules, it'll try to load
25
 
# the ones listed in "MODULES".
26
 
load_modules() {
27
 
        PRINTK=`cat /proc/sys/kernel/printk`
28
 
        [ "$VERBOSE" = no ] && echo "0 0 0 0" > /proc/sys/kernel/printk
29
 
        
30
 
        LIST=`/sbin/lsmod|awk '!/Module/ {print $1}'`
31
 
 
32
 
        # Get list of available modules
33
 
        LOC="/lib/modules/`uname -r`/kernel/drivers/acpi"
34
 
        if [ -d $LOC ]; then
35
 
          MODAVAIL=`( find $LOC -type f -name "*.o" -printf "basename %f .o\n"; \
36
 
                find $LOC -type f -name "*.ko" -printf "basename %f .ko\n" ) | /bin/sh`
37
 
        else
38
 
          MODAVAIL=""
39
 
        fi
40
 
 
41
 
        if [ "$MODULES" = "all" ]; then
42
 
                MODULES="$MODAVAIL"
43
 
        fi
44
 
 
45
 
        if [ -n "$MODULES" ]; then
46
 
                log_begin_msg "Loading ACPI modules..."
47
 
                STATUS=0
48
 
                for mod in $MODULES; do
49
 
                        echo $MODAVAIL | grep -q -w "$mod" || continue
50
 
                        if echo $LIST | grep -q -w "$mod"; then
51
 
                                [ "$VERBOSE" != no ] && log_success_msg "Module already loaded: $mod"
52
 
                        else
53
 
                                if modprobe $mod 2>/dev/null; then
54
 
                                        [ "$VERBOSE" != no ] && log_success_msg "Loaded module: $mod"
55
 
                                else
56
 
                                        if [ "$VERBOSE" != no ]; then
57
 
                                                log_warning_msg "Unable to load module: $mod"
58
 
                                        fi
59
 
                                fi
60
 
                        fi              
61
 
                done
62
 
                log_end_msg $STATUS
63
 
        fi
64
 
        echo "$PRINTK" > /proc/sys/kernel/printk
65
 
}
66
 
 
67
 
case "$1" in
68
 
  start)
69
 
    [ -f /proc/modules ] && load_modules
70
 
    log_begin_msg "Starting ACPI services..."
71
 
    start-stop-daemon --start --quiet --exec /usr/sbin/acpid -- -c /etc/acpi/events $OPTIONS
72
 
    log_end_msg $?
73
 
    ;;
74
 
  stop)
75
 
    log_begin_msg "Stopping ACPI services..."
76
 
    start-stop-daemon --stop --quiet --oknodo --retry 2 --exec /usr/sbin/acpid
77
 
    log_end_msg $?
78
 
    ;;
79
 
  restart)
80
 
    $0 stop
81
 
    sleep 1
82
 
    $0 start
83
 
    ;;
84
 
  reload|force-reload) 
85
 
    log_begin_msg "Reloading ACPI services..."
86
 
    start-stop-daemon --stop --signal 1 --exec /usr/sbin/acpid
87
 
    log_end_msg $?
88
 
    ;;
89
 
  *)
90
 
    log_success_msg "Usage: /etc/init.d/acpid {start|stop|restart|reload|force-reload}"
91
 
    exit 1
92
 
esac
93
 
 
94
 
exit 0