if someone wants to shutdown their unit on powerloss:
create file: /etc/udev/rules.d/15-gpio-charger.rules
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/sbin/halt"
i'd love to know a way to start that unit when power is available again though.
on 4.4 the system crashes on halt. but as it does this after all services are stopped and the disks are synced this is not really a problem.
on 5.8 the system stops and "system halted" appears on serial console - BUT it is still on and fans are spinning.