Talk:Code/tp-fancontrol-fc.init

From ThinkWiki
Revision as of 14:32, 13 February 2007 by Fikin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  1. !/bin/bash
  2. tp-fancontrol
  3. nikolay fiykov (fikin@sf.net)
  4. chkconfig: 2345 45 57
  5. description: Thinkpad fan controll utility
      1. BEGIN INIT INFO
  6. Provides: $fan-control
      1. END INIT INFO
  1. Source function library.

. /etc/init.d/functions

NAME=tp-fancontrold APP=/sbin/${NAME}

[ -f ${APP} ] || exit 0

  1. Source config
  2. 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 $?