diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-06 18:04:32 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-06 18:04:32 +0200 |
commit | a7f89980e5b3f4b9a74c70dbc5ffe8aabd28be28 (patch) | |
tree | 41c4deec1fdfbafd7821b4ca7a9772ac0abd92f5 /scripts/ipmi_info |
Imported Upstream version 2.9.3upstream/2.9.3
Diffstat (limited to 'scripts/ipmi_info')
-rwxr-xr-x | scripts/ipmi_info | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/scripts/ipmi_info b/scripts/ipmi_info new file mode 100755 index 0000000..b3b3f9a --- /dev/null +++ b/scripts/ipmi_info @@ -0,0 +1,124 @@ +#! /bin/sh +# +# ipmi_info +# +# chkconfig: 345 91 07 +# description: ipmi_info saves the OS info (hostname, OS release) into +# the IPMI System Info variables, if supported. +# It does nothing if IPMI System Info is not supported. +# +### BEGIN INIT INFO +# Provides: ipmi_info +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: +# Default-Stop: +# Short-Description: ipmi_info saves OS info to the IPMI system info +# Description: ipmi_info saves OS info to the IPMI system info +### END INIT INFO + +name=ipmi_info +iuprog=/usr/bin/ipmiutil +tmp=/tmp/ipmi_info.tmp + +getosver() { + if [ -f /etc/os-release ]; then + . /etc/os-release + echo "${NAME} ${VERSION} kernel ${KERNEL_VERSION}" + elif [ -f /etc/redhat-release ]; then + cat /etc/redhat-release |head -n1 + elif [ -f /etc/SuSE-release ]; then + cat /etc/SuSE-release |head -n1 + elif [ -f /etc/mvl-release ]; then + sver=`grep Monta /etc/mvl-release |awk '{ print $4 }' |cut -f1 -d'.'` + echo "Monta Vista Linux version $sver" + elif [ -f /etc/debian_version ]; then + sver=`grep Debian /etc/issue |awk '{ print $3 }'` + echo "Debian Linux version $sver" + else + sver=`uname -r` + styp=`uname -s` + echo "$styp $sver" + fi +} + +start() +{ + echo -n $"Starting $name: " + echo + retval=0 + PID=0 + + ${iuprog} health -i >$tmp 2>&1 + if [ $? -eq 0 ]; then + name=`hostname` + os=`getosver` + echo "setting name=$name, os=$os ..." >>$tmp + ${iuprog} health -n "$name" >>$tmp 2>&1 + ${iuprog} health -o "$os" >>$tmp 2>&1 + else + # IPMI System Info is not supported. + retval=0 + fi + echo + return $retval +} + +stop() +{ + echo -n $"Stopping $name: " + echo + retval=0 + echo + return $retval +} + +restart() +{ + stop + start +} + +rh_status() { + echo "$name is stopped" + retval=3 + return $retval +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + +case "$1" in + start) + rh_status_q && exit 0 + start + ;; + stop) + rh_status_q || exit 0 + stop + ;; + status) + rh_status + ;; + restart) + restart + ;; + reload) + rh_status_q || exit 7 + restart + ;; + force_reload) + restart + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac + +exit $? + |