From 9d4d50b91ca773657430022f57315921ea7c8b52 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Apr 2026 15:21:12 +0000 Subject: [PATCH] Fix install.sh for non-login shell environments - Set XDG_RUNTIME_DIR before systemctl --user calls so daemon-reload and enable --now work when run outside a login session (e.g. via SSH or sudo) - Run loginctl enable-linger so user services start at boot without a login session - Update .env.example to use single quotes around RTSP URLs and document URL-encoding for special characters in passwords https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ --- install.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a4bb3a3..9128c20 100755 --- a/install.sh +++ b/install.sh @@ -202,8 +202,16 @@ env_example="$HERE/.env.example" echo "# .env is gitignored and never checked in." echo "" echo "# RTSP stream URLs — one line per camera (variable name = CAM_RTSP_)" + echo "#" + echo "# Use single quotes around the whole value to prevent shell interpretation." + echo "# Special characters in the PASSWORD part of the URL must be URL-encoded:" + echo "# @ -> %40 : -> %3A / -> %2F # -> %23" + echo "# ! -> %21 \$ -> %24 & -> %26 % -> %25" + echo "# + -> %2B = -> %3D space -> %20" + echo "# Example: password p@ss!word becomes p%40ss%21word in the URL." + echo "" for cam in "${CAMERAS[@]}"; do - echo "CAM_RTSP_${cam}=rtsp://admin:PASSWORD@192.168.1.XXX:554/stream1" + echo "CAM_RTSP_${cam}='rtsp://admin:PASSWORD@192.168.1.XXX:554/stream1'" done echo "" echo "# Mattermost upload" @@ -218,6 +226,16 @@ env_example="$HERE/.env.example" } > "$env_example" echo " wrote .env.example (cp .env.example .env then fill in real values)" +# ── User-session prerequisites (non-system installs only) ──────────────────── +if ! $SYSTEM_MODE; then + # Make systemctl --user reachable when run outside a login session + export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" + # Start user services at boot even without an interactive login + loginctl enable-linger "$USER" \ + && echo " loginctl enable-linger: ok" \ + || echo " WARNING: loginctl enable-linger failed (may need to run manually)" +fi + # ── Reload and enable ───────────────────────────────────────────────────────── echo "" $SC daemon-reload