You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
341 B
23 lines
341 B
2 years ago
|
#!/bin/bash
|
||
|
|
||
|
upsname="{{ upsname }}"
|
||
|
retries=5
|
||
|
retry_delay=30
|
||
|
|
||
|
# Check dependencies
|
||
|
which upsc >/dev/null || exit 1
|
||
|
|
||
|
upsstat=1 # just to bootstrap the loop
|
||
|
|
||
|
while [ $upsstat -ne 0 ]; do
|
||
|
upsc $upsname
|
||
|
upsstat=$?
|
||
|
if [ $upsstat -eq 1 ]; then
|
||
|
let retries=retries-1
|
||
|
if [ $retries -le 0 ]; then
|
||
|
reboot
|
||
|
fi
|
||
|
sleep $retry_delay
|
||
|
fi
|
||
|
done
|