[PATCH 11/11] fancontrol.init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Submitted for the upcoming 2.10.0 release:  To upgrade the  
fancontrol.init script
to the version I've been using for a while now on an FC1 system.


--- lm_sensors-2.9.2/prog/init/fancontrol.init	2004-06-23  
09:36:49.000000000 -1000
+++ Working/etc/init.d/fancontrol	2006-02-05 19:58:03.000000000 -1000
@@ -1,101 +1,103 @@
#!/bin/sh
#
-# $Id: fancontrol.init,v 1.1 2004/06/23 19:36:49 khali Exp $
+# $Id: fancontrol,v 1.17 2006/02/06 05:58:03 dean Exp $
+#
+# System V style startup script for RedHat-like systems.
+#
#
# fancontrol
#
-# chkconfig: 2345 90 01
-# description: start/stop fancontrol
+# chkconfig: 2345 60 01
+# description: Optional part of LM_Sensors.  On certain motherboards
+#              with supported chipsets, fancontrol can control the
+#              speed of System/CPU fans in response to temperature
+#              sensor output.
# pidfile: /var/run/fancontrol.pid
#
-
-PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
-export PATH
+# Usage /etc/init.d/fancontrol {start|stop|restart|status|condrestart}
# Source function library.
. /etc/rc.d/init.d/functions
-FANCONTROL="/usr/local/sbin/fancontrol"
-PIDFILE="/var/run/fancontrol.pid"
+PATH=/bin:/sbin
+export PATH
+
+prog=fancontrol
+exe=/usr/local/sbin/$prog
+PIDFILE=/var/run/$prog.pid
+LOCKFILE=/var/lock/subsys/$prog
-RETVAL=0
start()
{
-   echo -n "Starting fancontrol daemon"
-   daemon $FANCONTROL -d
-   RETVAL=$?
-   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fancontrol
-   echo
+	echo -n "Starting $prog daemon: "
+	if [ -f $LOCKFILE ] ; then
+		echo -n "Lock file exists"
+		echo_failure
+		echo
+		exit -1;
+	fi
+	daemon $exe -d
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch $LOCKFILE && echo_success
+	echo
+	return $RETVAL
}
stop()
{
-   echo -n "Stopping fancontrol daemon"
-   killproc $FANCONTROL
-   RETVAL=$?
-   rm -f $PIDFILE
-   rm -f /var/lock/subsys/fancontrol
-   echo
-}
-
-status()
-{
-   if [ -f $PIDFILE ] ; then
-     pid=`cat $PIDFILE`
-   else
-     echo -n "$FANCONTROL does not appear to be running"
-     echo
-     exit
-   fi
-
-   if [ -n "$pid" ] ; then
-     ps -p $pid > /dev/null
-     if [ $? ] ; then
-       echo -n "$FANCONTROL appears to be running"
-     else
-       echo -n "$FANCONTROL does not appear to be running"
-     fi
-     echo
-   fi
+	echo -n "Stopping $prog daemon: "
+	killproc $exe
+	RETVAL=$?
+	echo
+	[ $RETVAL = 0 ] && rm -f $LOCKFILE $PIDFILE
+	return $RETVAL
}
condrestart()
{
-   [ -e /var/lock/subsys/fancontrol ] && restart || :
+	[ -e $LOCKFILE ] && restart || :
}
-if [ ! -x $FANCONTROL ] ; then
-   echo "Cannot run $FANCONTROL"
-   exit 0
+
+
+if [ ! -x $exe ] ; then
+	echo -n "No such service $prog: "
+	if [ ! -f $exe ] ; then
+		echo -n "No such executable $exe"
+	else
+		echo -n "Insufficient permissions for $exe"
+	fi
+	echo_failure
+	exit -1
fi
case "$1" in
-   start)
-     start
-     ;;
-
-   stop)
-     stop
-     ;;
-
-   status)
-     status
-     ;;
-
-   restart)
-     stop
-     start
-     ;;
-
-   condrestart)
-     condrestart
-     ;;
-
-   *)
-     echo "Usage: /etc/init.d/fancontrol
-{start|stop|status|restart|condrestart}"
-     RETVAL=1
+start)
+	start
+	;;
+
+stop)
+	stop
+	;;
+
+restart)
+	stop
+	start
+	;;
+
+status)
+	status $exe
+	RETVAL=$?
+	;;
+
+condrestart)
+	condrestart
+	;;
+
+*)
+	echo "Usage: /etc/init.d/$prog {start|stop|status|restart| 
condrestart}"
+	exit -1
esac
exit $RETVAL





[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux