pass HOST_ variables, not BUILD_
[buildroot.git] / package / acpid / S20acpid
blob5e4321c02ae2d442b16024bc5bff00eb3f4d9337
1 #! /bin/sh -e
2 ### BEGIN INIT INFO
3 # Provides: acpid
4 # Required-Start: $syslog
5 # Required-Stop: $syslog
6 # Should-Start: $local_fs
7 # Should-Stop: $local_fs
8 # Default-Start: 2 3 4 5
9 # Default-Stop: 0 1 6
10 # Short-Description: Start the Advanced Configuration and Power Interface daemon
11 # Description: Provide a socket for X11, hald and others to multiplex
12 # kernel ACPI events.
13 ### END INIT INFO
15 # Check for daemon presence
16 test -x /usr/sbin/acpid || exit 0
18 # Check for ACPI support on kernel side
19 [ -d /proc/acpi ] || exit 0
21 # Include acpid defaults if available
22 OPTIONS=""
23 if [ -f /etc/default/acpid ] ; then
24 . /etc/default/acpid
27 # Get lsb functions
28 [ -r /lib/lsb/init-functions ] && . /lib/lsb/init-functions
29 [ -r /etc/default/rcS ] && . /etc/default/rcS
31 if [ "x$VERBOSE" = "xno" ]; then
32 MODPROBE_OPTIONS="$MODPROBE_OPTIONS -q"
33 export MODPROBE_OPTIONS
36 # As the name says. If the kernel supports modules, it'll try to load
37 # the ones listed in "MODULES".
38 load_modules() {
39 LIST=`/sbin/lsmod|awk '!/Module/ {print $1}'`
41 # Get list of available modules
42 LOC="/lib/modules/`uname -r`/kernel/drivers/acpi"
43 if [ -d $LOC ]; then
44 MODAVAIL=`( find $LOC -type f -name "*.o"; \
45 find $LOC -type f -name "*.ko") | /bin/sed -e 's,.*/,,g' -e 's,\.ko,,g' -e 's,\.o,,g'`
46 else
47 MODAVAIL=""
50 if [ "$MODULES" = "all" ]; then
51 MODULES="$MODAVAIL"
54 if [ -n "$MODULES" ]; then
55 echo "Loading ACPI modules..."
56 STATUS=0
57 for mod in $MODULES; do
58 echo $MODAVAIL | grep -q -w "$mod" || continue
59 if echo $LIST | grep -q -w "$mod"; then
60 [ "$VERBOSE" != no ] && echo "Module already loaded: $mod"
61 else
62 if modprobe $mod 2>/dev/null; then
63 [ "$VERBOSE" != no ] && echo "Loaded module: $mod"
64 else
65 if [ "$VERBOSE" != no ]; then
66 echo "Unable to load module: $mod"
70 done
71 echo $STATUS
75 case "$1" in
76 start)
77 [ -f /proc/modules ] && load_modules
78 echo "Starting Advanced Configuration and Power Interface daemon..."
79 start-stop-daemon -S -q -x /usr/sbin/acpid -- -c /etc/acpi/events $OPTIONS
80 echo $?
82 stop)
83 echo "Stopping Advanced Configuration and Power Interface daemon..."
84 #start-stop-daemon -K -q -o -R 2 -x /usr/sbin/acpid
85 start-stop-daemon -K -q -x /usr/sbin/acpid
86 echo $?
88 restart)
89 $0 stop
90 sleep 1
91 $0 start
93 reload|force-reload)
94 $0 stop && $0 start
95 echo $?
98 echo "Usage: /etc/init.d/acpid {start|stop|restart|reload|force-reload}"
99 exit 1
100 esac
102 exit 0