#!/bin/sh

timestamp=`date`
logfile="/home/pi/pbj.log"
echo $timestamp "pbj ac detect poll" >> $logfile
while true
do
	sleep 180
        ac_gpio=`gpio read 8`
	if test $ac_gpio -eq 1
        then
		timestamp=`date`
		echo $timestamp "ac is down (1)" >> $logfile
		sleep 30
		/sbin/halt -p
        fi
done
