diff options
| -rwxr-xr-x | setup.sh | 16 | ||||
| -rw-r--r-- | systemd/restic-backup.service | 5 | ||||
| -rw-r--r-- | systemd/restic-check.service | 5 | ||||
| -rwxr-xr-x | update.sh | 4 |
4 files changed, 20 insertions, 10 deletions
@@ -348,15 +348,23 @@ else fi log "Generating systemd service file: $SYSTEMD_DIR/restic-backup.service" +# Generate the service file with correct paths 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\"|" \ + -e "s|Environment=\"RESTIC_ENV_FILE=/path/to/be/replaced\"|Environment=\"RESTIC_ENV_FILE=$ENV_FILE\"|" \ systemd/restic-backup.service >"$SYSTEMD_DIR/restic-backup.service" +# Add HOME environment variable only for system scope +if [ "$SCOPE" == "system" ]; then + sed -i "/# HOME will be set by setup.sh for system scope only/a Environment=\"HOME=/root\"" "$SYSTEMD_DIR/restic-backup.service" +fi log "Generating systemd service file: $SYSTEMD_DIR/restic-check.service" +# Generate the service file with correct paths 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\"|" \ + -e "s|Environment=\"RESTIC_ENV_FILE=/path/to/be/replaced\"|Environment=\"RESTIC_ENV_FILE=$ENV_FILE\"|" \ systemd/restic-check.service >"$SYSTEMD_DIR/restic-check.service" +# Add HOME environment variable only for system scope +if [ "$SCOPE" == "system" ]; then + sed -i "/# HOME will be set by setup.sh for system scope only/a Environment=\"HOME=/root\"" "$SYSTEMD_DIR/restic-check.service" +fi # Copy systemd timer files log "Copying systemd timer file: $SYSTEMD_DIR/restic-backup.timer" diff --git a/systemd/restic-backup.service b/systemd/restic-backup.service index 0e2e411..259b5d8 100644 --- a/systemd/restic-backup.service +++ b/systemd/restic-backup.service @@ -7,8 +7,9 @@ After=network.target network-online.target Type=oneshot # ExecStart path will be replaced by setup.sh during installation ExecStart=/path/to/be/replaced/restic_backup.sh -# Environment variable will be set by setup.sh based on scope -Environment="HOME=/root" +# Environment variable for restic configuration +Environment="RESTIC_ENV_FILE=/path/to/be/replaced" +# HOME will be set by setup.sh for system scope only # Memory limits to prevent OOM on VPS (allow swap for prune operations) MemoryMax=512M MemorySwapMax=1G diff --git a/systemd/restic-check.service b/systemd/restic-check.service index 0892554..78f92f8 100644 --- a/systemd/restic-check.service +++ b/systemd/restic-check.service @@ -7,8 +7,9 @@ After=network.target network-online.target Type=oneshot # ExecStart path will be replaced by setup.sh during installation ExecStart=/path/to/be/replaced/restic_check.sh -# Environment variable will be set by setup.sh based on scope -Environment="HOME=/root" +# Environment variable for restic configuration +Environment="RESTIC_ENV_FILE=/path/to/be/replaced" +# HOME will be set by setup.sh for system scope only # Memory limits to prevent OOM on VPS (allow swap for safety) MemoryMax=512M MemorySwapMax=1G @@ -113,10 +113,10 @@ update_services() { # Generate service files with correct paths (like setup.sh does) sed -e "s|ExecStart=/path/to/be/replaced/restic_backup.sh|ExecStart=$install_dir/restic_backup.sh|" \ - -e "s|# Environment variable will be set by setup.sh based on scope|Environment=\"RESTIC_ENV_FILE=$env_file\"|" \ + -e "s|Environment=\"RESTIC_ENV_FILE=/path/to/be/replaced\"|Environment=\"RESTIC_ENV_FILE=$env_file\"|" \ systemd/restic-backup.service >"$systemd_dir/restic-backup.service" sed -e "s|ExecStart=/path/to/be/replaced/restic_check.sh|ExecStart=$install_dir/restic_check.sh|" \ - -e "s|# Environment variable will be set by setup.sh based on scope|Environment=\"RESTIC_ENV_FILE=$env_file\"|" \ + -e "s|Environment=\"RESTIC_ENV_FILE=/path/to/be/replaced\"|Environment=\"RESTIC_ENV_FILE=$env_file\"|" \ systemd/restic-check.service >"$systemd_dir/restic-check.service" # Copy timer files directly |
