nut-debian/scripts/Solaris/nut.in
2013-11-24 16:00:12 +01:00

64 lines
893 B
Bash

#!/sbin/sh
#init.d script to start nut services
NUT_DIR="@prefix@"
CONFIG=$NUT_DIR/etc/nut.conf
if [ -f $CONFIG ] ; then
. $CONFIG
fi
ups_stop () {
pkill -n upsmon
pkill -n upsd
${NUT_DIR}/bin/upsdrvctl stop > /dev/null 2>&1
}
ups_start () {
if [ "$MODE" = "none" ];then
echo No mode set
exit 1
fi
if [ ! "$MODE" = "netclient" ];then
$NUT_DIR/bin/upsdrvctl start #> /dev/null 2>&1
$NUT_DIR/sbin/upsd #> /dev/null 2>&1
fi
$NUT_DIR/sbin/upsmon #> /dev/null 2>&1
}
case $1 in
'start')
ups_start
;;
'stop')
ups_stop
;;
'restart')
ups_stop
while pgrep upsd > /dev/null
do
sleep 1
done
ups_start
;;
'poweroff')
$NUT_DIR/sbin/upsmon -K >/dev/null 2>&1
if [ $? = 0 ]; then
echo "Shutting down the UPS ..."
#$NUT_DIR/bin/upsdrvctl shutdown
fi
;;
*)
echo ""
echo "Usage: '$0' {start | stop | restart }"
echo ""
exit 64
;;
esac
exit $?