From dcb1ce034dab2d19488e81673d8338820a714fea Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Thu, 17 Sep 2026 08:56:33 -0400 Subject: [PATCH] fix(install): make install_service.sh --help print usage instead of installing install_service.sh parsed no arguments, so `sudo ./scripts/install/ install_service.sh --help` (presented as harmless in MIGRATION_GUIDE.md) rewrote ledmatrix.service, ledmatrix-web.service and both update-verify units and enabled/started them. It now handles -h/--help (usage, exit 0, no changes) and rejects any other argument with exit 2 before doing anything. Running it with no arguments, as first_time_install.sh does, is unchanged. Co-Authored-By: Claude Opus 5 --- scripts/install/install_service.sh | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scripts/install/install_service.sh b/scripts/install/install_service.sh index 07a53832..8b129503 100755 --- a/scripts/install/install_service.sh +++ b/scripts/install/install_service.sh @@ -3,6 +3,41 @@ # Exit on error set -e +usage() { + cat <<'USAGE' +Usage: sudo ./scripts/install/install_service.sh [-h|--help] + +Installs (or reinstalls) the LEDMatrix systemd units from the templates in +systemd/, then enables and starts them: + - ledmatrix.service main display (runs as root) + - ledmatrix-web.service web interface (runs as the invoking user) + - ledmatrix-update-verify.service automatic-update health check + - ledmatrix-update-verify.path + +Existing unit files in /etc/systemd/system are overwritten. The script takes +no other options; run it with no arguments to install. + +Options: + -h, --help Show this help and exit without changing anything. +USAGE +} + +# Parse arguments before touching anything: this script rewrites and restarts +# services, so an unrecognised option must not fall through to a full install. +for arg in "$@"; do + case "$arg" in + -h|--help) + usage + exit 0 + ;; + *) + echo "ERROR: unknown option: $arg" >&2 + usage >&2 + exit 2 + ;; + esac +done + # Get the actual user who invoked sudo if [ -n "$SUDO_USER" ]; then ACTUAL_USER="$SUDO_USER"