Files
raspi-backup/08_timer_disable.sh
2025-12-30 18:38:02 +01:00

24 lines
828 B
Bash

#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
SERVICE_NAME="raspi-backup.service"
TIMER_NAME="raspi-backup.timer"
SERVICE_PATH="/etc/systemd/system/${SERVICE_NAME}"
TIMER_PATH="/etc/systemd/system/${TIMER_NAME}"
[[ "${EUID:-$(id -u)}" -eq 0 ]] || { echo "Bitte mit sudo starten: sudo $SCRIPT_DIR/08_timer_disable.sh"; exit 1; }
command -v systemctl >/dev/null 2>&1 || { echo "systemctl nicht gefunden."; exit 1; }
# stoppen/disable (egal ob existiert)
systemctl disable --now "$TIMER_NAME" >/dev/null 2>&1 || true
# units löschen (falls vorhanden)
rm -f "$SERVICE_PATH" "$TIMER_PATH"
systemctl daemon-reload
echo "Timer/Service deaktiviert und entfernt."
echo "Check:"
systemctl list-timers --all | grep -E "raspi-backup\.timer" || echo "OK: kein Timer mehr da."