Comment 5 for bug 576602

Revision history for this message
Vk (flo74970) wrote :

here is an enhanced script (no need to stop daemon to be sure that it works)

************************************************
#!/bin/sh
#
# Fancontrol start script.
#

set -e

# Defaults
DAEMON=/usr/sbin/fancontrol
PIDFILE=/var/run/fancontrol.pid
PATH=/sbin:/bin:/usr/sbin:/usr/bin

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
        start)
  cp /etc/fancontrol1 /etc/fancontrol
                log_begin_msg "Starting fancontrol config 1..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

  cp /etc/fancontrol2 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 2..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

  cp /etc/fancontrol3 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 3..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

  cp /etc/fancontrol4 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 4..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

                ;;
        stop)
                log_begin_msg "Stopping fancontrol daemon..."
                start-stop-daemon --stop -o -q -p $PIDFILE
                log_end_msg $?
                rm -f $PIDFILE
  ;;
        force-reload|restart)
                sh $0 stop
                sh $0 start
                ;;
        *)
                log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload}"
                log_success_msg " start - starts system-wide fancontrol service"
                log_success_msg " stop - stops system-wide fancontrol service"
                log_success_msg " restart, force-reload - starts a new system-wide fancontrol service"
                exit 1
                ;;
esac

exit 0
********************************************************