exit 1
fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
status_file=/dev/shm/iank-status
shopt -s nullglob
exit 0
fi
+loop_count=0
main-loop() {
while true; do
power=true
power=false
fi
wait=15
- if ! $power; then
- if systemctl -q is-active bitcoind; then
- bitcoinoff
+
+ if $power; then
+ if (( loop_count % 10 == 0 )); then
+ if [[ -r /sys/class/power_supply/BAT0/capacity ]]; then
+ bat=$(cat /sys/class/power_supply/BAT0/capacity)
+ else
+ bat=100
+ fi
+ case $bat in
+ 100|9?)
+ bitcoinon &
+ ;;
+ esac
fi
+ else
+ bitcoinoff
wait=60
fi
sleep $wait
write-status
mute
+ loop_count=$(( loop_count + 1 ))
done
}