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
360 B

#!/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
/usr/sbin/shutdown -r now
fi
sleep $retry_delay
fi
done