Skip to contentSkip to conversation

fancontrol.init

PATCH New Dean Takemori 2 participants 2 messages Feb 6, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 11/11 fancontrol.init

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úncontrol
+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
#1 lore raw

PATCH 11/11 fancontrol.init

Hi Dean,

Please start a new thread when starting a new topic.

Quoted 3 lines · Dean Takemori

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.

Please list the changes between the old and the new version. Are these bug fixes? New features? The diff is very large (compared to the size of the script) and it looks much like a complete rewrite to me, while we want incremental changes.

Also there is a lot of noise due to reindentation. This makes the review very difficult. Please separate the coding style cleanups from the functional changes.

If there are any bug fixes in there, please extract them and send a minimal patch for 2.10.0. We are not going to merge a complete rewrite right before a release.

Thanks,
--
Jean Delvare