diff options
Diffstat (limited to 'src/lm_sensors')
-rwxr-xr-x | src/lm_sensors/fancontrol.rc | 35 | ||||
-rwxr-xr-x | src/lm_sensors/healthd.rc | 36 | ||||
-rwxr-xr-x | src/lm_sensors/sensord.rc | 37 | ||||
-rwxr-xr-x | src/lm_sensors/sensors.rc | 119 |
4 files changed, 227 insertions, 0 deletions
diff --git a/src/lm_sensors/fancontrol.rc b/src/lm_sensors/fancontrol.rc new file mode 100755 index 0000000..8e98d06 --- /dev/null +++ b/src/lm_sensors/fancontrol.rc @@ -0,0 +1,35 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +PID=$(pidof -o %PPID -x /usr/sbin/fancontrol) +case "$1" in + start) + stat_busy "Starting fancontrol" + [ -z "$PID" ] && /usr/sbin/fancontrol -D &>/dev/null + if [ $? -gt 0 -o -n "$PID" ]; then + stat_fail + else + add_daemon fancontrol + stat_done + fi + ;; + stop) + stat_busy "Stopping fancontrol" + [ ! -z "$PID" ] && kill $PID &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon fancontrol + stat_done + fi + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/src/lm_sensors/healthd.rc b/src/lm_sensors/healthd.rc new file mode 100755 index 0000000..f50f4a6 --- /dev/null +++ b/src/lm_sensors/healthd.rc @@ -0,0 +1,36 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +PID=$(pidof -x -o %PPID /usr/sbin/healthd) +case "${1}" in + start) + stat_busy "Starting Health Daemon" + [ -z "${PID}" ] && /usr/sbin/healthd &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + echo "${PID}" > /var/run/healthd.pid + add_daemon healthd + stat_done + fi + ;; + stop) + stat_busy "Stopping Health Daemon" + [ ! -z "${PID}" ] && kill ${PID} &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon healthd + stat_done + fi + ;; + restart) + $0 stop + sleep 2 + $0 start + ;; + *) echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/src/lm_sensors/sensord.rc b/src/lm_sensors/sensord.rc new file mode 100755 index 0000000..e3ef4d2 --- /dev/null +++ b/src/lm_sensors/sensord.rc @@ -0,0 +1,37 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/conf.d/sensord + +PID=$(pidof -o %PPID /usr/sbin/sensord) +case "$1" in + start) + stat_busy "Starting sensord" + [ -z "$PID" ] && /usr/sbin/sensord ${SENSORD_ARGS} + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon sensord + stat_done + fi + ;; + stop) + stat_busy "Stopping sensord" + [ ! -z "$PID" ] && kill $PID &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon sensord + stat_done + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/src/lm_sensors/sensors.rc b/src/lm_sensors/sensors.rc new file mode 100755 index 0000000..4acde22 --- /dev/null +++ b/src/lm_sensors/sensors.rc @@ -0,0 +1,119 @@ +#!/bin/bash + +# description: sensors is used for monitoring motherboard sensor values. +# config: /etc/conf.d/lm_sensors + +# See also the lm_sensors homepage at: +# http://www2.lm-sensors.nu/~lm78/index.html + +# It uses a config file /etc/conf.d/lm_sensors that contains the modules to +# be loaded/unloaded. That file is sourced into this one. + +# The format of that file a shell script that simply defines the modules +# in order as normal shell variables with the special names: +# MODULE_1, MODULE_2, MODULE_3, etc. + +. /etc/rc.conf +. /etc/rc.d/functions + +PSENSORS=/usr/bin/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 + + # 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 "lm_sensors: kernel does not have sensors support" + stat_fail + fi + + # If sensors was not already running, unload the module... + [ -e /var/run/daemons/sensors ] || /sbin/modprobe -r i2c-proc &>/dev/null +fi + +if [ -e /etc/conf.d/lm_sensors ]; then + CONFIG=/etc/conf.d/lm_sensors +elif [ -e /etc/sysconfig/lm_sensors ]; then + # Moving config to new Arch-specific location + mv /etc/sysconfig/lm_sensors /etc/conf.d/lm_sensors + CONFIG=/etc/conf.d/lm_sensors +fi + +case "$1" in + start) + stat_busy "Starting Up Sensors" + + if [ -r "$CONFIG" ]; then + . "$CONFIG" + modules=$(grep \^MODULE_ $CONFIG | wc -l | tr -d ' ') + i=0 + while [ $i -lt $modules ] ; do + module=$(eval echo '$'MODULE_$i) + # echo starting module __${module}__ #debug + /sbin/modprobe $module &>/dev/null + i=$(expr $i + 1) + done + fi + + $PSENSORS -s + + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon sensors + stat_done + fi + ;; + + stop) + stat_busy "Shutting Down Sensors" + + if [ -r "$CONFIG" ]; then + . "$CONFIG" + modules=$(grep \^MODULE_ $CONFIG | wc -l | tr -d ' ') + i=$(expr $modules - 1) + while [ $i -ge 0 ] ; do + module=$(eval echo '$'MODULE_$i) + # echo stoping module __${module}__ #debug + /sbin/modprobe -r $module &>/dev/null + i=$(expr $i - 1) + done + fi + + if [ $WITHSYS == "0" ]; then + /sbin/modprobe -r i2c-proc &>/dev/null + fi + + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon sensors + stat_done + fi + ;; + + status) + $PSENSORS + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + + condrestart) + [ -e /var/run/daemons/sensors ] && $0 restart || : + ;; + + *) + echo "Usage: $0 {start|stop|restart|status|condrestart}" +esac +exit 0 |