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
This commit is contained in:
+19
-1
@@ -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_<camname>)"
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user