aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Scholten2025-10-24 10:26:11 +1000
committerSam Scholten2025-10-24 10:26:11 +1000
commit56973528a9e4cab924951ad0e4c7b4eead4baa2c (patch)
tree2ce98e0a2fffc50d0c477e54025d67f9923ccf86
parent0af934099f5b9af34b9fad53ce1100c723db8bb9 (diff)
downloaddrestic-56973528a9e4cab924951ad0e4c7b4eead4baa2c.tar.gz
drestic-56973528a9e4cab924951ad0e4c7b4eead4baa2c.zip
Fix systemd service environment variables in setup.shv1.3.2
- Properly set HOME environment variable based on scope (user/system) - Ensure RESTIC_ENV_FILE is correctly added to service files - Fixes issue where services had incorrect paths and env vars
-rwxr-xr-xsetup.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/setup.sh b/setup.sh
index 3650ef6..f667247 100755
--- a/setup.sh
+++ b/setup.sh
@@ -340,13 +340,21 @@ log "Making scripts executable: $INSTALL_DIR/restic_backup.sh, $INSTALL_DIR/rest
chmod +x "$INSTALL_DIR/restic_backup.sh" "$INSTALL_DIR/restic_check.sh" "$INSTALL_DIR/common.sh"
# Prepare systemd service files
-# Use sed to replace the ExecStart path and add the environment variable
+# Use sed to replace the ExecStart path and add the environment variables
+if [ "$SCOPE" == "system" ]; then
+ HOME_PATH="/root"
+else
+ HOME_PATH="$HOME"
+fi
+
log "Generating systemd service file: $SYSTEMD_DIR/restic-backup.service"
sed -e "s|ExecStart=/path/to/be/replaced/restic_backup.sh|ExecStart=$INSTALL_DIR/restic_backup.sh|" \
+ -e "s|Environment=\"HOME=/root\"|Environment=\"HOME=$HOME_PATH\"|" \
-e "s|# Environment variable will be set by setup.sh based on scope|Environment=\"RESTIC_ENV_FILE=$ENV_FILE\"|" \
systemd/restic-backup.service >"$SYSTEMD_DIR/restic-backup.service"
log "Generating systemd service file: $SYSTEMD_DIR/restic-check.service"
sed -e "s|ExecStart=/path/to/be/replaced/restic_check.sh|ExecStart=$INSTALL_DIR/restic_check.sh|" \
+ -e "s|Environment=\"HOME=/root\"|Environment=\"HOME=$HOME_PATH\"|" \
-e "s|# Environment variable will be set by setup.sh based on scope|Environment=\"RESTIC_ENV_FILE=$ENV_FILE\"|" \
systemd/restic-check.service >"$SYSTEMD_DIR/restic-check.service"