135 lines
3.3 KiB
Bash
135 lines
3.3 KiB
Bash
#!/bin/bash
|
|
#
|
|
# /etc/rc.d/init.d/acpid
|
|
#
|
|
# Starts the acpi daemon
|
|
#
|
|
# chkconfig: 345 44 01
|
|
# description: Listen and dispatch ACPI events from the kernel
|
|
# processname: acpid
|
|
|
|
# Source function library.
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
if [ -f /etc/sysconfig/acpi ]; then
|
|
source /etc/sysconfig/acpi
|
|
fi
|
|
|
|
DAEMON=acpi
|
|
PROGNAME=${DAEMON}d
|
|
test -x /usr/sbin/$PROGNAME || exit 0
|
|
|
|
RETVAL=0
|
|
|
|
#
|
|
# See how we were called.
|
|
#
|
|
|
|
start() {
|
|
# Check if it is already running
|
|
if [[ ! -f /var/lock/subsys/$PROGNAME && -e /proc/acpi ]]; then
|
|
echo -n "Loading ACPI modules: "
|
|
if [ "$AC" != "no" ];then
|
|
action "Loading ACPI AC control module" /sbin/modprobe ac 2>/dev/null
|
|
fi
|
|
if [ "$BATTERY" != "no" ];then
|
|
action "Loading ACPI BATTERY control module" /sbin/modprobe battery 2>/dev/null
|
|
fi
|
|
if [ "$FAN" != "no" ];then
|
|
action "Loading ACPI FAN control module" /sbin/modprobe fan 2>/dev/null
|
|
fi
|
|
if [ "$HOTKEY" != "no" ];then
|
|
action "Loading ACPI HOTKEY control module" /sbin/modprobe hotkey 2>/dev/null \
|
|
|| echo "HOTKEY=no" >> /etc/sysconfig/acpi
|
|
fi
|
|
if [ "$THERMAL" != "no" ];then
|
|
action "Loading ACPI THERMAL control module" /sbin/modprobe thermal 2>/dev/null
|
|
fi
|
|
if [ "$BUTTON" != "no" ];then
|
|
action "Loading ACPI BUTTON control module" /sbin/modprobe button 2>/dev/null
|
|
fi
|
|
if [ "$PROCESSOR" != "no" ];then
|
|
action "Loading ACPI PROCESSOR control module" /sbin/modprobe processor 2>/dev/null
|
|
fi
|
|
if [ "$ASUS_ACPI" != "no" ];then
|
|
action "Loading ACPI ASUS control module" /sbin/modprobe asus_acpi 2>/dev/null \
|
|
|| echo "ASUS_ACPI=no" >> /etc/sysconfig/acpi
|
|
fi
|
|
if [ "$IBM_ACPI" != "no" ];then
|
|
action "Loading ACPI IBM control module" /sbin/modprobe ibm_acpi 2>/dev/null \
|
|
|| echo "IBM_ACPI=no" >> /etc/sysconfig/acpi
|
|
fi
|
|
if [ "$TOSHIBA_ACPI" != "no" ];then
|
|
action "Loading ACPI TOSHIBA control module" /sbin/modprobe toshiba_acpi 2>/dev/null\
|
|
|| echo "TOSHIBA_ACPI=no" >> /etc/sysconfig/acpi
|
|
fi
|
|
if [ "$CONTAINER" != "no" ];then
|
|
action "Loading ACPI CONTAINER control module" /sbin/modprobe container 2>/dev/null
|
|
fi
|
|
if [ "$VIDEO" != "no" ];then
|
|
action "Loading ACPI VIDEO control module" /sbin/modprobe video 2>/dev/null
|
|
fi
|
|
if [ "$CPU_FREQ" -a "$CPU_FREQ" != "no" ];then
|
|
action "Loading CPUFREQ control module" /sbin/modprobe $CPU_FREQ 2>/dev/null
|
|
fi
|
|
if [ -e /proc/acpi/event ]; then
|
|
echo -n "Starting $DAEMON daemon: "
|
|
daemon /usr/sbin/$PROGNAME
|
|
RETVAL=$?
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROGNAME
|
|
echo
|
|
fi
|
|
fi
|
|
return $RETVAL
|
|
}
|
|
|
|
stop() {
|
|
if [[ -f /var/lock/subsys/$PROGNAME && -e /proc/acpi/event ]]; then
|
|
echo -n "Stopping $DAEMON daemon: "
|
|
killproc /usr/sbin/$PROGNAME
|
|
RETVAL=$?
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROGNAME
|
|
echo
|
|
return $RETVAL
|
|
fi
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
reload() {
|
|
trap "" SIGHUP
|
|
killall -HUP $PROGNAME
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
reload)
|
|
reload
|
|
;;
|
|
restart)
|
|
restart
|
|
;;
|
|
condrestart)
|
|
if [ -f /var/lock/subsys/$PROGNAME ]; then
|
|
restart
|
|
fi
|
|
;;
|
|
status)
|
|
status $PROGNAME
|
|
;;
|
|
*)
|
|
INITNAME=`basename $0`
|
|
echo "Usage: $INITNAME {start|stop|restart|condrestart|status}"
|
|
exit 1
|
|
esac
|
|
|
|
exit $RETVAL
|