34 lines
843 B
Bash
Executable file
34 lines
843 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
ping_host="rex.do.netdeneb.com"
|
|
irmc_host="rex-irmc.do.netdeneb.com"
|
|
|
|
netrc_path="/opt/backuprunner/scripts/backupserver-netrc"
|
|
|
|
timeout=600
|
|
|
|
err_report() {
|
|
echo "Error on line $1"
|
|
exit 255
|
|
}
|
|
|
|
trap 'err_report $LINENO' ERR
|
|
|
|
if ! ping -c4 "$ping_host"; then
|
|
curl "$irmc_host/9#restart" -X POST \
|
|
--digest --netrc-file "$netrc_path" \
|
|
-H "Content-Type: application/x-www-form-urlencoded" \
|
|
-d 'APPLY=0&a=1&P0=Confirm' \
|
|
-s -o /dev/null
|
|
|
|
echo "Waiting for $ping_host..."
|
|
while [[ "$timeout" -gt 0 ]]; do
|
|
ping -c1 -W10 "$ping_host" >/dev/null && break
|
|
echo "timeout in $timeout"
|
|
timeout=$(( $timeout - 10 ))
|
|
done
|
|
else
|
|
echo "$ping_host is already up"
|
|
fi
|