https://nuclear.unh.edu/wiki/index.php?title=Shutdown2&feed=atom&action=history
Shutdown2 - Revision history
2024-03-29T10:09:06Z
Revision history for this page on the wiki
MediaWiki 1.35.0
https://nuclear.unh.edu/wiki/index.php?title=Shutdown2&diff=5105&oldid=prev
Aduston at 15:24, 20 July 2010
2010-07-20T15:24:33Z
<p></p>
<p><b>New page</b></p><div>This script is located in /etc/apcupsd/shutdown2 on [[gourd]]. It monitors battery life and shuts down other systems connected to the UPS as battery life is depleted.<br />
<br />
<code><br />
#!/bin/sh<br />
<br />
while [ 1 ]; do<br />
if [ `/usr/sbin/apcaccess | grep STATUS | awk '{print $3}'` = "ONLINE" ] ; then<br />
echo "online, exiting"| write Tbow<br />
exit 0<br />
fi<br />
CHARGE=`/usr/sbin/apcaccess | grep BCHARGE | awk '{print $3}'`<br />
echo "monitoring charge" | write Tbow<br />
if [ `echo "$CHARGE <= 50.0" | bc` -eq 1 ]; then<br />
wall "apcupsd: Shutting down machines in rack."<br />
ssh -i /root/.ssh/shutdown_id_rsa root@taro 'shutdown -h now'<br />
sleep 5<br />
ssh -i /root/.ssh/shutdown_id_rsa root@pumpkin 'shutdown -h now'<br />
sleep 5<br />
ssh -i /root/.ssh/shutdown_id_rsa root@tomato 'shutdown -h now'<br />
sleep 5<br />
ssh -i /root/.ssh/shutdown_id_rsa root@roentgen 'shutdown -h now'<br />
fi<br />
if [ `echo "$CHARGE <= 5.0" | bc` -eq 1 ]; then<br />
wall "apcupsd: Shutting down Einstein and Jalapeno"<br />
ssh -i /root/.ssh/shutdown_id_rsa root@einstein 'shutdown -h now'<br />
sleep 5<br />
ssh -i /root/.ssh/shutdown_id_rsa root@jalapeno 'shutdown -h now'<br />
exit 1<br />
fi<br />
sleep 30<br />
done<br />
</code></div>
Aduston