Stop a non-interactive install aborting on the service prompt

The systemd-service question was a bare `read -rp`. Under `set -euo pipefail`
a read that hits EOF returns non-zero, so every caller without a TTY --
install_core_system.sh, CI, `vm run` -- aborted the installer with exit 1 at
that line, after the Python deps were already in place. That made the module
permanently un-installable from its documented install path.

It now defaults to "n" when stdin is not a terminal and says how to add the
service later; STEAM_ENFORCER_INSTALL_SERVICE=y opts in non-interactively.
The interactive path is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
This commit is contained in:
Krzysztof Rudnicki 2026-08-24 13:04:00 +02:00
parent 740ec43767
commit 2ad87524e4

View File

@ -33,7 +33,22 @@ else
fi
# Install systemd service (system-level, runs as root).
read -rp "Install systemd enforce service? [y/N] " ans
#
# Non-interactive callers (install_core_system.sh, CI, `vm run`) have no stdin,
# where a bare `read` fails and -- under `set -e` -- aborts this whole installer
# with exit 1 after the Python deps are already in place. That made the module
# permanently un-installable from the documented install path. Default to "no"
# when there is no terminal, and let STEAM_ENFORCER_INSTALL_SERVICE=y opt in.
ans="${STEAM_ENFORCER_INSTALL_SERVICE:-}"
if [[ -z $ans ]]; then
if [[ -t 0 ]]; then
read -rp "Install systemd enforce service? [y/N] " ans
else
ans="n"
echo "No terminal: skipping the systemd enforce service."
echo "(Install it later with: sudo STEAM_ENFORCER_INSTALL_SERVICE=y bash install.sh)"
fi
fi
if [[ "${ans,,}" == "y" ]]; then
if [[ $EUID -ne 0 ]]; then
echo "Error: systemd service install needs root. Re-run with sudo."