summaryrefslogtreecommitdiff
path: root/scripts/ipmiutil_wdt
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/ipmiutil_wdt')
-rwxr-xr-xscripts/ipmiutil_wdt146
1 files changed, 146 insertions, 0 deletions
diff --git a/scripts/ipmiutil_wdt b/scripts/ipmiutil_wdt
new file mode 100755
index 0000000..6c2bd73
--- /dev/null
+++ b/scripts/ipmiutil_wdt
@@ -0,0 +1,146 @@
+#! /bin/sh
+#
+# wdt Enable & reset the IPMI watchdog timer via cron
+#
+# chkconfig: - 91 59
+# description: wdt is a utility from ipmiutil.sf.net to configure the \
+# IPMI watchdog timer.
+#
+# It enables watchdog for 90 second timeout, reset every 1 min (60 sec).
+# It uses the cron daemon which reads files from /etc/cron.d
+# Note that the $crond_sh variable is different for RedHat & SuSE.
+#
+### BEGIN INIT INFO
+# Provides: ipmiutil_wdt
+# Required-Start: $local_fs $remote_fs $syslog
+# Required-Stop: $local_fs $remote_fs $syslog
+# Default-Start: 3 4 5 3 4 5
+# Default-Stop: 0 1 2 6 0 1 2 6
+# Short-Description: ipmiutil watchdog timer init script
+# Description: Init script to enable and reset ipmiutil watchdog timer via cron
+### END INIT INFO
+#
+#if [ -f /etc/init.d/functions ]; then
+# Source function library.
+#. /etc/init.d/functions
+#fi
+
+name=ipmiutil_wdt
+prog="/usr/bin/ipmiutil wdt"
+wdtcron=/etc/cron.d/wdt
+LOCKFILE=/var/lock/subsys/$name
+wdtlog=/var/log/$name
+#tmpcron=/tmp/wdtcron.$$
+# tmpcron2=/tmp/wdtcron2.$$
+
+start() {
+ echo -n $"Starting $prog: "
+ echo
+ # do not start if in driverless mode
+ ipmiutil cmd -k |grep "driverless" >/dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ driverok=0
+ else
+ driverok=1
+ fi
+ if [ $driverok -eq 0 ]
+ then
+ echo "No ipmi driver loaded, aborting."
+ RETVAL=1
+ else
+ # configure the watchdog for a 90 second timeout
+ $prog -e -t 90 >$wdtlog
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ]
+ then
+ # restart the watchdog every 60 seconds via crontab (skip)
+ # cat - <<%%% >$tmpcron
+#* * * * * $prog -r
+#%%%
+ # crontab $tmpcron
+ # RETVAL=$?
+ # restart the watchdog every 60 seconds via /etc/cron.d
+ cat - <<%%% >$wdtcron
+* * * * * root $prog -r
+%%%
+ # make crond re-read the /etc/cron.d
+ $crond_sh restart >>$wdtlog
+ touch $LOCKFILE
+ fi
+ fi
+ echo
+ return $RETVAL
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ echo
+ # first disable the watchdog
+ $prog -d >>$wdtlog
+ RETVAL=$?
+ # now remove the wdt cron job
+ # crontab -l >$tmpcron
+ # grep -v $prog $tmpcron |grep -v "^#" >$tmpcron2
+ # crontab $tmpcron2
+ rm -f $wdtcron
+ # make crond re-read the /etc/cron.d
+ $crond_sh restart >>$wdtlog
+ rm -f ${LOCKFILE}
+ echo
+ return $RETVAL
+}
+
+restart() {
+ stop
+ start
+}
+
+get_status() {
+ $prog
+ if [ -f ${LOCKFILE} ]; then
+ if [ -f $wdtcron ]; then
+ echo "$name is running..."
+ retval=0
+ else
+ echo "$name is not running but ${LOCKFILE} exists"
+ retval=1
+ fi
+ else
+ echo "$name is stopped"
+ retval=3
+ fi
+ return $retval
+}
+
+# Begin mainline script here
+if [ -f /etc/redhat-release ]
+then
+ crond_sh=/etc/init.d/crond
+else
+ # SuSE, MontaVista, etc.
+ crond_sh=/etc/init.d/cron
+fi
+if [ ! -d /var/lock/subsys ]; then
+ LOCKFILE=/var/run/$name.pid
+fi
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ get_status
+ ;;
+ restart)
+ restart
+ ;;
+ reload)
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|reload}"
+ exit 1
+esac