nut/scripts/Solaris/nut.in

64 lines
896 B
Text
Raw Normal View History

2013-11-24 15:00:12 +00:00
#!/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
2014-04-22 18:39:47 +00:00
${NUT_DIR}/sbin/upsdrvctl stop > /dev/null 2>&1
2013-11-24 15:00:12 +00:00
}
ups_start () {
if [ "$MODE" = "none" ];then
echo No mode set
exit 1
fi
if [ ! "$MODE" = "netclient" ];then
2014-04-22 18:39:47 +00:00
$NUT_DIR/sbin/upsdrvctl start #> /dev/null 2>&1
2013-11-24 15:00:12 +00:00
$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 ..."
2014-04-22 18:39:47 +00:00
#$NUT_DIR/sbin/upsdrvctl shutdown
2013-11-24 15:00:12 +00:00
fi
;;
*)
echo ""
echo "Usage: '$0' {start | stop | restart }"
echo ""
exit 64
;;
esac
exit $?