mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-03 07:45:30 +00:00
modify initscript to have lsb compliant return values
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5144 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -28,31 +28,6 @@
|
|||||||
# in order as normal shell variables with the special names:
|
# in order as normal shell variables with the special names:
|
||||||
# MODULE_1, MODULE_2, MODULE_3, etc.
|
# MODULE_1, MODULE_2, MODULE_3, etc.
|
||||||
|
|
||||||
if grep -q sysfs /proc/mounts; then
|
|
||||||
WITHSYS=1
|
|
||||||
else
|
|
||||||
WITHSYS=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $WITHSYS == "0" ]; then
|
|
||||||
# If sensors isn't supported by the kernel, try loading the module...
|
|
||||||
[ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc >/dev/null 2>&1
|
|
||||||
|
|
||||||
# Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
|
|
||||||
# support for sensors.
|
|
||||||
[ -e /proc/sys/dev/sensors ] || exit 0
|
|
||||||
|
|
||||||
# If sensors was not already running, unload the module...
|
|
||||||
[ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
CONFIG=/etc/sysconfig/lm_sensors
|
|
||||||
[ -r "$CONFIG" ] || exit 0
|
|
||||||
grep '^MODULE_' $CONFIG >/dev/null 2>&1 || exit 0
|
|
||||||
|
|
||||||
# Load config file
|
|
||||||
. "$CONFIG"
|
|
||||||
|
|
||||||
PSENSORS=/usr/local/bin/sensors
|
PSENSORS=/usr/local/bin/sensors
|
||||||
|
|
||||||
if [ ! -x $PSENSORS ]; then
|
if [ ! -x $PSENSORS ]; then
|
||||||
@@ -65,7 +40,47 @@ fi
|
|||||||
RETVAL=0
|
RETVAL=0
|
||||||
prog="lm_sensors"
|
prog="lm_sensors"
|
||||||
|
|
||||||
|
# This functions checks if sensor support is compiled into the kernel, if
|
||||||
|
# sensors are configured, and loads the config file
|
||||||
|
check_sensors() {
|
||||||
|
if grep -q sysfs /proc/mounts; then
|
||||||
|
WITHSYS=1
|
||||||
|
else
|
||||||
|
WITHSYS=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $WITHSYS == "0" ]; then
|
||||||
|
# If sensors isn't supported by the kernel, try loading the module...
|
||||||
|
[ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc >/dev/null 2>&1
|
||||||
|
|
||||||
|
# Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
|
||||||
|
# support for sensors.
|
||||||
|
if ! [ -e /proc/sys/dev/sensors ]; then
|
||||||
|
echo -n "$1 $prog: kernel does not have sensors support"
|
||||||
|
echo_failure
|
||||||
|
echo
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If sensors was not already running, unload the module...
|
||||||
|
[ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CONFIG=/etc/sysconfig/lm_sensors
|
||||||
|
if ! [ -r "$CONFIG" ] || ! grep '^MODULE_' $CONFIG >/dev/null 2>&1; then
|
||||||
|
echo -n "$1 $prog: not configured, run sensors-detect"
|
||||||
|
echo_warning
|
||||||
|
echo
|
||||||
|
exit 6
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load config file
|
||||||
|
. "$CONFIG"
|
||||||
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
check_sensors "Starting"
|
||||||
|
|
||||||
echo -n "Starting $prog: loading module "
|
echo -n "Starting $prog: loading module "
|
||||||
|
|
||||||
modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
|
modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
|
||||||
@@ -89,6 +104,8 @@ start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
check_sensors "Stopping"
|
||||||
|
|
||||||
echo -n "Stopping $prog: "
|
echo -n "Stopping $prog: "
|
||||||
|
|
||||||
modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
|
modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
|
||||||
@@ -116,12 +133,14 @@ stop() {
|
|||||||
dostatus() {
|
dostatus() {
|
||||||
$PSENSORS
|
$PSENSORS
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
if [ $RETVAL -ne 0 ]; then
|
||||||
|
RETVAL=3
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
stop
|
stop
|
||||||
start
|
start
|
||||||
RETVAL=$?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
condrestart() {
|
condrestart() {
|
||||||
@@ -147,7 +166,7 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop|status|restart|reload|condrestart}"
|
echo "Usage: $0 {start|stop|status|restart|reload|condrestart}"
|
||||||
exit 1
|
exit 3
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
|
Reference in New Issue
Block a user