A script to shutdown a system on power events. This is useful, for example, to tether a system to a specific physical location while in public. This way, any attempt to move the system elsewhere (for example, for forensic analysis at a separate location) will result in immediate poweroff
WARNING: This script has no way to differentiate being unplugged from an innocent loss of power. An unexpected temporary loss of power can result in data loss. Therefore, it's recommended to avoid using destructive panic actions. The script syncs data to disk by default, but cannot save your documents for you. Unsaved data will be lost
This script was designed to run on Qubes inside dom0, but should work on most Linux-based OSs
Installation is as follows:
- Copy
qpowerkill,qpowerkill.service, andpkinto dom0 - Copy/move
qpowerkillinto/usr/binand mark it as executable - Copy/move
qpowerkill.serviceinto/etc/systemd/system - Copy/move
pkinto/usr/binand mark it executablepkis a helper script to disable/re-enable qpowerkill without typing a long systemctl command
- Run
systemctl enable qpowerkillto make qpowerkill start at boot - After qpowerkill is set to start at boot, run
systemctl start qpowerkillto start qpowerkill immediately
This will enable the service at boot, and start the service
To attach or detatch your charger/power adapter without causing dom0 to power off, temporarily stop the service with systemctl stop qpowerkill or use the provided helper script pk, then restart it after the power adapter is attached or removed
pk is effectively just an alias for systemctl <start/stop/restart/status> qpowerkill. The major benefit is it's shorter
- To start qpowerkill, run
pk start - To stop qpowerkill, run
pk stop - To check if qpowerkill is running, run
pk status - To view qpowerkill's logs, run
pk log - To delete qpowerkill's logs, run
pk rm-log - You can also queue multiple commands. For example,
pk start statuswill start qpowerkill, then show the status to make sure it's actually running
The Qubes official documentation has information about copying files to dom0: https://www.qubes-os.org/doc/how-to-copy-from-dom0/#copying-to-dom0
For better security, you should download this into a disposable VM, to prevent a compromised qube from tampering with the data locally
For the best security, you should use qubes-clean to copy this script into dom0