diff --git a/prog/init/README b/prog/init/README new file mode 100644 index 00000000..f0451641 --- /dev/null +++ b/prog/init/README @@ -0,0 +1,34 @@ +This directory contains files useful for initialization +scripts, especially for RedHat. + +There are two choices, lm_sensors.init and sensord.init. +Use one or the other but not both! + +---------------- + +The script lm_sensors.init is a nice startup/shutdown script. +On RH and other RH-based systems (MDK, notably) use this sort of startup +mechanism (i.e. SVR4-based), as opposed to the everything-in-one-script +(/etc/rc or /etc/rc.local) like the BSD-based systems do. +The lm_sensors.init file should be copied to /etc/rc.d/init.d/lm_sensors. +For more information see the top of the file. +It requires the /etc/sysconfig/sensors file, which identifies +the correct modules. + +The /etc/sysconfig/lm_sensors file is only a list of modules, +as would be determined by running sensors-detect. +The lm_sensors.sysconfig file contains the MODULE_# variable definitions; +it should be modified for your setup and then +copied to /etc/sysconfig/lm_sensors. + +---------------- + +The script sensord.init also loads the modules, and then +starts the sensord daemon. See the directory ../sensord for +more information on the daemon. + +The sensord.init file should be copied to /etc/rc.d/init.d/sensord. +For more information see the top of the file. + +To configure this service one should put appropriate "alias i2c-bus-0 xxx" +and "alias i2c-sensors-chip-0 xxx" in /etc/modules.conf. diff --git a/prog/init/lm_sensors.init b/prog/init/lm_sensors.init new file mode 100755 index 00000000..d546b7b2 --- /dev/null +++ b/prog/init/lm_sensors.init @@ -0,0 +1,120 @@ +#!/bin/sh +# +# chkconfig: 2345 26 74 +# description: sensors is used for monitoring motherboard sensor values. +# config: /etc/sysconfig/sensors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# See also the lm_sensors homepage at: +# http://www2.lm-sensors.nu/~lm78/index.html + +# It uses a config file /etc/sysconfig/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. + +# 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. +[ -e /proc/sys/dev/sensors ] || exit 0 + +# If sensors was not already running, unload the module... +[ -e /var/lock/subsys/sensors ] || /sbin/modprobe -r i2c-proc &>/dev/null + +CONFIG=/etc/sysconfig/lm_sensors + +# Source function library. +. /etc/init.d/functions + +RETVAL=0 + +start() { + echo -n $"Starting up sensors: " + test -r "$CONFIG" && . "$CONFIG" + + modules=`grep \^MODULE_ $CONFIG | wc -l` + i=0 + while [ $i -lt $modules ] ; do + module=`eval echo '$'MODULE_$i` + /sbin/modprobe $module &>/dev/null + i=`expr $i + 1` + done + + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensors + echo +} + +stop() { + echo -n $"Shutting down sensors: " + test -r "$CONFIG" && . "$CONFIG" + + modules=`grep \^MODULE_ $CONFIG | wc -l` + i=$modules + while [ $i -ge 0 ] ; do + module=`eval echo '$'MODULE_$i` + /sbin/modprobe -r $module &>/dev/null + i=`expr $i - 1` + done + /sbin/modprobe -r i2c-proc &>/dev/null + + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sensors + echo +} + +dostatus() { + /usr/bin/sensors + RETVAL=$? +} + +restart() { + stop + start + RETVAL=$? +} + +condrestart() { + [ -e /var/lock/subsys/sensors ] && restart || : +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + dostatus + ;; + restart|reload) + restart + ;; + condrestart) + condrestart + ;; + *) + echo "Usage: sensors.init {start|stop|status|restart|reload|condrestart}" + exit 1 +esac + +exit $RETVAL diff --git a/prog/init/lm_sensors.sysconfig b/prog/init/lm_sensors.sysconfig new file mode 100755 index 00000000..5ff219a0 --- /dev/null +++ b/prog/init/lm_sensors.sysconfig @@ -0,0 +1,38 @@ +# This is /etc/sysconfig/lm_sensors. +# +# sensors is used for monitoring motherboard sensor values. +# +# See also the lm_sensors homepage at: +# http://www2.lm-sensors.nu/~lm78/index.html +# +# This file is used by /etc/rc.d/init.d/lm_sensors and defines the modules to be +# loaded/unloaded. This file is sourced into /etc/rc.d/init.d/lm_sensors. + +# The format of this file is a shell script that simply defines the modules +# in order as normal variables with the special names: +# MODULE_1, MODULE_2, MODULE_3, etc. + +# +# List the modules that are to be loaded for your system +# Adapted from results of running /usr/sbin/sensors-detect +# +# Mine said (I have an ASUS K7M motherboard): +# +# #----cut here---- +# # I2C adapter drivers +# modprobe i2c-matroxfb +# # modprobe unknown adapter MAVEN:fb0 on i2c-matroxfb using Bit-shift algorithm +# # modprobe unknown adapter MAVEN:fb0 on i2c-matroxfb using Bit-shift algorithm +# modprobe i2c-isa +# # I2C chip drivers +# modprobe ddcmon +# modprobe w83781d +# modprobe via686a +# #----cut here---- +# +# Here is my module list +MODULE_1=i2c-matroxfb +MODULE_2=i2c-isa +MODULE_3=ddcmon +MODULE_4=w83781d +MODULE_5=via686a