| src | ||
| .gitignore | ||
| build.sh | ||
| Cargo.lock | ||
| Cargo.toml | ||
| config.toml.example | ||
| install.sh | ||
| README.md | ||
| reboot-tester.service | ||
| uninstall.sh | ||
Reboot Tester
A robust system reboot testing tool for Linux systems. This tool safely performs a configurable number of automated system reboots, with multiple safety mechanisms to prevent infinite reboot loops.
Features
- Configurable reboot count: Set the exact number of reboots to perform
- Desktop detection: Waits for the graphical desktop to be ready before counting down
- Configurable delay: Set how long to wait at the desktop before triggering a reboot
- Multiple safety mechanisms:
- Kill switch file to emergency halt reboots
- Maximum uptime detection (assumes user intervention if exceeded)
- Consecutive failure tracking
- Automatic service disable on completion or abort
- Persistent state: Tracks progress across reboots
- Detailed logging: Full history of all reboot attempts
Requirements
- Linux system with systemd
- Rust toolchain (for building)
- Root privileges (for installation and execution)
Installation
Quick Install
# Clone or download the project
cd reboot-tester
# Build the binary (as normal user)
./build.sh
# Install (as root)
sudo ./install.sh
Manual Build & Install
# Build the binary (as normal user)
cargo build --release
# Install (as root)
sudo ./install.sh
Installing from Pre-built Binary
If distributing a pre-built package, place these files in the same directory:
reboot-tester(the binary)install.shuninstall.shconfig.toml.examplereboot-tester.service
Then run:
sudo ./install.sh
Manual Installation (Without Scripts)
# Create directories
sudo mkdir -p /etc/reboot-tester
sudo mkdir -p /var/lib/reboot-tester
# Install files
sudo cp target/release/reboot-tester /usr/local/bin/
sudo cp config.toml.example /etc/reboot-tester/config.toml
sudo cp reboot-tester.service /etc/systemd/system/
# Set permissions
sudo chmod 755 /usr/local/bin/reboot-tester
sudo chmod 644 /etc/reboot-tester/config.toml
sudo chmod 644 /etc/systemd/system/reboot-tester.service
# Reload systemd
sudo systemctl daemon-reload
Configuration
Edit /etc/reboot-tester/config.toml to customize behavior:
[reboot]
# Total number of reboots to perform
target_count = 10
# Seconds to wait after desktop is ready before triggering reboot
wait_after_desktop_seconds = 25
[safety]
# Maximum uptime before assuming user intervention (aborts test)
max_uptime_before_abort_seconds = 300
# Enable the kill switch file feature
enable_kill_switch = true
# Maximum consecutive failed boots before aborting
max_failed_boots = 3
[desktop]
# Detection method: "graphical-target", "display-manager", "dbus-session", "custom-command"
detection_method = "graphical-target"
# Custom command (only if detection_method = "custom-command")
custom_ready_command = ""
# Additional delay after desktop detection
post_detection_delay_seconds = 5
[logging]
log_file = "/var/log/reboot-tester.log"
log_level = "info"
use_journal = true
[state]
state_directory = "/var/lib/reboot-tester"
Usage
Start a Reboot Test
sudo reboot-tester start
This will:
- Initialize the test state
- Enable the systemd service
- Begin the first reboot after a 10-second countdown
Check Status
sudo reboot-tester status
Shows current test progress, safety status, and reboot history.
Stop a Test
sudo reboot-tester stop
Immediately stops the reboot test and disables the service.
Reset State
sudo reboot-tester reset
Clears all state and history.
Safety Mechanisms
1. Kill Switch
Create the file /etc/reboot-tester/STOP to immediately halt all reboots:
sudo touch /etc/reboot-tester/STOP
The tool checks for this file before every reboot.
2. Maximum Uptime Check
If the system has been running longer than max_uptime_before_abort_seconds (default: 300 seconds / 5 minutes), the tool assumes a user is actively using the system and aborts the test.
This prevents accidental reboots if:
- The service starts unexpectedly
- Someone logs in and starts working
- A reboot gets delayed for any reason
3. Consecutive Failure Tracking
If the system fails to complete a reboot cycle multiple times (defined by max_failed_boots), the test is automatically aborted. This prevents issues with systems that boot but fail to reach the desktop.
4. Automatic Service Disable
When a test completes (successfully or via abort), the systemd service is automatically disabled to prevent any future reboots.
How It Works
- Start: User runs
reboot-tester start - Initialize: Tool creates state file, enables systemd service
- First Reboot: System reboots after 10-second countdown
- Boot Detection: On boot, systemd runs the service after graphical target
- Desktop Wait: Tool waits for desktop to be ready
- Countdown: Tool waits configured seconds (default: 25)
- Reboot: System reboots if safety checks pass
- Repeat: Steps 4-7 repeat until target count is reached
- Complete: Service disables itself, test marked complete
Files and Directories
| Path | Description |
|---|---|
/usr/local/bin/reboot-tester |
Main executable |
/etc/reboot-tester/config.toml |
Configuration file |
/etc/reboot-tester/STOP |
Kill switch file (create to stop) |
/var/lib/reboot-tester/state.json |
Persistent state |
/etc/systemd/system/reboot-tester.service |
Systemd service |
/var/log/reboot-tester.log |
Log file |
Packaging for Distribution
To create a distributable package without requiring Rust on the target system:
# Build the binary
./build.sh
# Create distribution directory
mkdir -p dist
cp target/release/reboot-tester dist/
cp install.sh uninstall.sh config.toml.example reboot-tester.service dist/
# Optionally create a tarball
tar -czvf reboot-tester-dist.tar.gz dist/
The dist/ directory (or tarball) can be copied to any compatible Linux system and installed with sudo ./install.sh.
Troubleshooting
Test won't start
- Check you're running as root:
sudo reboot-tester start - Verify config file exists:
cat /etc/reboot-tester/config.toml - Check for existing test:
sudo reboot-tester status
Reboots stopped unexpectedly
- Check for kill switch:
ls -la /etc/reboot-tester/STOP - Check status for reason:
sudo reboot-tester status - Check journal logs:
journalctl -u reboot-tester.service
Want to abort immediately
Multiple options:
# Option 1: Use the stop command
sudo reboot-tester stop
# Option 2: Create kill switch file
sudo touch /etc/reboot-tester/STOP
# Option 3: Disable the service directly
sudo systemctl disable reboot-tester.service
System stuck in reboot loop - Ubuntu
If you can't get to the desktop fast enough:
- At boot, access GRUB menu
- Edit boot entry, add
systemd.unit=rescue.target - Boot into rescue mode
- Run:
systemctl disable reboot-tester.service - Or create:
touch /etc/reboot-tester/STOP - Reboot normally
System stuck in reboot loop systemd-boot - Pop
If you can't get to the desktop fast enough:
- At boot, access systemd-boot menu (Repeatedly tap space on boot)
- Mount the OS partition
- Add the KillSwitch:
touch /etc/reboot-tester/STOP - Reboot normally
Uninstallation
# Stop any active test
sudo reboot-tester stop
# Disable and remove service
sudo systemctl disable reboot-tester.service
sudo rm /etc/systemd/system/reboot-tester.service
sudo systemctl daemon-reload
# Remove files
sudo rm /usr/local/bin/reboot-tester
sudo rm -rf /etc/reboot-tester
sudo rm -rf /var/lib/reboot-tester
License
This tool is provided as-is for system testing purposes. Use at your own risk.