2005-06-27 14:57:04 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#############################################################################
|
|
|
|
#
|
2012-05-09 12:19:03 +00:00
|
|
|
# ipmi: OpenIPMI Driver helper script
|
2005-06-27 14:57:04 +00:00
|
|
|
#
|
2012-05-09 12:19:03 +00:00
|
|
|
# Authors: Jan Safranek <jsafrane@redhat.com>
|
2005-06-27 14:57:04 +00:00
|
|
|
#
|
2012-05-09 12:19:03 +00:00
|
|
|
# Based on IPMI init script by:
|
|
|
|
# Matt Domsch <Matt_Domsch@dell.com>
|
|
|
|
# Chris Poblete <Chris_Poblete@dell.com>
|
2005-09-01 17:04:50 +00:00
|
|
|
#
|
2005-09-08 11:25:11 +00:00
|
|
|
# Status return code bits
|
|
|
|
# no bits set = no errors
|
|
|
|
# bit 0 set = minimum modules aren't loaded
|
|
|
|
# bit 1 set = requested feature module isn't loaded
|
|
|
|
# bit 2 set = /dev/ipmi0 (or /dev/imb if using that instead) doesn't exist
|
|
|
|
# bit 3 set = /dev/watchdog doesn't exist
|
|
|
|
# bit 4 set = lockfile doesn't exist
|
|
|
|
# bit 5 set = modules are loaded even when asked to be unloaded
|
2005-09-01 17:04:50 +00:00
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
CONFIGFILE=/etc/sysconfig/ipmi
|
2005-06-27 14:57:04 +00:00
|
|
|
# source config info
|
2005-09-08 11:25:11 +00:00
|
|
|
[ -r ${CONFIGFILE} ] && . ${CONFIGFILE}
|
2005-06-27 14:57:04 +00:00
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# GLOBALS
|
|
|
|
#############################################################################
|
|
|
|
MODULE_NAME="ipmi"
|
|
|
|
INTF_NUM=0
|
|
|
|
|
|
|
|
IPMI_SMB_MODULE_NAME="ipmi_smb"
|
|
|
|
IPMI_SI_MODULE_NAME="ipmi_si"
|
|
|
|
kernel=`uname -r | cut -d. -f1-2`
|
|
|
|
if [ "${kernel}" == "2.4" ]; then
|
|
|
|
IPMI_SMB_MODULE_NAME="ipmi_smb_intf"
|
|
|
|
IPMI_SI_MODULE_NAME="ipmi_si_drv"
|
|
|
|
fi
|
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
MODULES_INTERFACES=""
|
2005-11-23 11:21:46 +00:00
|
|
|
[ "${DEV_IPMI}" = "yes" ] && MODULES_INTERFACES="${MODULES_INTERFACES} ipmi_devintf"
|
|
|
|
[ "${IPMI_IMB}" = "yes" ] && MODULES_INTERFACES="${MODULES_INTERFACES} ipmi_imb"
|
2005-09-08 11:25:11 +00:00
|
|
|
|
|
|
|
MODULES_FEATURES=""
|
2005-11-23 11:21:46 +00:00
|
|
|
[ "${IPMI_WATCHDOG}" = "yes" ] && MODULES_FEATURES="${MODULES_FEATURES} ipmi_watchdog"
|
|
|
|
[ "${IPMI_POWEROFF}" = "yes" ] && MODULES_FEATURES="${MODULES_FEATURES} ipmi_poweroff"
|
2005-09-08 11:25:11 +00:00
|
|
|
|
|
|
|
MODULES_HW=""
|
2005-11-23 11:21:46 +00:00
|
|
|
[ "${IPMI_SI}" = "yes" ] && MODULES_HW="${MODULES_HW} ${IPMI_SI_MODULE_NAME}"
|
|
|
|
[ "${IPMI_SMB}" = "yes" ] && MODULES_HW="${MODULES_HW} ${IPMI_SMB_MODULE_NAME}"
|
2005-09-08 11:25:11 +00:00
|
|
|
|
2005-07-04 12:50:39 +00:00
|
|
|
MODULES_BASE="ipmi_msghandler"
|
|
|
|
MODULES="${MODULES_INTERFACES} ${MODULES_FEATURES} ${MODULES_HW} ${MODULES_BASE}"
|
2005-06-27 14:57:04 +00:00
|
|
|
|
|
|
|
RETVAL=0
|
|
|
|
LOCKFILE=/var/lock/subsys/ipmi
|
2008-12-10 13:56:38 +00:00
|
|
|
DEV_IPMI_TIMEOUT=150
|
2005-09-08 11:25:11 +00:00
|
|
|
|
2006-08-01 11:34:45 +00:00
|
|
|
UDEV_EXISTS=0
|
|
|
|
if [ -e /sbin/udev -o -e /sbin/udevd ]; then
|
|
|
|
UDEV_EXISTS=1
|
|
|
|
fi
|
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
#############################################################################
|
|
|
|
# NOTES:
|
|
|
|
# * /dev/ipmi0 is unconditionally deleted here on ipmi_devintf unload,
|
|
|
|
# because SLES9 and RHEL4 kernels don't send a message for udev to delete
|
|
|
|
# it for us.
|
|
|
|
#
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
modules_loaded_verbose()
|
|
|
|
{
|
|
|
|
OnePlusLoaded=0
|
|
|
|
OnePlusUnloaded=0
|
|
|
|
for m in $@; do
|
|
|
|
if /sbin/lsmod | grep $m >/dev/null 2>&1 ; then
|
|
|
|
echo "$m module loaded."
|
|
|
|
OnePlusLoaded=1
|
|
|
|
else
|
|
|
|
echo "$m module not loaded."
|
|
|
|
OnePlusUnloaded=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
modules_loaded()
|
|
|
|
{
|
|
|
|
OnePlusLoaded=0
|
|
|
|
OnePlusUnloaded=0
|
|
|
|
for m in $@; do
|
|
|
|
if /sbin/lsmod | grep $m >/dev/null 2>&1 ; then
|
|
|
|
OnePlusLoaded=1
|
|
|
|
else
|
|
|
|
OnePlusUnloaded=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
device_node_exists ()
|
|
|
|
{
|
|
|
|
if [ -e "$1" ]; then
|
|
|
|
echo "$1 exists."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
echo "$1 does not exist."
|
|
|
|
return 0
|
|
|
|
}
|
2005-06-27 14:57:04 +00:00
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
minimum_modules_loaded()
|
|
|
|
{
|
|
|
|
rc_base=1
|
|
|
|
rc_hw=1
|
|
|
|
modules_loaded_verbose "${MODULES_BASE}"
|
|
|
|
[ ${OnePlusLoaded} -eq 0 ] && rc_base=0
|
|
|
|
|
|
|
|
modules_loaded_verbose "${MODULES_HW}"
|
|
|
|
[ ${OnePlusLoaded} -eq 0 ] && rc_hw=0
|
|
|
|
|
|
|
|
return $((rc_base && rc_hw))
|
|
|
|
}
|
2005-07-04 12:50:39 +00:00
|
|
|
|
2005-06-27 14:57:04 +00:00
|
|
|
#############################################################################
|
2005-09-08 11:25:11 +00:00
|
|
|
|
2005-07-04 12:50:39 +00:00
|
|
|
load_si()
|
|
|
|
{
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_SI}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe ${IPMI_SI_MODULE_NAME} > /dev/null 2>&1
|
|
|
|
modules_loaded ${IPMI_SI_MODULE_NAME}
|
|
|
|
[ ${OnePlusLoaded} -ne 1 ] && RETVAL=$((RETVAL | 1))
|
2005-09-01 17:04:50 +00:00
|
|
|
fi
|
2005-07-04 12:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_smb()
|
|
|
|
{
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_SMB}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe ${IPMI_SMB_MODULE_NAME} > /dev/null 2>&1
|
|
|
|
modules_loaded ${IPMI_SMB_MODULE_NAME}
|
|
|
|
[ ${OnePlusLoaded} -ne 1 ] && RETVAL=$((RETVAL | 1))
|
2005-09-01 17:04:50 +00:00
|
|
|
fi
|
2005-07-04 12:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_hw_modules()
|
|
|
|
{
|
2005-09-01 17:04:50 +00:00
|
|
|
load_si
|
|
|
|
load_smb
|
2005-07-04 12:50:39 +00:00
|
|
|
}
|
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
start_watchdog_common()
|
2005-06-27 14:57:04 +00:00
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
load_hw_modules
|
|
|
|
modprobe ipmi_watchdog ${IPMI_WATCHDOG_OPTIONS} > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_watchdog
|
|
|
|
[ ${OnePlusUnloaded} -ne 0 ] &&
|
|
|
|
RETVAL=$((RETVAL | 2)) &&
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Watchdog startup failed: cannot load ipmi_watchdog module" &&
|
2005-09-08 11:25:11 +00:00
|
|
|
return
|
2006-08-01 11:34:45 +00:00
|
|
|
if [ ${UDEV_EXISTS} -eq 0 -a ! -e /dev/watchdog ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
mknod -m 0600 /dev/watchdog c 10 130
|
|
|
|
[ $? -ne 0 ] &&
|
|
|
|
RETVAL=$((RETVAL | 8)) &&
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Watchdog startup failed: cannot create /dev/watchdog" &&
|
2005-09-08 11:25:11 +00:00
|
|
|
return
|
2005-07-04 12:50:39 +00:00
|
|
|
fi
|
2005-09-08 11:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_watchdog_quiet()
|
|
|
|
{
|
2005-11-23 11:21:46 +00:00
|
|
|
[ "${IPMI_WATCHDOG}" != "yes" ] &&
|
2005-09-08 11:25:11 +00:00
|
|
|
return
|
|
|
|
start_watchdog_common
|
|
|
|
}
|
|
|
|
|
|
|
|
start_watchdog()
|
|
|
|
{
|
2005-11-23 11:21:46 +00:00
|
|
|
[ "${IPMI_WATCHDOG}" != "yes" ] &&
|
2005-09-08 11:25:11 +00:00
|
|
|
RETVAL=$((RETVAL | 2)) &&
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Watchdog not configured" &&
|
2005-09-08 11:25:11 +00:00
|
|
|
return
|
|
|
|
start_watchdog_common
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_watchdog()
|
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe -q -r ipmi_watchdog > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_watchdog
|
|
|
|
if [ ${OnePlusLoaded} -ne 0 ]; then
|
|
|
|
RETVAL=$((RETVAL | 32))
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Watchog shutdown failed: cannot unload ipmi_watchdog module"
|
2005-09-08 11:25:11 +00:00
|
|
|
else
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_WATCHDOG}" = "yes" ]; then
|
2006-08-01 11:34:45 +00:00
|
|
|
[ ${UDEV_EXISTS} -eq 0 ] && rm -f /dev/watchdog
|
2005-09-08 11:25:11 +00:00
|
|
|
fi
|
|
|
|
fi
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
stop_watchdog_quiet()
|
2005-06-27 14:57:04 +00:00
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe -q -r ipmi_watchdog > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_watchdog
|
|
|
|
if [ ${OnePlusLoaded} -ne 0 ]; then
|
|
|
|
RETVAL=$((RETVAL | 32))
|
|
|
|
else
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_WATCHDOG}" = "yes" ]; then
|
2006-08-01 11:34:45 +00:00
|
|
|
[ ${UDEV_EXISTS} -eq 0 ] && rm -f /dev/watchdog
|
2005-09-08 11:25:11 +00:00
|
|
|
fi
|
2005-09-01 17:04:50 +00:00
|
|
|
fi
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
start_powercontrol_common()
|
|
|
|
{
|
|
|
|
local poweroff_opts=""
|
|
|
|
load_hw_modules
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_POWERCYCLE}" == "yes" ]; then
|
2005-10-11 12:43:00 +00:00
|
|
|
modinfo ipmi_poweroff 2>/dev/null | grep poweroff_control > /dev/null 2>&1 && \
|
|
|
|
poweroff_opts="poweroff_control=2"
|
|
|
|
modinfo ipmi_poweroff 2>/dev/null | grep poweroff_powercycle > /dev/null 2>&1 && \
|
|
|
|
poweroff_opts="poweroff_powercycle=1"
|
|
|
|
fi
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe ipmi_poweroff "${poweroff_opts}" > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_poweroff
|
|
|
|
[ ${OnePlusUnloaded} -ne 0 ] &&
|
|
|
|
RETVAL=$((RETVAL | 2)) &&
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Powercontroll startup failed: cannot load ipmi_poweroff module" &&
|
2005-09-08 11:25:11 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
start_powercontrol_quiet()
|
|
|
|
{
|
2005-11-23 11:21:46 +00:00
|
|
|
[ "${IPMI_POWEROFF}" != "yes" ] &&
|
2005-09-08 11:25:11 +00:00
|
|
|
return
|
|
|
|
start_powercontrol_common
|
|
|
|
}
|
|
|
|
|
|
|
|
start_powercontrol()
|
|
|
|
{
|
2005-11-23 11:21:46 +00:00
|
|
|
[ "${IPMI_POWEROFF}" != "yes" ] &&
|
2005-09-08 11:25:11 +00:00
|
|
|
RETVAL=$((RETVAL | 2)) &&
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Powercontroll not configured" &&
|
2005-09-08 11:25:11 +00:00
|
|
|
return
|
|
|
|
start_powercontrol_common
|
|
|
|
}
|
|
|
|
|
2005-06-27 14:57:04 +00:00
|
|
|
stop_powercontrol()
|
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe -q -r ipmi_poweroff > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_poweroff
|
|
|
|
if [ ${OnePlusLoaded} -ne 0 ]; then
|
|
|
|
RETVAL=$((RETVAL | 32))
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Powercontroll shutdown failed: cannot unload ipmi_poweroff module"
|
2005-09-08 11:25:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_powercontrol_quiet()
|
|
|
|
{
|
|
|
|
modprobe -q -r ipmi_poweroff > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_poweroff
|
|
|
|
[ ${OnePlusLoaded} -ne 0 ] && RETVAL=$((RETVAL | 32))
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
2005-07-04 12:50:39 +00:00
|
|
|
#############################################################################
|
|
|
|
unload_all_ipmi_modules()
|
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
stop_watchdog_quiet
|
|
|
|
stop_powercontrol_quiet
|
2005-09-01 17:04:50 +00:00
|
|
|
for m in ${MODULES}; do
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe -q -r ${m} > /dev/null 2>&1
|
2005-09-01 17:04:50 +00:00
|
|
|
done
|
2005-11-23 11:21:46 +00:00
|
|
|
# delete interface node ONLY if ipmi_devintf is unloaded
|
|
|
|
[ `lsmod | grep -c "ipmi_devintf"` -eq 0 ] &&
|
|
|
|
rm -f "/dev/ipmi${INTF_NUM}"
|
2005-07-04 12:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unload_ipmi_modules_leave_features()
|
|
|
|
{
|
2005-09-01 17:04:50 +00:00
|
|
|
for m in ${MODULES_INTERFACES}; do
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe -q -r ${m} > /dev/null 2>&1
|
2005-07-04 12:50:39 +00:00
|
|
|
done
|
2005-11-23 11:21:46 +00:00
|
|
|
# delete interface node ONLY if ipmi_devintf is unloaded
|
|
|
|
[ `lsmod | grep -c "ipmi_devintf"` -eq 0 ] &&
|
|
|
|
rm -f "/dev/ipmi${INTF_NUM}"
|
2005-10-11 12:43:00 +00:00
|
|
|
lsmod | egrep -q "ipmi_(poweroff|watchdog)" > /dev/null 2>&1
|
2005-09-01 17:04:50 +00:00
|
|
|
if [ "$?" -ne "0" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
stop_watchdog_quiet
|
|
|
|
stop_powercontrol_quiet
|
2005-09-01 17:04:50 +00:00
|
|
|
for m in ${MODULES}; do
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe -q -r ${m} > /dev/null 2>&1
|
2005-09-01 17:04:50 +00:00
|
|
|
done
|
|
|
|
fi
|
2005-07-04 12:50:39 +00:00
|
|
|
}
|
|
|
|
|
2005-06-27 14:57:04 +00:00
|
|
|
#############################################################################
|
|
|
|
load_ipmi_modules ()
|
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
local locdelay
|
|
|
|
modprobe ipmi_msghandler > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_msghandler
|
|
|
|
[ ${OnePlusLoaded} -ne 1 ] && unload_all_ipmi_modules && RETVAL=$((RETVAL | 1)) && return
|
2005-07-04 12:50:39 +00:00
|
|
|
load_hw_modules
|
2005-09-08 11:25:11 +00:00
|
|
|
[ $((RETVAL & 1)) -eq 1 ] && unload_all_ipmi_modules && RETVAL=$((RETVAL | 1)) && return
|
2005-06-27 14:57:04 +00:00
|
|
|
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${DEV_IPMI}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe ipmi_devintf > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_devintf
|
|
|
|
RETVAL=$((RETVAL & ~2))
|
|
|
|
[ ${OnePlusLoaded} -eq 0 ] && RETVAL=$((RETVAL | 2))
|
|
|
|
if [ ${OnePlusLoaded} -eq 1 ]; then
|
2006-08-01 11:34:45 +00:00
|
|
|
if [ ${UDEV_EXISTS} -eq 0 ]; then
|
2005-09-01 17:04:50 +00:00
|
|
|
DEVMAJOR=`cat /proc/devices | awk '/ipmidev/{print $1}'`
|
|
|
|
rm -f /dev/ipmi${INTF_NUM}
|
2005-09-08 11:25:11 +00:00
|
|
|
mknod -m 0600 /dev/ipmi${INTF_NUM} c ${DEVMAJOR} 0 || RETVAL=$((RETVAL | 4))
|
2005-09-01 17:04:50 +00:00
|
|
|
fi
|
2005-09-08 11:25:11 +00:00
|
|
|
|
|
|
|
# udev can take several seconds to create /dev/ipmi0,
|
|
|
|
# but it happens asynchronously, so delay here
|
|
|
|
locdelay=${DEV_IPMI_TIMEOUT}
|
|
|
|
while [ ! -e /dev/ipmi${INTF_NUM} -a ${locdelay} -gt 0 ]; do
|
|
|
|
locdelay=$((locdelay - 1))
|
2008-12-10 13:56:38 +00:00
|
|
|
sleep 0.1
|
2005-09-08 11:25:11 +00:00
|
|
|
done
|
2005-07-04 12:50:39 +00:00
|
|
|
fi
|
2005-06-27 14:57:04 +00:00
|
|
|
fi
|
|
|
|
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_IMB}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
modprobe ipmi_imb > /dev/null 2>&1
|
|
|
|
modules_loaded ipmi_imb
|
|
|
|
RETVAL=$((RETVAL & ~2))
|
|
|
|
[ ${OnePlusLoaded} -eq 0 ] && RETVAL=$((RETVAL | 2))
|
|
|
|
if [ ${OnePlusLoaded} -eq 1 ]; then
|
2005-09-01 17:04:50 +00:00
|
|
|
DEVMAJOR=`cat /proc/devices | awk '/imb/{print $1}'`
|
|
|
|
rm -f /dev/imb
|
2005-09-08 11:25:11 +00:00
|
|
|
mknod -m 0600 /dev/imb c ${DEVMAJOR} 0 || RETVAL=$((RETVAL | 4))
|
2005-09-01 17:04:50 +00:00
|
|
|
fi
|
2005-06-27 14:57:04 +00:00
|
|
|
fi
|
|
|
|
|
2005-07-04 12:50:39 +00:00
|
|
|
# Per Corey Minyard, essentially no one uses ipmi_radisys
|
|
|
|
# and we don't want to encourage its further use
|
|
|
|
# so it won't be handled here.
|
|
|
|
return
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
start()
|
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
load_ipmi_modules
|
|
|
|
if [ ${RETVAL} -eq 0 ]; then
|
2012-05-09 12:19:03 +00:00
|
|
|
touch ${LOCKFILE}
|
2005-09-08 11:25:11 +00:00
|
|
|
else
|
|
|
|
if [ $((RETVAL & 1)) -eq 1 ]; then
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Startup failed."
|
2005-09-08 11:25:11 +00:00
|
|
|
else
|
2012-05-09 12:19:03 +00:00
|
|
|
touch ${LOCKFILE} && echo "Warning!?"
|
2005-09-08 11:25:11 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
start_watchdog_quiet
|
|
|
|
start_powercontrol_quiet
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
stop()
|
|
|
|
{
|
2005-09-01 17:04:50 +00:00
|
|
|
unload_ipmi_modules_leave_features
|
2005-09-08 11:25:11 +00:00
|
|
|
modules_loaded ${MODULES_INTERFACES}
|
|
|
|
if [ ${OnePlusLoaded} -ne 0 ]; then
|
|
|
|
RETVAL=$((RETVAL | 32))
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Shutdown failed, something may be in use"
|
2005-09-08 11:25:11 +00:00
|
|
|
else
|
|
|
|
rm -f ${LOCKFILE}
|
|
|
|
fi
|
2005-07-04 12:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_all()
|
|
|
|
{
|
2005-09-01 17:04:50 +00:00
|
|
|
unload_all_ipmi_modules
|
2005-09-08 11:25:11 +00:00
|
|
|
modules_loaded ${MODULES}
|
|
|
|
if [ ${OnePlusLoaded} -ne 0 ]; then
|
|
|
|
RETVAL=$((RETVAL | 32))
|
2012-05-09 12:19:03 +00:00
|
|
|
echo "Shutdown failed, something may be in use"
|
2005-09-08 11:25:11 +00:00
|
|
|
else
|
|
|
|
rm -f ${LOCKFILE}
|
|
|
|
fi
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
restart()
|
|
|
|
{
|
2005-09-01 17:04:50 +00:00
|
|
|
stop_all
|
2005-09-08 11:25:11 +00:00
|
|
|
RETVAL=0
|
2005-09-01 17:04:50 +00:00
|
|
|
start
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
2005-09-01 17:04:50 +00:00
|
|
|
|
2008-10-17 10:34:12 +00:00
|
|
|
reload()
|
|
|
|
{
|
|
|
|
stop_all
|
|
|
|
RETVAL=0
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
|
2005-09-01 17:04:50 +00:00
|
|
|
status_all()
|
|
|
|
{
|
2005-09-08 11:25:11 +00:00
|
|
|
minimum_modules_loaded
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 1))
|
|
|
|
|
|
|
|
modules_loaded_verbose ${MODULES_FEATURES} ${MODULES_INTERFACES}
|
2005-09-01 17:04:50 +00:00
|
|
|
[ ${OnePlusUnloaded} -ne 0 ] && RETVAL=$((RETVAL | 2))
|
|
|
|
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${DEV_IPMI}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
device_node_exists /dev/ipmi${INTF_NUM}
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 4))
|
|
|
|
fi
|
2005-09-01 17:04:50 +00:00
|
|
|
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_IMB}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
device_node_exists /dev/imb
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 4))
|
|
|
|
fi
|
|
|
|
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_WATCHDOG}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
device_node_exists /dev/watchdog
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 8))
|
|
|
|
fi
|
2005-09-01 17:04:50 +00:00
|
|
|
|
|
|
|
[ ! -e ${LOCKFILE} ] && RETVAL=$((RETVAL | 16))
|
|
|
|
}
|
|
|
|
|
|
|
|
status()
|
|
|
|
{
|
|
|
|
minimum_modules_loaded
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 1))
|
|
|
|
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${DEV_IPMI}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
modules_loaded_verbose ipmi_devintf
|
|
|
|
[ ${OnePlusLoaded} -eq 0 ] && RETVAL=$((RETVAL | 2))
|
2005-09-01 17:04:50 +00:00
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
device_node_exists /dev/ipmi${INTF_NUM}
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 4))
|
|
|
|
fi
|
|
|
|
|
2005-11-23 11:21:46 +00:00
|
|
|
if [ "${IPMI_IMB}" = "yes" ]; then
|
2005-09-08 11:25:11 +00:00
|
|
|
device_node_exists /dev/imb
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 4))
|
|
|
|
fi
|
2005-09-01 17:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
status_watchdog()
|
|
|
|
{
|
|
|
|
minimum_modules_loaded
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 1))
|
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
modules_loaded_verbose ipmi_watchdog
|
2005-09-01 17:04:50 +00:00
|
|
|
[ ${OnePlusLoaded} -eq 0 ] && RETVAL=$((RETVAL | 2))
|
|
|
|
|
|
|
|
device_node_exists /dev/watchdog
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 8))
|
|
|
|
}
|
|
|
|
|
|
|
|
status_powercontrol()
|
2005-06-27 14:57:04 +00:00
|
|
|
{
|
2005-09-01 17:04:50 +00:00
|
|
|
minimum_modules_loaded
|
|
|
|
[ $? -eq 0 ] && RETVAL=$((RETVAL | 1))
|
|
|
|
|
2005-09-08 11:25:11 +00:00
|
|
|
modules_loaded_verbose ipmi_powercontrol
|
2005-09-01 17:04:50 +00:00
|
|
|
[ ${OnePlusLoaded} -eq 0 ] && RETVAL=$((RETVAL | 2))
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
2005-09-01 17:04:50 +00:00
|
|
|
#############################################################################
|
2005-06-27 14:57:04 +00:00
|
|
|
usage ()
|
|
|
|
{
|
2010-03-18 15:01:15 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status" 1>&2
|
|
|
|
echo $" restart|condrestart|try-restart|reload|force-reload" 1>&2
|
2005-09-01 17:04:50 +00:00
|
|
|
echo $" start-watchdog|stop-watchdog|status-watchdog" 1>&2
|
|
|
|
echo $" start-powercontrol|stop-powercontrol|status-powercontrol" 1>&2
|
|
|
|
echo $" stop-all|status-all}" 1>&2
|
2010-03-18 15:01:15 +00:00
|
|
|
RETVAL=2
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
condrestart ()
|
|
|
|
{
|
2005-09-01 17:04:50 +00:00
|
|
|
[ -e ${LOCKFILE} ] && restart
|
2005-06-27 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# MAIN
|
|
|
|
#############################################################################
|
|
|
|
case "$1" in
|
|
|
|
start) start ;;
|
|
|
|
stop) stop ;;
|
|
|
|
restart) restart ;;
|
2010-03-18 15:01:15 +00:00
|
|
|
force-reload) reload ;;
|
2008-10-17 10:34:12 +00:00
|
|
|
reload) reload ;;
|
2005-06-27 14:57:04 +00:00
|
|
|
status) status ;;
|
2005-09-01 17:04:50 +00:00
|
|
|
status-all) status_all ;;
|
2005-06-27 14:57:04 +00:00
|
|
|
condrestart) condrestart ;;
|
2005-11-23 11:21:46 +00:00
|
|
|
try-restart) condrestart ;;
|
2005-06-27 14:57:04 +00:00
|
|
|
start-watchdog) start_watchdog ;;
|
|
|
|
stop-watchdog) stop_watchdog ;;
|
2005-09-01 17:04:50 +00:00
|
|
|
status-watchdog) status_watchdog ;;
|
2005-06-27 14:57:04 +00:00
|
|
|
start-powercontrol) start_powercontrol ;;
|
|
|
|
stop-powercontrol) stop_powercontrol ;;
|
2005-09-01 17:04:50 +00:00
|
|
|
status-powercontrol) status_powercontrol ;;
|
|
|
|
stop-all) stop_all ;;
|
2005-06-27 14:57:04 +00:00
|
|
|
*) usage ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit ${RETVAL}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# end of file
|
|
|
|
#############################################################################
|
2005-07-04 12:50:39 +00:00
|
|
|
|