Linux laptop servers

Let the battery protect your data

Power Outage Helper watches incoming power and network reachability. If both remain unavailable after a grace period, it starts a normal Linux shutdown before the laptop battery is exhausted.

Two signals before shutdown

Careful decisions during an outage

Power-source detection

The guard reads Linux power-supply data for mains, USB, USB-C, USB-PD, and battery charging or full states instead of relying on a single adapter name.

Redundant network checks

After power is absent for 30 seconds, shutdown proceeds only if google.com, 1.1.1.1, and the local gateway at 192.168.1.1 are all unreachable.

Managed system service

One script installs, starts, checks, and removes a systemd service. The service restarts automatically and records events through the system logger.

Install with systemd

Start protecting the server

The installer copies the guard to /usr/local/sbin, creates the systemd unit, and enables it immediately. Root access and the ping command from iputils-ping are required.

chmod +x power-network-shutdown-guard.sh
sudo ./power-network-shutdown-guard.sh --install
sudo ./power-network-shutdown-guard.sh --status
  1. 1
    Test adapter detectionRun the non-destructive test helper and unplug the adapter. It exits when incoming power is no longer detected.
  2. 2
    Install the guardMake the shutdown script executable and run its install command with root privileges.
  3. 3
    Verify the serviceCheck systemd status and confirm that the three default ping targets reflect the server's actual network.

Non-destructive verification

Test detection before enabling shutdown

The adapter test polls every two seconds and never shuts down the machine. Use it first to confirm that the laptop exposes its charging state through /sys/class/power_supply.