diff -ur etc.orig/rc.d/init.d/raidmon etc/rc.d/init.d/raidmon --- etc.orig/rc.d/init.d/raidmon 2007-06-21 12:45:43.000000000 -0700 +++ etc/rc.d/init.d/raidmon 2007-06-21 12:46:12.000000000 -0700 @@ -1,54 +1,46 @@ -#!/bin/sh -# -# chkconfig: 2345 20 80 +#!/sbin/runscript # description: RAIDMon is a daemon that monitors the RAID subsystem # And generates e-mail to root # processname: MegaServ. -# source function library -. /etc/rc.d/init.d/functions -case "$1" in - start) - megadevice="megadev0" - rm -f /dev/$megadevice 2>/dev/null - megamajor=`cat /proc/devices|gawk '/megadev/{print$1}' ` - mknod /dev/$megadevice c $megamajor 0 2>/dev/null - # New check : Timir: 10-31-01: Does node exist - if [ ! -c /dev/$megadevice ] - then - echo " - Character Device Node /dev/$megadevice does not exist. - Raid Monitor could not be started - " - exit 1 +depend() { + use logger + need net +} + +checkconfig() { + if [[ $( grep -v "^#" /etc/megamon.conf ) == "" ]]; then + ewarn "WARNING: /etc/megamon.conf has not been configured" fi +} - #echo -n 'Starting NetRAID Monitor:' - echo -n 'Starting RAID Monitor:' - daemon MegaCtrl -start +start() { + checkconfig + + megadevice="megadev0" + rm -f /dev/$megadevice 2>/dev/null + megamajor=`cat /proc/devices|gawk '/megadev/{print$1}' ` + mknod /dev/$megadevice c $megamajor 0 2>/dev/null + # New check : Timir: 10-31-01: Does node exist + if [ ! -c /dev/$megadevice ] ; then + eerror "Character Device Node /dev/$megadevice does not exist." + eerror "Raid Monitor could not be started" + return 1 + fi + + ebegin "Starting RAID Monitor" + start-stop-daemon --start --background --exec /usr/sbin/MegaCtrl -- -start touch /var/lock/subsys/raidmon - echo - ;; - stop) - #echo -n 'Stopping NetRAID Monitor:' - echo -n 'Stopping RAID Monitor:' - daemon MegaCtrl -stop + eend $? +} + +stop() { + ebegin "Stopping RAID Monitor" + megadevice="megadev0" - rm -f /dev/$megadevice 2>/dev/null + start-stop-daemon --stop --name MegaServ --exec /usr/sbin/MegaCtrl -- -stop + rm -f /dev/$megadevice 2>/dev/null rm -f /var/lock/subsys/raidmon 2>/dev/null - echo - ;; - restart|reload) - $0 stop - $0 start - ;; - *) - #echo "NetRAID Monitor is not Started/Stopped" - echo "RAID Monitor is not Started/Stopped" - echo "Usage: raidmon {start|stop|restart}" - exit 1 -esac - -exit 0 - + eend $? +}