Asking the kernel to disable PCI #hotplug may have just turned a #macpro2013 (the cylindrical one) from a workstation no longer receiving vendor software updates into something longer-lived. And more in line with my way of computing, which tends to be low-#GPU, moderate-#CPU, and high-memory. I wonder if it will run a bunch of #bhyve #virtualmachines or #FreeBSD #jails in the near future.
#jails #freebsd #virtualmachines #bhyve #cpu #gpu #macpro2013 #hotplug
how to #shutdown when #AC #PSU #power is #disconnected and running on #battery
useful for media art installations where you don't want the laptop battery to be destroyed by excessive power consumption if there is a long power cut
```
$ cat /usr/local/bin/psu-hotplug.sh
#!/bin/bash
ACTIVE="${1}"
PSUUSER=myinstallationuser
XUSER="$(who | grep -F "(:0)" | cut -d\ -f 1)"
if [ "x${XUSER}" = "x${PSUUSER}" ]
then
if [ "x${ACTIVE}" = "x0" ]
then
# power off if power is not restored
echo "$(date --iso=s) power lost" >> /var/log/psu-hotplug.log
touch /var/run/psu-hotplug.shutdown
sleep 30
if [ -f /var/run/psu-hotplug.shutdown ]
then
echo "$(date --iso=s) shutting down" >> /var/log/psu-hotplug.log
shutdown now -h
else
echo "$(date --iso=s) not shutting down" >> /var/log/psu-hotplug.log
fi
else
echo "$(date --iso=s) power restored" >> /var/log/psu-hotplug.log
rm -f /var/run/psu-hotplug.shutdown
fi
fi
$ cat /etc/udev/rules.d/50-psu-hotplug.rules
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}!="0", RUN+="/usr/local/bin/psu-hotplug.sh 1"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="AC", ENV{POWER_SUPPLY_ONLINE}!="0", RUN+="/usr/local/bin/psu-hotplug.sh 1"
```
#hotplug #udev #linux #battery #disconnected #power #psu #ac #shutdown