|
|
| (2 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| − | #!/bin/bash
| + | {{CodeHeader| |
| − | #
| + | |filename=tp-fancontrol |
| − | # tp-fancontrol
| + | |context=[[ACPI fan control script#Init script example for rh/fedora]] |
| − | #
| + | |author=Nikolay Fiykov |
| − | # nikolay fiykov (fikin@sf.net)
| + | |license=GPL v2 |
| − | #
| + | }} |
| − | # chkconfig: 2345 45 57
| |
| − | # description: Thinkpad fan controll utility
| |
| − | ### BEGIN INIT INFO
| |
| − | # Provides: $fan-control
| |
| − | ### END INIT INFO
| |
| − | | |
| − | # Source function library.
| |
| − | . /etc/init.d/functions
| |
| − | | |
| − | NAME=tp-fancontrold
| |
| − | APP=/sbin/${NAME}
| |
| − | | |
| − | [ -f ${APP} ] || exit 0
| |
| − | | |
| − | # Source config
| |
| − | # source config file; edit that file to configure this script
| |
| − | TEMP_SHIFT=0
| |
| − | LOG_SYSLOG=1
| |
| − | QUIET=1
| |
| − | if [ -e /etc/tp-fancontrol.conf ]; then
| |
| − | . /etc/tp-fancontrol.conf
| |
| − | fi
| |
| − | | |
| − | | |
| − | RETVAL=0
| |
| − | | |
| − | umask 077
| |
| − | | |
| − | start() {
| |
| − | echo -n $"Starting Thinkpad CPU fan control ... "
| |
| − | | |
| − | PARAMS="-d "
| |
| − | if [ "${TEMP_SHIFT}" != "0" ]
| |
| − | then
| |
| − | PARAMS=${PARAMS}" -s ${TEMP_SHIFT}"
| |
| − | fi
| |
| − | if [ "${LOG_SYSLOG}" = "1" ]
| |
| − | then
| |
| − | PARAMS=${PARAMS}" -l"
| |
| − | else
| |
| − | if [ "${QUIET}" = "1" ]
| |
| − | then
| |
| − | PARAMS=${PARAMS}" -q"
| |
| − | fi
| |
| − | fi
| |
| − | PARAMS=${PARAMS}
| |
| − |
| |
| − | # load ibm acpi module (requires acpi daemon first)
| |
| − | modprobe ibm_acpi experimental=1 hotkey=enable,0xffef
| |
| − |
| |
| − | daemon ${APP} ${PARAMS}
| |
| − | RETVAL=$?
| |
| − | echo
| |
| − | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/${NAME}
| |
| − | return $RETVAL
| |
| − | }
| |
| − | | |
| − | stop() {
| |
| − | echo -n $"Shutting down Thinkpad CPU fan control: "
| |
| − | killproc ${APP}
| |
| − | RETVAL=$?
| |
| − | echo
| |
| − | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${NAME}
| |
| − | return $RETVAL
| |
| − | }
| |
| − | rhstatus() {
| |
| − | status ${APP}
| |
| − | }
| |
| − | restart() {
| |
| − | stop
| |
| − | start
| |
| − | }
| |
| − | | |
| − | case "$1" in
| |
| − | start)
| |
| − | start
| |
| − | ;;
| |
| − | stop)
| |
| − | stop
| |
| − | ;;
| |
| − | status)
| |
| − | rhstatus
| |
| − | ;;
| |
| − | restart|reload)
| |
| − | restart
| |
| − | ;;
| |
| − | condrestart)
| |
| − | [ -f /var/lock/subsys/${NAME} ] && restart || :
| |
| − | ;;
| |
| − | *)
| |
| − | echo $"Usage: $0 {start|stop|status|restart|condrestart}"
| |
| − | exit 1
| |
| − | esac
| |
| − | | |
| − | exit $?
| |