3 PATH
=/sbin
:/usr
/sbin
:/bin
:/usr
/bin
:/usr
/local
/sbin
:/usr
/local
/bin
6 DESC
="Network UPS Tools"
7 DEFAULT
=/etc
/sysconfig
/nut
8 CONFIG
=/etc
/nut
/nut.conf
13 # set upsd specific options. use "man upsd" for more info
16 # set upsmon specific options. use "man upsmon" for more info
19 # Include defaults if available (transition period)
20 if [ -f $DEFAULT ] ; then
24 # Include NUT nut.conf
25 if [ -f $CONFIG ] ; then
29 # Explicitly require the configuration to be done in /etc/nut/nut.conf
30 if [ "x$MODE" = "xnone" ] ; then
31 log_failure_msg
"$NAME disabled, please adjust the configuration to your needs "
32 log_failure_msg
"and then set MODE to a suitable value in $CONFIG to enable it."
33 # exit success to avoid breaking the install process!
38 upsdrvctl
=/usr
/bin
/upsdrvctl
39 upsmon
=/usr
/sbin
/upsmon
40 log
=">/dev/null 2>/dev/null"
42 start_stop_server
() {
47 ! $upsdrvctl start
>/dev
/null
2>&1 && boot_mesg
"(upsdrvctl failed)"
48 $upsd $UPSD_OPTIONS >/dev
/null
2>&1
52 $upsd -c stop
>/dev
/null
2>&1
54 ! $upsdrvctl stop
>/dev
/null
2>&1 && boot_mesg
"(upsdrvctl failed)"
64 start_stop_client
() {
66 standalone|netserver|netclient
)
69 $upsmon $UPSMON_OPTIONS >/dev
/null
2>&1
73 $upsmon -c stop
>/dev
/null
2>&1
110 boot_mesg
"Starting $DESC ..."
111 start_stop_server start
112 start_stop_client start
116 boot_mesg
"Stopping $DESC ..."
117 start_stop_server stop
118 start_stop_client stop
122 $upsd -c reload
>/dev
/null
2>&1
123 $upsmon -c reload
>/dev
/null
2>&1
131 restart|force-reload
)
132 boot_mesg
"Restarting $DESC ..."
133 start_stop_client stop
134 start_stop_server stop
136 start_stop_server start
137 start_stop_client start
141 flag
=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p' /etc/nut/upsmon.conf`
142 wait_delay
=`sed -ne 's#^ *POWEROFF_WAIT= *\(.*\)$#\1#p' $CONFIG`
143 if [ -f "$flag" ] ; then
144 if $upsmon -K >/dev
/null
2>&1 ; then
145 boot_mesg
"Shutting down the UPS ..."
147 if $upsdrvctl shutdown
; then
149 boot_mesg
"Waiting for UPS to cut the power"
151 boot_mesg
"Shutdown failed."
152 boot_mesg
"Waiting for UPS batteries to run down"
154 if [ "$wait_delay" ] ; then
155 boot_mesg
" (will reboot after $wait_delay) ..."
157 /etc
/init.d
/reboot stop
160 boot_mesg
"Power down flag is not set (UPS shutdown not needed)"
163 if [ -z "$flag" ] ; then
164 boot_mesg
"##########################################################"
165 boot_mesg
"## POWERDOWNFLAG is not defined in /etc/nut/upsmon.conf ##"
167 boot_mesg
"## Please read the Manual page upsmon.conf(5) ##"
168 boot_mesg
"##########################################################"
175 echo "Usage: $N {start|stop|status|reload|restart|force-reload|poweroff}" >&2