Difference between revisions of "Code/tp-fancontrol.init"

From ThinkWiki
Jump to: navigation, search
m (needs quotes to avoid trying to execute "-s")
m (Undo corruption)
 
(One intermediate revision by one other user not shown)
(No difference)

Latest revision as of 05:53, 12 April 2007

  1. ! /bin/sh
      1. BEGIN INIT INFO
  2. Provides: tp-fancontrol
  3. Default-Start: 2 3 4 5
  4. Default-Stop: S 0 1 6
      1. END INIT INFO
  5. Copyright (c) 2006 Ronald Aigner <ra3@os.inf.tu-dresden.de>

set -e

DAEMON=/usr/bin/tp-fancontrol NAME=tp-fancontrol DAEMONUSER=root PIDDIR=/var/run PIDFILE=$PIDDIR/tp-fancontrol.pid DESC="Thinkpad CPU fan control"

test -x $DAEMON || exit 0

  1. 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

start_it() {

 PARAMS=-d
 if [ -e $PIDFILE ]; then
   echo "$DESC already running. Stop first."
   exit 1
 fi
 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" -p $PIDFILE"
 echo -n "Starting $DESC: $NAME ... "
 $DAEMON $PARAMS
 if [ "$?" = "0" ]; then
   echo "Success."
 else
   echo "Error while starting: $?"
 fi

}

stop_it() {

 if [ -e $PIDFILE ]; then
   echo -n "Stopping $DESC ... "
   $DAEMON -k
   if [ "$?" = "0" ]; then
     echo "Success."
   else
     echo "Error while stopping: $?"
   fi
 else
   echo "$DESC not running."
 fi

}

restart_it() {

 if [ -e $PIDFILE ]; then
   stop_it
   sleep 2
 fi
 start_it

}

case "$1" in

 start)
   start_it
 ;;
 stop)
   stop_it
 ;;
 reload|force-reload|restart)
   restart_it
 ;;
 *)
   echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload}" >&2
   exit 1
 ;;

esac

exit 0