This commit is contained in:
2024-11-10 21:28:16 -06:00
parent b33a252874
commit 1b1b9f3119
2 changed files with 24 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERS='2.8.1-11102024' VERS='2.8.2-11102024'
noheader=' update service dailytemp confsync -r -report test ' noheader=' update service dailytemp confsync -r -report test '

View File

@@ -939,17 +939,31 @@ AMBIENT TEMP: ${OFFSITE_TEMP}'F"
fi fi
if [ -f ${PW_TMPFOLDER}/shutdown.OFFSITE ]; then if [ -f ${PW_TMPFOLDER}/shutdown.OFFSITE ]; then
if [ -f ${PW_TMPFOLDER}/power.offsite.restored ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.restored)) -gt $(echo "scale=2; ${PW_OFFSITE_WAIT_TO_POWER_SERVERS}*60" | bc) ]; then if [ -f ${PW_TMPFOLDER}/power.offsite.restored ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.restored)) -gt $(echo "scale=2; ${PW_OFFSITE_WAIT_TO_POWER_SERVERS}*60" | bc) ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Powering Hosts ON After Power Outage" >> ${PW_LOGFILE} if [ "$(CHECK_HOST ${PW_IP})" != "false" ]; then
SENDNOTICE2 "OFFSITE HOST POWER" "Powering offsite host(s) back ONLINE after power outage" echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Powering Hosts ON After Power Outage" >> ${PW_LOGFILE}
for host in ${PW_OFFSITEHOSTS_IDRAC}; do if [ -f ${PW_TMPFOLDER}/power.offsite.nohomeconn ]; then
if [ "${TEST}" = "" ] || [ "${TEST}" = "full" ]; then SENDNOTICE2 "OFFSITE HOST POWER" "Powerwall connections has been established, powering offsite host(s) back ONLINE after power outage"
ipmitool -I lanplus -H ${host} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power on &
else else
echo "TESTMODE: Powering up '${host}'" SENDNOTICE2 "OFFSITE HOST POWER" "Powering offsite host(s) back ONLINE after power outage"
fi fi
done for host in ${PW_OFFSITEHOSTS_IDRAC}; do
rm -f ${PW_TMPFOLDER}/power.offsite.restored if [ "${TEST}" = "" ] || [ "${TEST}" = "full" ]; then
rm -f ${PW_TMPFOLDER}/shutdown.OFFSITE ipmitool -I lanplus -H ${host} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power on &
else
echo "TESTMODE: Powering up '${host}'"
fi
done
rm -f ${PW_TMPFOLDER}/power.offsite.restored ${PW_TMPFOLDER}/power.offsite.nohomeconn ${PW_TMPFOLDER}/shutdown.OFFSITE
else
if [ ! -f ${PW_TMPFOLDER}/power.offsite.nohomeconn ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Will wait to power on offsite host(s) until powerwall connection is regained" >> ${PW_LOGFILE}
touch ${PW_TMPFOLDER}/power.offsite.nohomeconn
SENDNOTICE2 "OFFSITE HOST POWER" "Will wait to power on offsite host(s) until powerwall connection is regained"
elif [ -f ${PW_TMPFOLDER}/power.offsite.nohomeconn ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.nohomeconn)) -gt $(echo "scale=2; ${PW_OFFSITE_WAIT_TO_POWER_SERVERS}*60" | bc) ]; then
touch ${PW_TMPFOLDER}/power.offsite.nohomeconn
SENDNOTICE2 "OFFSITE HOST POWER" "Still waiting for connection to powerwall before powering offsite host(s) back on"
fi
fi
fi fi
fi fi
logtime=$(expr `date +%s` - $(stat -c %Y ${PW_LOGPOWER})) logtime=$(expr `date +%s` - $(stat -c %Y ${PW_LOGPOWER}))