One command to update, inspect and manage your Debian hosts. hostctl is an interactive Bash menu for post-install setup and day-to-day maintenance of Debian, DietPi and Raspberry Pi systems. Risky changes are validated before they go live, and a failed action drops you back to the menu instead of killing the script.
- System update and distribution upgrade
- Reboot-required detection
- DietPi distribution upgrade helpers (Bullseye → Bookworm, Bookworm → Trixie)
- Self-update from GitHub with syntax validation and confirmation
- Passwordless sudo configuration with
visudovalidation - SSH hardening with effective-configuration validation and rollback
- Ed25519 SSH key generation
- SSH key distribution to other hosts via
ssh-copy-id - Atomic
.bashrcrecreation and interactive.bash_aliasesmerge - UFW firewall baseline (SSH allowed; PiVPN and SNMP ports auto-allowed when configured)
- WiFi power save disable for wireless hosts (persistent via systemd)
- Profile-based SNMPD installation, configuration, and removal
- Docker repository, installation, and removal tools
- Docker maintenance: prune unused data and update Docker Compose stacks
- PiVPN installation, client generation, and removal
- Wake-on-LAN tools
- Fastfetch repository and updater integration
- geodebtest integration: Debian mirror benchmark (clone/update and run; can apply the chosen mirror to the APT sources)
- Health check: configuration state, services, disk usage, failed systemd units, CPU temperature, and pending package updates
- Configuration backup and restore helpers with automatic pruning
- Profile information and important-path reporting
The menu is grouped into these four sections. Everything is logged to
~/hostctl.log.
A profile is selected when the script starts:
x64x64-brkpipi-brk
Profiles control SNMP community settings, hardware-information sources, and other environment-specific defaults.
- Debian or DietPi
- Bash
- systemd
- An interactive terminal
- Network access for package installation and remote installers
- A normal local user with sudo access
The script installs its required Debian packages during startup. Run it through
sudo from the account that should receive the shell files, SSH key, generated
scripts, and log file.
git clone https://github.com/mews-se/hostctl.git
cd hostctl
sudo ./hostctl.shSelect the appropriate profile, then choose individual actions from the sectioned menu. Each action is self-contained and can be run independently; a failed or cancelled action returns to the menu without terminating the script.
Security-sensitive configuration is backed up before replacement.
- Sudoers candidates are validated before installation.
- SSH candidates are checked with both
sshd -tandsshd -T. - A failed SSH restart restores the previous configuration.
- Failed SNMP reloads restore the previous configuration.
- Restore operations validate supported configuration files before replacing the live version.
Timestamped backups are stored beside their corresponding files. The five newest backups are kept per file; older ones are pruned automatically.
DietPi upgrade helpers and the PiVPN installer are downloaded to secure temporary files instead of being piped directly into Bash.
Before execution, the script:
- Verifies Bash syntax.
- Displays the download URL.
- Displays the SHA-256 digest.
- Requests confirmation before running the file as root.
The self-update action downloads the latest hostctl.sh from the main
branch, verifies Bash syntax, shows the current and new version, and requires
confirmation. The replacement is an atomic rename, so the running instance is
unaffected until restarted.
Docker removal purges the Docker packages and permanently deletes:
/var/lib/docker
/var/lib/containerd
The action requires typing REMOVE before deletion begins.
SNMPD removal stops and disables the service and purges the package and its
configuration after confirmation. Timestamped snmpd.conf backups are kept,
and lm-sensors is left installed.
PiVPN removal runs PiVPN's own interactive uninstaller (pivpn -u) in a
pseudo-terminal, the same way the installer is run. The uninstaller asks
which dependencies to remove and deletes the VPN server configuration.
The Docker maintenance action offers:
- Prune: shows current Docker disk usage, then removes stopped containers, unused networks, dangling images, and build cache. Optionally also removes all unused images.
- Compose stack update: discovers Docker Compose files under the user's
home directory,
/opt, and/srv, then pulls images and restarts each stack after confirmation.
The main script writes its log to:
~/hostctl.log
The file is created and appended as the invoking user rather than as root.
When the log exceeds 1 MB it is rotated to ~/hostctl.log.old, keeping one
previous generation.
- Start a new shell session after changing
.bashrcor.bash_aliases. - Log out and back in after joining the
dockergroup. - Review the reboot-required result after system upgrades.
- Test SSH access in a second session before closing the current connection.
- Restart the script after a self-update to run the new version.
MIT License