Changeset 5142

Show
Ignore:
Timestamp:
03/12/08 21:49:40 (8 months ago)
Author:
jwrdegoede
Message:

modify initscript to have lsb compliant return values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/trunk/prog/init/lm_sensors.init

    r5141 r5142  
    2929#    MODULE_1, MODULE_2, MODULE_3, etc. 
    3030 
    31 if grep -q sysfs /proc/mounts; then 
    32         WITHSYS=1 
    33 else 
    34         WITHSYS=0 
    35 fi 
    36  
    37 if [ $WITHSYS == "0" ]; then 
    38         # If sensors isn't supported by the kernel, try loading the module... 
    39         [ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc >/dev/null 2>&1 
    40  
    41         # Don't bother if /proc/sensors still doesn't exist, kernel doesn't have 
    42         # support for sensors. 
    43         [ -e /proc/sys/dev/sensors ] || exit 0 
    44  
    45         # If sensors was not already running, unload the module... 
    46         [ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1 
    47 fi 
    48  
    49 CONFIG=/etc/sysconfig/lm_sensors 
    50 [ -r "$CONFIG" ] || exit 0 
    51 grep '^MODULE_' $CONFIG >/dev/null 2>&1 || exit 0 
    52  
    53 # Load config file 
    54 . "$CONFIG" 
    55  
    5631PSENSORS=/usr/local/bin/sensors 
    5732 
     
    6641prog="lm_sensors" 
    6742 
     43# This functions checks if sensor support is compiled into the kernel, if 
     44# sensors are configured, and loads the config file 
     45check_sensors() { 
     46        if grep -q sysfs /proc/mounts; then 
     47                WITHSYS=1 
     48        else 
     49                WITHSYS=0 
     50        fi 
     51 
     52        if [ $WITHSYS == "0" ]; then 
     53                # If sensors isn't supported by the kernel, try loading the module... 
     54                [ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc >/dev/null 2>&1 
     55 
     56                # Don't bother if /proc/sensors still doesn't exist, kernel doesn't have 
     57                # support for sensors. 
     58                if ! [ -e /proc/sys/dev/sensors ]; then 
     59                        echo -n "$1 $prog: kernel does not have sensors support" 
     60                        echo_failure 
     61                        echo 
     62                        exit 5 
     63                fi 
     64 
     65                # If sensors was not already running, unload the module... 
     66                [ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1 
     67        fi 
     68 
     69        CONFIG=/etc/sysconfig/lm_sensors 
     70        if ! [ -r "$CONFIG" ] || ! grep '^MODULE_' $CONFIG >/dev/null 2>&1; then 
     71                echo -n "$1 $prog: not configured, run sensors-detect" 
     72                echo_warning 
     73                echo 
     74                exit 6 
     75        fi 
     76 
     77        # Load config file 
     78        . "$CONFIG" 
     79} 
     80 
    6881start() { 
     82        check_sensors "Starting" 
     83 
    6984        echo -n "Starting $prog: loading module " 
    7085 
     
    90105 
    91106stop() { 
     107        check_sensors "Stopping" 
     108 
    92109        echo -n "Stopping $prog: " 
    93110 
     
    117134        $PSENSORS 
    118135        RETVAL=$? 
     136        if [ $RETVAL -ne 0 ]; then 
     137                RETVAL=3 
     138        fi 
    119139} 
    120140 
     
    122142        stop 
    123143        start 
    124         RETVAL=$? 
    125144} 
    126145 
     
    148167  *) 
    149168        echo "Usage: $0 {start|stop|status|restart|reload|condrestart}" 
    150         exit 1 
     169        exit 3 
    151170esac 
    152171