diff options
| author | Sam Scholten | 2025-10-27 07:52:15 +1000 |
|---|---|---|
| committer | Sam Scholten | 2025-10-27 07:52:15 +1000 |
| commit | f57913b709828027ef3435a83477fb038e5c7a0e (patch) | |
| tree | 5790476ad94a4e04ee52ec8b96b7907827d88846 | |
| parent | 055850289f79fb2cd4946ffd44b3586371edd35e (diff) | |
| download | drestic-f57913b709828027ef3435a83477fb038e5c7a0e.tar.gz drestic-f57913b709828027ef3435a83477fb038e5c7a0e.zip | |
Fix update.sh: properly replace service file placeholders
- Fix update_services() to use sed like setup.sh does
- Generate service files with correct ExecStart paths
- Add RESTIC_ENV_FILE environment variable during update
- This fixes the '/path/to/be/replaced' error in systemd services
| -rwxr-xr-x | update.sh | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -83,21 +83,43 @@ update_scripts() { update_services() { local install_type="$1" local systemd_dir + local install_dir + local env_file if [ "$install_type" = "system" ]; then systemd_dir="/etc/systemd/system" + install_dir="/usr/local/bin" + env_file="/root/.restic_env" log "Updating systemd services and timers in $systemd_dir" - sudo cp systemd/restic-backup.service "$systemd_dir/" - sudo cp systemd/restic-check.service "$systemd_dir/" + + # 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\"|" \ + systemd/restic-backup.service | sudo tee "$systemd_dir/restic-backup.service" >/dev/null + 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\"|" \ + systemd/restic-check.service | sudo tee "$systemd_dir/restic-check.service" >/dev/null + + # Copy timer files directly sudo cp systemd/restic-backup.timer "$systemd_dir/" sudo cp systemd/restic-check.timer "$systemd_dir/" sudo systemctl daemon-reload else systemd_dir="$HOME/.config/systemd/user" + install_dir="$HOME/.local/bin" + env_file="$HOME/.config/restic/env" mkdir -p "$systemd_dir" log "Updating systemd services and timers in $systemd_dir" - cp systemd/restic-backup.service "$systemd_dir/" - cp systemd/restic-check.service "$systemd_dir/" + + # 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\"|" \ + 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\"|" \ + systemd/restic-check.service >"$systemd_dir/restic-check.service" + + # Copy timer files directly cp systemd/restic-backup.timer "$systemd_dir/" cp systemd/restic-check.timer "$systemd_dir/" systemctl --user daemon-reload |
