Fancontrol starts manually but fails as service

6,023

I feel silly, should've investigated more. Here is the answer just incase I mess this up or anyone else has the same problem. Also, many thanks to @Fiisch for advice and pointing me in the right direction.

When starting fancontrol via #service fancontrol start or #fancontrol, the errors of /usr/sbin/fancontrol are not printed. Due to motherboard limitations, my sensors are defined as absolute paths. So I ran /usr/sbin/fancontrol. This causes the error

Configuration is too old, please run pwmconfig again

So I decided to take a look at /usr/sbin/fancontrol to see why. I found the cause at lines 302-307:

# Check for configuration change
if [ -z "$DEVPATH" -o -z "$DEVNAME" ]
then
    echo "Configuration is too old, please run pwmconfig again" >&2
    exit 1
fi

Its just a simple configuration change detector! since, I had specified the absolute paths for my sensors, not only was this not necessary, it was actually causing the error. So I just commented it out.

## Check for configuration change
#if [ -z "$DEVPATH" -o -z "$DEVNAME" ]
#then
#   echo "Configuration is too old, please run pwmconfig again" >&2
#   exit 1
#fi

That was it! fancontrol works perfectly now and starts at boot time.

Share:
6,023

Related videos on Youtube

Jason.local
Author by

Jason.local

Updated on September 18, 2022

Comments

  • Jason.local
    Jason.local over 1 year

    When fancontrol is started from the terminal it works fine

    # fancontrol
    Loading configuration from /etc/fancontrol ...
    
    Common settings:
      INTERVAL=2
    
    Settings for /sys/devices/platform/it87.656/hwmon/hwmon[[:print:]]*/device/pwm1:
      Depends on /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon[[:print:]]*/device/temp1_input
      Controls /sys/devices/platform/it87.656/hwmon/hwmon[[:print:]]*/device/fan1_input
      MINTEMP=17
      MAXTEMP=53
      MINSTART=140
      MINSTOP=50
      MINPWM=0
      MAXPWM=255
    
    Settings for /sys/devices/platform/it87.656/hwmon/hwmon[[:print:]]*/device/pwm3:
      Depends on /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon[[:print:]]*/device/temp1_input
      Controls /sys/devices/platform/it87.656/hwmon/hwmon[[:print:]]*/device/fan2_input
      MINTEMP=17
      MAXTEMP=55
      MINSTART=140
      MINSTOP=50
      MINPWM=0
      MAXPWM=255
    
    Enabling PWM on fans...
    Starting automatic fan control...
    

    However when starting fancontrol as a service (at or after boot), it fails.

    # service fancontrol start
    [ ok ] Starting fan speed regulator: fancontrol.
    # service fancontrol status
    [FAIL] fancontrol is not running ... failed!
    

    What is the difference between starting fancontrol as a service vs manually that would cause it to fail?

    Debian Wheezy Fancontrol initscript

    #! /bin/sh
    
    ### BEGIN INIT INFO
    # Provides:          fancontrol
    # Required-Start:    $remote_fs
    # Required-Stop:     $remote_fs
    # Default-Start:     2 3 4 5
    # Default-Stop:
    # Short-Description: fancontrol
    # Description:       fan speed regulator
    ### END INIT INFO
    
    . /lib/lsb/init-functions
    
    [ -f /etc/default/rcS ] && . /etc/default/rcS
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    DAEMON=/usr/sbin/fancontrol
    DESC="fan speed regulator"
    NAME="fancontrol"
    PIDFILE=/var/run/fancontrol.pid
    CONF=/etc/fancontrol
    
    test -x $DAEMON || exit 0
    
    case "$1" in
      start)
        if [ -f $CONF ] ; then
            if $DAEMON --check 1>/dev/null 2>/dev/null ; then
                log_daemon_msg "Starting $DESC" "$NAME"
                start-stop-daemon --start --quiet --background --pidfile $PIDFILE --startas $DAEMON
                log_end_msg $?
            else
                log_failure_msg "Not starting fancontrol, broken configuration file; please re-run pwmconfig."
            fi
        else
            if [ "$VERBOSE" != no ]; then
                log_warning_msg "Not starting fancontrol; run pwmconfig first."
            fi
        fi
        ;;
      stop)
        log_daemon_msg "Stopping $DESC" "$NAME"
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON
        rm -f $PIDFILE
        log_end_msg $?
        ;;
      restart)
        $0 stop
    
    • Fiisch
      Fiisch almost 10 years
      Post here the initscript (/etc/init.d/fancontrol) so we can look what is happening during the boot start. Also post what OS you use. Some quick ideas: 1) different ENV variables 2) sudo command somewhere inside the initscript && requiretty in sudo configuration
    • Jason.local
      Jason.local almost 10 years
      @Fiisch Im on Debian wheezy and ive added the fancontrol initscript.
    • Fiisch
      Fiisch almost 10 years
      Try to run start-stop-daemon --start --pidfile /var/run/fancontrol.pid --startas /usr/sbin/fancontrol from your terminal and post results. Also try the same but first set your PATH to the same as is written in the initscript. And please post the output of which fancontrol from your bash session. :) PS: Sorry for the delay. I had much work to do.