Ctrl+Alt+Defib is an ESP32-based power outage monitoring and automated shutdown system designed for Proxmox servers.
The system monitors utility power using a standard 5V USB power adapter. When utility power is lost, a configurable shutdown timer begins. If power is not restored before the timer expires, the Ctrl+Alt+Defib unit sends a secure shutdown request to a Proxmox shutdown service running in a lightweight Linux container. The shutdown service then performs a controlled shutdown of the Proxmox host to protect virtual machines, containers, and storage from unexpected power loss before the UPS batteries are depleted.
The ESP32 remains powered by the UPS during an outage, allowing it to continue monitoring power status. When utility power is restored, a separate configurable startup timer begins. Once the startup delay has expired, the Ctrl+Alt+Defib unit automatically sends a Wake-on-LAN packet to restart the Proxmox host.
The project is designed to be simple to deploy, inexpensive to build, and easy to configure. All settings are managed through a built-in web interface hosted directly on the Ctrl+Alt+Defib unit.
- Configurable shutdown delay timer
- Web-based configuration interface
- Secure token-protected shutdown requests
- Automated Proxmox shutdown-service container installer
- Wake-on-LAN support for automatic Proxmox host startup after power restoration
- Local event logging and status monitoring
- Open-source hardware and firmware
- Designed and tested for the ESP32-ETH02 Ethernet module
.
├── docs
│ └── images
│ ├── Arduino-IDE-Settings.jpg
│ ├── Case-End.jpg
│ ├── Case-esp32.jpg
│ ├── Case-inside.jpg
│ ├── Hat-schematic.png
│ ├── Hookup-Diagram.png
│ ├── PCB-hat.jpg
│ ├── Webpage-config.jpg
│ ├── Webpage-log.jpg
│ └── Webpage-status.jpg
├── enclosure
│ └── stl
│ ├── CtrlAltDefib Case Lid.stl
│ ├── CtrlAltDefib Case.stl
│ └── Printing-Notes.md
├── firmware
│ └── CtrlAltDefib
│ └── CtrlAltDefib.ino
├── hardware
│ └── CtrlAltDefib-HAT
│ ├── CtrlAltDefib-HAT-Gerbers.zip
│ ├── CtrlAltDefib-HAT-Schematic.pdf
│ └── README.md
├── LICENSE
├── README.md
└── shutdown-service
└── install-shutdown-service.sh
- The Ctrl+Alt+Defib unit is powered by the UPS so it remains operational during a power outage.
- A standard 5V USB-C power adapter monitors the presence of utility power.
- If utility power is lost, a configurable shutdown countdown begins.
- If utility power returns before the timer expires, the shutdown countdown is cancelled.
- If the timer expires, the Ctrl+Alt+Defib unit sends a secure shutdown request to the Proxmox shutdown service.
- The shutdown service cleanly shuts down the Proxmox host.
- When utility power is restored, a configurable startup countdown begins.
- When the startup countdown expires, the Ctrl+Alt+Defib unit automatically sends a Wake-on-LAN packet to restart the Proxmox host.
All hardware files required to build the project are located in the hardware/CtrlAltDefib-HAT directory.
The utility power sensing adapter must be connected to a non-UPS outlet. If it is connected to a UPS-backed outlet, the system will be unable to detect a utility power failure.
The Ctrl+Alt+Defib unit must remain powered during a utility power outage. This is typically accomplished using a UPS, but a suitable USB battery pack may also be used.
Network connectivity between the Ctrl+Alt+Defib unit and the Proxmox host must remain available during a power outage. If the Ctrl+Alt+Defib unit communicates through a network switch, the switch should also remain powered until the shutdown process is complete.
Failure to maintain power to the Ctrl+Alt+Defib unit or the network path will prevent the shutdown request from reaching the Proxmox host.
- Bill of Materials (BOM)
- PCB design files
- Schematic files
Refer to the hardware README for the complete bill of materials, sourcing information, and assembly notes.
The 3D printable enclosure files are located in the enclosure directory.
The ESP32-ETH02 does not include a built-in USB programming interface.
To upload firmware, you will need one of the following:
- An ESP32-ETH02 programming adapter board
- A USB-to-Serial adapter with access to the required programming pins
The easiest option is to use one of the ESP32-ETH02 programming adapter boards available from Amazon, AliExpress, and other suppliers. These adapter boards typically provide:
- USB-C connection
- USB-to-Serial interface
- BOOT button
- RESET button
- Power regulation
These adapters allow the ESP32-ETH02 to be programmed directly from the Arduino IDE over USB without additional wiring.
The firmware has been developed and tested on the ESP32-ETH02 Ethernet module using:
| Component | Version |
|---|---|
| Arduino IDE | 2.3.10 |
| ESP32 Board Package (Espressif Systems) | 3.3.10 |
Other LAN8720-based ESP32 Ethernet boards may work, but they have not been tested with this project and are not currently supported.
Open the CtrlAltDefib.ino sketch located in:
firmware/CtrlAltDefib/
and upload it to your ESP32-ETH02 using the Arduino IDE.
Before compiling the firmware, install the ESP32 board package using the Arduino IDE Board Manager.
- Open Tools → Board → Boards Manager.
- Search for:
ESP32
- Install the ESP32 package published by Espressif Systems.
The firmware was developed and tested using version 3.3.10 of the ESP32 board package.
After installation, select:
Tools → Board → ESP32 Arduino → ESP32 Dev Module
and configure the settings shown below.
The firmware was developed and tested using the following Arduino IDE settings:
| Setting | Value |
|---|---|
| Board | ESP32 Dev Module |
| CPU Frequency | 240MHz (WiFi/BT) |
| Core Debug Level | Info |
| Erase All Flash Before Sketch Upload | Disabled |
| Events Run On | Core 1 |
| Flash Frequency | 40MHz |
| Flash Mode | DIO |
| Flash Size | 4MB (32Mb) |
| JTAG Adapter | Disabled |
| Arduino Runs On | Core 1 |
| Partition Scheme | Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) |
| PSRAM | Disabled |
| Upload Speed | 115200 |
| Zigbee Mode | Disabled |
Before compiling and uploading the firmware, edit the following lines in CtrlAltDefib.ino:
constexpr const char *UI_USERNAME = "admin";
constexpr const char *UI_PASSWORD = "CHANGE-ME";Change the password to a secure value before uploading the firmware.
Example:
constexpr const char *UI_USERNAME = "admin";
constexpr const char *UI_PASSWORD = "MySecurePassword";The web interface will use these credentials for authentication.
- Connect the ESP32-ETH02 to your programming adapter.
- Connect the programming adapter to your computer using USB.
- Open
firmware/CtrlAltDefib/CtrlAltDefib.inoin the Arduino IDE. - Configure the username and password in the sketch before compiling.
- Select the settings listed above.
- Compile and upload the firmware.
Install any required libraries when prompted by the Arduino IDE.
After the firmware has been uploaded successfully, continue with the Proxmox Shutdown Service Setup section.
The shutdown service runs inside a lightweight Debian LXC container and receives authenticated shutdown requests from the Ctrl+Alt+Defib unit .
The installer automatically creates and configures the container, installs all required software, generates SSH keys, and configures the shutdown service.
- Proxmox VE 8.x or newer
- Internet access from the Proxmox host
- A Debian 12 container template available in Proxmox
If a Debian 12 template is not already installed:
- Open the Proxmox web interface.
- Select the local storage.
- Open CT Templates.
- Download the latest Debian 12 Standard template.
Log in to the Proxmox host as root and clone the repository:
git clone https://github.com/shaneaune/CtrlAltDefib.git
cd CtrlAltDefib/shutdown-serviceMake the installer executable and start it:
chmod +x install-shutdown-service.sh
./install-shutdown-service.shThe installer will:
- Create the shutdown-service container
- Install required packages
- Generate the SSH shutdown key
- Install and start the shutdown service
- Display the Ctrl+Alt+Defib unit configuration settings
- Generate the authorized_keys entry required for Proxmox shutdown access
When the installer completes, it will display a line similar to:
command="shutdown -h now",no-port-forwarding,no-agent-forwarding,no-pty ssh-ed25519 ...
Copy the entire line and add it to the Proxmox host's authorized_keys file:
nano /root/.ssh/authorized_keysPaste the generated line onto a new line at the end of the file.
To save the file:
Ctrl+O Enter
To exit Nano:
Ctrl+X
On the Proxmox host you can retrieve the generated line again at any time with:
pct exec <CTID> -- cat /root/proxmox_authorized_key.txtThe installer will display:
- Shutdown Service IP
- Shutdown Service Port
- Shutdown Token
These values will be required when configuring the Ctrl+Alt+Defib settings in the web interface.
The first time the shutdown-service container connects to the Proxmox host, SSH will prompt to verify the Proxmox host key.
Before performing the first shutdown test:
-
Open a console to the shutdown-service container.
-
Run:
pct enter
- Leave the console open during the first shutdown test.
When the shutdown timer expires, you will see a message similar to:
The authenticity of host '10.0.0.xxx' can't be established. ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxx. Are you sure you want to continue connecting (yes/no/[fingerprint])?
Type:
yes
and press Enter.
The Proxmox host key will be saved and all future shutdowns will occur automatically without additional user interaction.
After the Ctrl+Alt+Defib unit has been configured, perform a shutdown test.
The first shutdown request will automatically save the Proxmox host SSH key within the shutdown-service container. Future shutdown requests will use the saved key automatically.
Verify that:
- The Ctrl+Alt+Defib unit detects utility power loss
- The shutdown timer expires as expected
- The Proxmox host shuts down cleanly
- Wake-on-LAN startup functions correctly after power restoration
Note: During the first shutdown test only, you may be prompted to verify the Proxmox host SSH key as described in the previous section.
After uploading the firmware and connecting the Ctrl+Alt+Defib unit to your network, the device will automatically obtain an IP address using DHCP.
Locate the assigned IP address using your router, DHCP server, or a network scanning tool and open the web interface in your browser:
http://<ip-address>/
Log in using the username and password configured in the firmware before uploading.
After logging in, the Status page will be displayed. Open the Config page to access the system settings.
On the Configuration page, enter the values provided by the shutdown-service installer:
- Shutdown Service IP Address
- Shutdown Service Port
- Shutdown Token
Set the desired shutdown delay. This determines how long the system will wait after utility power is lost before initiating a Proxmox shutdown.
Enter the MAC address of the Proxmox host and configure the desired startup delay.
When utility power is restored, the Ctrl+Alt+Defib unit will wait for the configured startup delay before sending the Wake-on-LAN packet.
Save the configuration using the Save Config button. The Ctrl+Alt+Defib unit will begin monitoring utility power and managing shutdown and startup events using the configured settings.
Before relying on Ctrl+Alt+Defib to protect your Proxmox host, perform a complete functional test.
- Ensure the Ctrl+Alt+Defib unit is powered from a UPS-backed outlet.
- Ensure the utility power sensing adapter is connected to a non-UPS outlet.
- Open the Ctrl+Alt+Defib Status page.
- Verify that utility power is reported as present.
- Temporarily disconnect the utility power sensing adapter.
- Verify that the shutdown countdown begins.
- Allow the countdown to expire.
- Confirm that the Proxmox host shuts down cleanly.
- Restore utility power.
- Verify that the startup countdown begins.
- Allow the startup delay to expire.
- Confirm that a Wake-on-LAN packet is sent.
- Verify that the Proxmox host powers on successfully.
After the test is complete, confirm that:
- Utility power status is reported correctly.
- Shutdown countdown operates correctly.
- Startup countdown operates correctly.
- The Proxmox host shuts down cleanly.
- Wake-on-LAN startup functions correctly.
- Event logs show the expected activity.







