Merge pull request 'v0.7.1' (#13) from v0.7.1 into main

Reviewed-on: #13
This commit is contained in:
2026-04-12 12:37:09 +00:00
14 changed files with 365 additions and 45 deletions

View File

@@ -36,6 +36,7 @@ Wenn ein Client eine bestimmte Domain zu oft anfragt (z.B. >30x pro Minute), wir
- Whitelist für vertrauenswürdige IPs
- Dry-Run Modus zum gefahrlosen Testen
- Benachrichtigungen (Discord, Slack, Gotify, Ntfy)
- **Watchdog** — automatischer Health Check alle 5 Minuten mit Recovery und Benachrichtigung bei Service-Ausfall
- systemd Service für dauerhaften Betrieb
## Voraussetzungen
@@ -97,32 +98,10 @@ sudo /opt/adguard-shield/report-generator.sh send # Report jetzt
sudo /opt/adguard-shield/report-generator.sh status # Report-Status anzeigen
sudo /opt/adguard-shield/report-generator.sh install # Cron-Job einrichten
sudo journalctl -u adguard-shield -f # Logs live verfolgen
```
## Projektstruktur
```
├── adguard-shield.sh # Haupt-Monitor-Script
├── adguard-shield.conf # Konfiguration
├── adguard-shield.service # systemd Unit
├── external-blocklist-worker.sh # Externer Blocklist-Worker
├── external-whitelist-worker.sh # Externer Whitelist-Worker (DynDNS-Auflösung)
├── iptables-helper.sh # Manuelle iptables-Verwaltung
├── unban-expired.sh # Cron-basiertes Entsperren
├── report-generator.sh # E-Mail Report Generator
├── install.sh # Installer / Updater
├── uninstall.sh # Uninstaller (wird ins Installationsverzeichnis kopiert)
├── templates/
│ ├── report.html # HTML-Report-Template
│ └── report.txt # TXT-Report-Template
├── README.md
└── docs/
├── architektur.md # Architektur & Funktionsweise
├── konfiguration.md # Alle Parameter erklärt + Konfig-Migration
├── befehle.md # Vollständige Befehlsreferenz inkl. Installer
├── benachrichtigungen.md # Webhook-Setup (Discord, Slack, Gotify, Ntfy)
├── report.md # E-Mail Report Setup & Konfiguration
└── tipps-und-troubleshooting.md
# Watchdog (automatischer Health Check)
sudo systemctl status adguard-shield-watchdog.timer # Watchdog-Status
sudo systemctl list-timers adguard-shield-watchdog.timer # Nächste Ausführung
```
## Dokumentation
@@ -134,7 +113,7 @@ sudo journalctl -u adguard-shield -f # Logs live ver
| [Befehle](docs/befehle.md) | Vollständige Befehlsreferenz für Installer, Monitor, iptables-Helper und systemd |
| [Benachrichtigungen](docs/benachrichtigungen.md) | Setup für Discord, Slack, Gotify, Ntfy |
| [E-Mail Report](docs/report.md) | Periodische Statistik-Reports per E-Mail (HTML/TXT) |
| [Tipps & Troubleshooting](docs/tipps-und-troubleshooting.md) | Best Practices, häufige Probleme, Deinstallation |
| [Tipps & Troubleshooting](docs/tipps-und-troubleshooting.md) | Best Practices, häufige Probleme, Watchdog, Deinstallation |
## Lizenz

View File

@@ -0,0 +1,7 @@
[Unit]
Description=AdGuard Shield - Watchdog Health Check
Documentation=https://git.techniverse.net/scriptos/adguard-shield
[Service]
Type=oneshot
ExecStart=/opt/adguard-shield/adguard-shield-watchdog.sh

166
adguard-shield-watchdog.sh Normal file
View File

@@ -0,0 +1,166 @@
#!/bin/bash
###############################################################################
# AdGuard Shield - Watchdog
# Prüft ob der Hauptservice läuft und startet ihn bei Bedarf neu.
# Wird über adguard-shield-watchdog.timer alle 5 Minuten ausgeführt.
#
# Autor: Patrick Asmus
# E-Mail: support@techniverse.net
# Lizenz: MIT
###############################################################################
set -euo pipefail
INSTALL_DIR="/opt/adguard-shield"
CONFIG_FILE="${INSTALL_DIR}/adguard-shield.conf"
SERVICE_NAME="adguard-shield.service"
LOG_FILE="/var/log/adguard-shield.log"
WATCHDOG_STATE_FILE="/var/lib/adguard-shield/watchdog.state"
# ─── Logging ──────────────────────────────────────────────────────────────────
log() {
local level="$1"
shift
local message="$*"
local timestamp
timestamp="$(date '+%Y-%m-%d %H:%M:%S')"
local log_entry="[$timestamp] [WATCHDOG] [$level] $message"
echo "$log_entry" | tee -a "$LOG_FILE"
}
# ─── Benachrichtigung senden ──────────────────────────────────────────────────
send_watchdog_notification() {
local action="$1" # "recovery" oder "failure"
local detail="$2"
# Konfiguration laden für Benachrichtigungs-Einstellungen
if [[ ! -f "$CONFIG_FILE" ]]; then
return
fi
source "$CONFIG_FILE"
if [[ "${NOTIFY_ENABLED:-false}" != "true" ]]; then
return
fi
local my_hostname
my_hostname=$(hostname)
local title message
if [[ "$action" == "recovery" ]]; then
title="🔄 AdGuard Shield Watchdog"
message="🔄 AdGuard Shield Watchdog auf ${my_hostname}
---
Der Service war ausgefallen und wurde automatisch neu gestartet.
${detail}"
elif [[ "$action" == "failure" ]]; then
title="🚨 AdGuard Shield Watchdog"
message="🚨 AdGuard Shield Watchdog auf ${my_hostname}
---
Der Service konnte NICHT automatisch neu gestartet werden!
Manuelles Eingreifen erforderlich.
${detail}"
fi
case "${NOTIFY_TYPE:-}" in
discord)
local json_payload
json_payload=$(jq -nc --arg msg "$message" '{content: $msg}')
curl -s -H "Content-Type: application/json" \
-d "$json_payload" \
"$NOTIFY_WEBHOOK_URL" &>/dev/null || true
;;
slack)
local json_payload
json_payload=$(jq -nc --arg msg "$message" '{text: $msg}')
curl -s -H "Content-Type: application/json" \
-d "$json_payload" \
"$NOTIFY_WEBHOOK_URL" &>/dev/null || true
;;
gotify)
curl -s -X POST "$NOTIFY_WEBHOOK_URL" \
-F "title=${title}" \
-F "message=${message}" \
-F "priority=5" &>/dev/null || true
;;
ntfy)
if [[ -n "${NTFY_TOPIC:-}" ]]; then
local ntfy_url="${NTFY_SERVER_URL:-https://ntfy.sh}"
local auth_args=()
if [[ -n "${NTFY_TOKEN:-}" ]]; then
auth_args=(-H "Authorization: Bearer ${NTFY_TOKEN}")
fi
curl -s \
-H "Title: ${title}" \
-H "Priority: ${NTFY_PRIORITY:-5}" \
-H "Tags: warning,watchdog" \
"${auth_args[@]}" \
-d "$message" \
"${ntfy_url}/${NTFY_TOPIC}" &>/dev/null || true
fi
;;
generic)
local json_payload
json_payload=$(jq -nc --arg msg "$message" --arg act "watchdog_${action}" \
'{message: $msg, action: $act}')
curl -s -H "Content-Type: application/json" \
-d "$json_payload" \
"$NOTIFY_WEBHOOK_URL" &>/dev/null || true
;;
esac
}
# ─── Hauptlogik ──────────────────────────────────────────────────────────────
main() {
# Verzeichnis für State-Datei sicherstellen
mkdir -p "$(dirname "$WATCHDOG_STATE_FILE")"
# Prüfen ob der Service aktiv ist
if systemctl is-active --quiet "$SERVICE_NAME"; then
# Service läuft falls vorher ausgefallen war, Status zurücksetzen
if [[ -f "$WATCHDOG_STATE_FILE" ]]; then
rm -f "$WATCHDOG_STATE_FILE"
fi
exit 0
fi
# Service läuft NICHT Recovery versuchen
log "WARN" "Service $SERVICE_NAME ist nicht aktiv starte Recovery..."
# Zähler für fehlgeschlagene Recovery-Versuche
local fail_count=0
if [[ -f "$WATCHDOG_STATE_FILE" ]]; then
fail_count=$(cat "$WATCHDOG_STATE_FILE" 2>/dev/null || echo "0")
fi
# systemd reset-failed damit StartLimit zurückgesetzt wird
systemctl reset-failed "$SERVICE_NAME" 2>/dev/null || true
# Service starten
if systemctl start "$SERVICE_NAME" 2>/dev/null; then
# Kurz warten und prüfen ob er auch wirklich läuft
sleep 3
if systemctl is-active --quiet "$SERVICE_NAME"; then
log "INFO" "Service $SERVICE_NAME erfolgreich neu gestartet (Watchdog Recovery)"
send_watchdog_notification "recovery" "Versuch: $((fail_count + 1))"
rm -f "$WATCHDOG_STATE_FILE"
exit 0
fi
fi
# Start fehlgeschlagen
fail_count=$((fail_count + 1))
echo "$fail_count" > "$WATCHDOG_STATE_FILE"
log "ERROR" "Service $SERVICE_NAME konnte nicht gestartet werden (Fehlversuch: $fail_count)"
# Bei jedem 3. Fehlversuch eine Benachrichtigung senden (Spam vermeiden)
if [[ $((fail_count % 3)) -eq 1 ]]; then
send_watchdog_notification "failure" "Fehlversuche: $fail_count
Letzter Fehler: $(systemctl status "$SERVICE_NAME" 2>&1 | tail -5)"
fi
exit 1
}
main

View File

@@ -0,0 +1,11 @@
[Unit]
Description=AdGuard Shield - Watchdog Timer
Documentation=https://git.techniverse.net/scriptos/adguard-shield
[Timer]
OnBootSec=2min
OnUnitActiveSec=5min
AccuracySec=30s
[Install]
WantedBy=timers.target

View File

@@ -4,7 +4,7 @@ Documentation=https://git.techniverse.net/scriptos/adguard-shield
After=network.target AdGuardHome.service
Wants=AdGuardHome.service
StartLimitBurst=5
StartLimitIntervalSec=60
StartLimitIntervalSec=300
[Service]
Type=simple
@@ -14,7 +14,7 @@ ExecReload=/bin/kill -HUP $MAINPID
# Neustart-Verhalten
Restart=on-failure
RestartSec=10
RestartSec=30
# Sicherheits-Hardening
ProtectSystem=full

View File

@@ -8,7 +8,7 @@
# Lizenz: MIT
###############################################################################
VERSION="v0.7.0"
VERSION="v0.7.1"
set -euo pipefail

15
docs/README.md Normal file
View File

@@ -0,0 +1,15 @@
# Dokumentation
Hier findest du die vollständige Dokumentation zu AdGuard Shield.
## Inhaltsverzeichnis
| Dokument | Beschreibung |
|---|---|
| [Architektur & Funktionsweise](architektur.md) | Überblick über den Systemaufbau, Datenfluss und die internen Komponenten |
| [Befehle & Nutzung](befehle.md) | Alle verfügbaren Befehle des Installers, des Hauptskripts und des Watchdogs |
| [Konfiguration](konfiguration.md) | Beschreibung aller Konfigurationsparameter in `adguard-shield.conf` |
| [Webhook-Benachrichtigungen](benachrichtigungen.md) | Einrichtung von Push-Benachrichtigungen über Telegram, Discord, Gotify u.a. |
| [E-Mail Report](report.md) | Konfiguration des automatischen Statistik-Reports per E-Mail |
| [Update-Anleitung](update.md) | Schritt-für-Schritt-Anleitung zum Aktualisieren einer bestehenden Installation |
| [Tipps & Troubleshooting](tipps-und-troubleshooting.md) | Best Practices, häufige Probleme und deren Lösungen |

View File

@@ -132,13 +132,16 @@ Das ermöglicht:
├── adguard-shield.sh # Haupt-Monitor-Script
├── adguard-shield.conf # Konfiguration (chmod 600)
├── adguard-shield.conf.old # Backup der Konfig nach Update
├── adguard-shield-watchdog.sh # Watchdog Health-Check-Script
├── iptables-helper.sh # iptables Verwaltung
├── external-blocklist-worker.sh # Externer Blocklist-Worker
├── external-whitelist-worker.sh # Externer Whitelist-Worker (DNS-Auflösung)
└── unban-expired.sh # Cron-basiertes Entsperren
/etc/systemd/system/
── adguard-shield.service # systemd Service (Autostart aktiv)
── adguard-shield.service # systemd Service (Autostart aktiv)
├── adguard-shield-watchdog.service # systemd Watchdog-Unit (oneshot)
└── adguard-shield-watchdog.timer # systemd Timer (alle 5 Min.)
/var/lib/adguard-shield/
├── *.ban # State-Dateien aktiver Sperren
@@ -157,8 +160,8 @@ Der Installer (`install.sh`) bietet ein interaktives Menü und folgende Funktion
| Befehl | Beschreibung |
|--------|--------------|
| `install` | Vollständige Neuinstallation (Abhängigkeiten, Dateien, Konfiguration, Service) |
| `update` | Update mit automatischer Konfigurations-Migration und Service-Neustart |
| `install` | Vollständige Neuinstallation (Abhängigkeiten, Dateien, Konfiguration, Service, Watchdog) |
| `update` | Update mit automatischer Konfigurations-Migration, Watchdog-Aktivierung und Service-Neustart |
| `uninstall` | Deinstallation mit optionalem Behalten der Konfiguration |
| `status` | Installationsstatus, Version und Service-Status anzeigen |
| `--help` | Hilfe und Befehlsübersicht |

View File

@@ -42,8 +42,9 @@ Beim Update passiert automatisch:
2. Die bestehende Konfiguration wird als `adguard-shield.conf.old` gesichert
3. Neue Konfigurationsparameter werden automatisch zur bestehenden Konfig hinzugefügt
4. Bestehende Einstellungen bleiben **immer** erhalten
5. Der systemd Service wird per `daemon-reload` neu geladen
6. Der Service wird automatisch neu gestartet (falls er lief)
5. Der systemd Service und Watchdog-Timer werden per `daemon-reload` neu geladen
6. Der Watchdog-Timer wird automatisch aktiviert (falls noch nicht aktiv)
7. Der Service wird automatisch neu gestartet (falls er lief)
### API-Verbindungstest nach Installation
@@ -86,6 +87,31 @@ sudo systemctl disable adguard-shield
> **Hinweis:** Der Service wird bei der Installation automatisch für den Autostart beim Booten aktiviert. Nach einem Update wird der Service automatisch neu gestartet — ein manueller Neustart ist nicht nötig.
## Watchdog (automatischer Health Check)
Der Watchdog prüft alle 5 Minuten ob der Hauptservice läuft und startet ihn bei Bedarf automatisch neu. Er wird als systemd Timer betrieben und bei der Installation automatisch aktiviert.
```bash
# Watchdog-Status
sudo systemctl status adguard-shield-watchdog.timer
# Nächste geplante Ausführung anzeigen
sudo systemctl list-timers adguard-shield-watchdog.timer
# Watchdog aktivieren / deaktivieren
sudo systemctl enable adguard-shield-watchdog.timer
sudo systemctl disable adguard-shield-watchdog.timer
# Watchdog starten / stoppen
sudo systemctl start adguard-shield-watchdog.timer
sudo systemctl stop adguard-shield-watchdog.timer
# Watchdog-Logs anzeigen
sudo journalctl -u adguard-shield-watchdog.service --no-pager -n 20
```
> **Hinweis:** Der Watchdog sendet automatisch Benachrichtigungen (falls `NOTIFY_ENABLED=true`), wenn er den Service wiederbeleben muss oder die Recovery fehlschlägt.
## Monitor — Verwaltungsbefehle
Die folgenden Befehle dienen der **Verwaltung und Diagnose** und können jederzeit ausgeführt werden, auch während der Service läuft:

View File

@@ -116,12 +116,30 @@ Bei Sperren aus der **externen Blocklist** werden Benachrichtigungen separat üb
### Service gestartet
**Überschrift:** ✅ AdGuard Shield
> 🟢 AdGuard Shield v0.7.0 wurde auf dns1 gestartet.
> 🟢 AdGuard Shield v0.7.1 wurde auf dns1 gestartet.
### Service gestoppt
**Überschrift:** 🚨 🛡️ AdGuard Shield
> 🔴 AdGuard Shield v0.7.0 wurde auf dns1 gestoppt.
> 🔴 AdGuard Shield v0.7.1 wurde auf dns1 gestoppt.
### Watchdog — Service wiederhergestellt
**Überschrift:** 🔄 AdGuard Shield Watchdog
> 🔄 AdGuard Shield Watchdog auf dns1
> ---
> Der Service war ausgefallen und wurde automatisch neu gestartet.
> Versuch: 1
### Watchdog — Recovery fehlgeschlagen
**Überschrift:** 🚨 AdGuard Shield Watchdog
> 🚨 AdGuard Shield Watchdog auf dns1
> ---
> Der Service konnte NICHT automatisch neu gestartet werden!
> Manuelles Eingreifen erforderlich.
> Fehlversuche: 1
> Letzter Fehler: (systemd Statusausgabe)
### Sperre (Ban)
**Überschrift:** 🚨 🛡️ AdGuard Shield

View File

@@ -193,6 +193,37 @@ sudo rm -f /var/run/adguard-shield.pid
sudo systemctl start adguard-shield
```
### Service ist ausgefallen und startet nicht mehr
Wenn systemd das Restart-Limit erreicht hat (z.B. `"Start request repeated too quickly"`), hilft der **Watchdog** — er prüft alle 5 Minuten ob der Service läuft und startet ihn automatisch neu.
**Watchdog-Status prüfen:**
```bash
# Timer-Status anzeigen
sudo systemctl status adguard-shield-watchdog.timer
# Letzte Watchdog-Ausführungen anzeigen
sudo systemctl list-timers adguard-shield-watchdog.timer
# Watchdog-Logs prüfen
sudo journalctl -u adguard-shield-watchdog.service --no-pager -n 20
```
**Manuelles Recovery (sofort):**
```bash
# systemd-Fehlerzähler zurücksetzen und Service starten
sudo systemctl reset-failed adguard-shield.service
sudo systemctl start adguard-shield.service
```
**Watchdog nachträglich aktivieren:**
```bash
sudo systemctl enable adguard-shield-watchdog.timer
sudo systemctl start adguard-shield-watchdog.timer
```
> **Hinweis:** Der Watchdog sendet automatisch eine Benachrichtigung (falls `NOTIFY_ENABLED=true`), wenn er den Service wiederbeleben muss oder die Recovery fehlschlägt.
## Update durchführen
```bash
@@ -229,9 +260,13 @@ Oder manuell:
```bash
sudo systemctl stop adguard-shield
sudo systemctl disable adguard-shield
sudo systemctl stop adguard-shield-watchdog.timer
sudo systemctl disable adguard-shield-watchdog.timer
sudo /opt/adguard-shield/iptables-helper.sh remove
sudo rm -rf /opt/adguard-shield
sudo rm -f /etc/systemd/system/adguard-shield.service
sudo rm -f /etc/systemd/system/adguard-shield-watchdog.service
sudo rm -f /etc/systemd/system/adguard-shield-watchdog.timer
sudo systemctl daemon-reload
```

View File

@@ -35,8 +35,9 @@ Das Update-Script macht automatisch folgendes:
2. **Scripts aktualisieren** — Alle `.sh`-Dateien werden nach `/opt/adguard-shield/` kopiert
3. **Konfigurations-Migration** — Neue Parameter werden automatisch zur bestehenden Konfiguration hinzugefügt, bestehende Einstellungen bleiben **unverändert**
4. **Backup erstellen** — Die alte Konfiguration wird als `adguard-shield.conf.old` gesichert
5. **Service aktualisieren** — Die systemd Service-Datei wird aktualisiert und `daemon-reload` ausgeführt
6. **Service neustarten** — Der Service wird automatisch neu gestartet (falls er vorher lief)
5. **Service aktualisieren** — Die systemd Service-Datei und Watchdog-Dateien werden aktualisiert und `daemon-reload` ausgeführt
6. **Watchdog aktivieren** — Der Watchdog-Timer wird automatisch aktiviert (falls noch nicht aktiv)
7. **Service neustarten** — Der Service wird automatisch neu gestartet (falls er vorher lief)
### 3. Neue Parameter prüfen (optional)

View File

@@ -6,7 +6,7 @@
# Lizenz: MIT
###############################################################################
VERSION="v0.7.0"
VERSION="v0.7.1"
set -euo pipefail
@@ -125,6 +125,13 @@ print_help() {
echo -e " ${CYAN}sudo /opt/adguard-shield/report-generator.sh install${NC} # Cron-Job einrichten"
echo -e " ${CYAN}sudo /opt/adguard-shield/report-generator.sh remove${NC} # Cron-Job entfernen"
echo ""
echo -e "${BOLD}Watchdog-Befehle:${NC}"
echo -e " ${CYAN}sudo systemctl status adguard-shield-watchdog.timer${NC} # Watchdog-Status"
echo -e " ${CYAN}sudo systemctl list-timers adguard-shield-watchdog.timer${NC} # Nächste Ausführung"
echo -e " ${CYAN}sudo systemctl enable adguard-shield-watchdog.timer${NC} # Watchdog aktivieren"
echo -e " ${CYAN}sudo systemctl disable adguard-shield-watchdog.timer${NC} # Watchdog deaktivieren"
echo -e " ${CYAN}sudo journalctl -u adguard-shield-watchdog.service${NC} # Watchdog-Logs"
echo ""
echo -e "${BOLD}Voraussetzungen:${NC}"
echo " - Linux Server (Debian/Ubuntu empfohlen)"
echo " - Root-Zugriff (sudo)"
@@ -248,6 +255,7 @@ install_files() {
cp "$SCRIPT_DIR/external-blocklist-worker.sh" "$INSTALL_DIR/"
cp "$SCRIPT_DIR/external-whitelist-worker.sh" "$INSTALL_DIR/"
cp "$SCRIPT_DIR/report-generator.sh" "$INSTALL_DIR/"
cp "$SCRIPT_DIR/adguard-shield-watchdog.sh" "$INSTALL_DIR/"
cp "$SCRIPT_DIR/uninstall.sh" "$INSTALL_DIR/"
# Templates kopieren
@@ -262,6 +270,7 @@ install_files() {
chmod +x "$INSTALL_DIR/external-blocklist-worker.sh"
chmod +x "$INSTALL_DIR/external-whitelist-worker.sh"
chmod +x "$INSTALL_DIR/report-generator.sh"
chmod +x "$INSTALL_DIR/adguard-shield-watchdog.sh"
chmod +x "$INSTALL_DIR/uninstall.sh"
echo -e " ✅ Dateien installiert"
@@ -356,18 +365,22 @@ install_service() {
echo -e "${YELLOW}Installiere systemd Service...${NC}"
cp "$SCRIPT_DIR/adguard-shield.service" "$SERVICE_FILE"
cp "$SCRIPT_DIR/adguard-shield-watchdog.service" /etc/systemd/system/adguard-shield-watchdog.service
cp "$SCRIPT_DIR/adguard-shield-watchdog.timer" /etc/systemd/system/adguard-shield-watchdog.timer
systemctl daemon-reload
echo -e " ✅ Service-Datei installiert"
echo -e " ✅ Service-Dateien installiert (inkl. Watchdog)"
echo ""
# Interaktiv: Autostart beim Booten?
read -rep " Soll AdGuard Shield beim Booten automatisch starten? [J/n]: " autostart
if [[ "${autostart,,}" != "n" ]]; then
systemctl enable adguard-shield.service
echo -e " ✅ Autostart aktiviert"
systemctl enable adguard-shield-watchdog.timer
echo -e " ✅ Autostart aktiviert (inkl. Watchdog-Timer)"
else
systemctl disable adguard-shield.service 2>/dev/null || true
systemctl disable adguard-shield-watchdog.timer 2>/dev/null || true
echo -e " Autostart nicht aktiviert"
echo -e " ${YELLOW}Später aktivieren mit: sudo systemctl enable adguard-shield${NC}"
fi
@@ -500,6 +513,15 @@ print_summary() {
echo " Konfiguration: $INSTALL_DIR/adguard-shield.conf"
echo " Service: adguard-shield.service ($svc_status)"
echo " Autostart: $autostart_status"
# Watchdog-Status
local watchdog_status="deaktiviert"
if systemctl is-active adguard-shield-watchdog.timer &>/dev/null 2>&1; then
watchdog_status="aktiv ✅"
elif systemctl is-enabled adguard-shield-watchdog.timer &>/dev/null 2>&1; then
watchdog_status="aktiviert (Timer nicht gestartet)"
fi
echo " Watchdog: $watchdog_status"
echo " Log-Datei: /var/log/adguard-shield.log"
echo ""
echo " Nützliche Befehle:"
@@ -579,6 +601,15 @@ do_status() {
echo -e " ❌ Konfiguration: fehlt!"
fi
# Watchdog-Status
if systemctl is-active adguard-shield-watchdog.timer &>/dev/null 2>&1; then
echo -e " ✅ Watchdog-Timer: aktiv"
elif systemctl is-enabled adguard-shield-watchdog.timer &>/dev/null 2>&1; then
echo -e " ⚠️ Watchdog-Timer: aktiviert aber nicht gestartet"
else
echo -e " ❌ Watchdog-Timer: nicht installiert/deaktiviert"
fi
echo ""
}
@@ -618,7 +649,8 @@ do_install() {
read -rep " Soll der AdGuard Shield Service jetzt gestartet werden? [J/n]: " start_now
if [[ "${start_now,,}" != "n" ]]; then
systemctl start adguard-shield
echo -e " ✅ Service gestartet"
systemctl start adguard-shield-watchdog.timer 2>/dev/null || true
echo -e " ✅ Service gestartet (inkl. Watchdog-Timer)"
else
echo -e " Service nicht gestartet"
echo -e " ${YELLOW}Später starten mit: sudo systemctl start adguard-shield${NC}"
@@ -651,18 +683,28 @@ do_update() {
# Service-Datei aktualisieren
echo -e "${YELLOW}Aktualisiere systemd Service...${NC}"
cp "$SCRIPT_DIR/adguard-shield.service" "$SERVICE_FILE"
cp "$SCRIPT_DIR/adguard-shield-watchdog.service" /etc/systemd/system/adguard-shield-watchdog.service
cp "$SCRIPT_DIR/adguard-shield-watchdog.timer" /etc/systemd/system/adguard-shield-watchdog.timer
systemctl daemon-reload
echo -e " ✅ Service-Datei aktualisiert"
echo -e " ✅ Service-Dateien aktualisiert (inkl. Watchdog)"
echo ""
# Interaktiv: Autostart beim Booten?
if systemctl is-enabled adguard-shield &>/dev/null; then
echo -e " Autostart ist bereits aktiviert"
# Watchdog-Timer auch aktivieren falls noch nicht aktiv
if ! systemctl is-enabled adguard-shield-watchdog.timer &>/dev/null 2>&1; then
systemctl enable adguard-shield-watchdog.timer
systemctl start adguard-shield-watchdog.timer
echo -e " ✅ Watchdog-Timer aktiviert"
fi
else
read -rep " Soll AdGuard Shield beim Booten automatisch starten? [J/n]: " autostart
if [[ "${autostart,,}" != "n" ]]; then
systemctl enable adguard-shield.service
echo -e " ✅ Autostart aktiviert"
systemctl enable adguard-shield-watchdog.timer
systemctl start adguard-shield-watchdog.timer
echo -e " ✅ Autostart aktiviert (inkl. Watchdog-Timer)"
else
echo -e " Autostart bleibt deaktiviert"
fi

View File

@@ -13,6 +13,8 @@
# INSTALL_DIR ergibt sich aus dem Verzeichnis, in dem dieses Script liegt
INSTALL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SERVICE_FILE="/etc/systemd/system/adguard-shield.service"
WATCHDOG_SERVICE_FILE="/etc/systemd/system/adguard-shield-watchdog.service"
WATCHDOG_TIMER_FILE="/etc/systemd/system/adguard-shield-watchdog.timer"
# Farben
RED='\033[0;31m'
@@ -79,6 +81,16 @@ do_uninstall() {
fi
echo ""
# Watchdog-Timer stoppen und deaktivieren
if systemctl is-active adguard-shield-watchdog.timer &>/dev/null 2>&1; then
systemctl stop adguard-shield-watchdog.timer
echo " ✅ Watchdog-Timer gestoppt"
fi
if systemctl is-enabled adguard-shield-watchdog.timer &>/dev/null 2>&1; then
systemctl disable adguard-shield-watchdog.timer
echo " ✅ Watchdog-Timer deaktiviert"
fi
# Service stoppen und deaktivieren
if systemctl is-active adguard-shield &>/dev/null; then
systemctl stop adguard-shield
@@ -90,9 +102,13 @@ do_uninstall() {
fi
if [[ -f "$SERVICE_FILE" ]]; then
rm -f "$SERVICE_FILE"
systemctl daemon-reload
echo " ✅ Service-Datei entfernt"
fi
rm -f "$WATCHDOG_SERVICE_FILE" "$WATCHDOG_TIMER_FILE"
if [[ -f "$WATCHDOG_SERVICE_FILE" ]] || [[ -f "$WATCHDOG_TIMER_FILE" ]]; then
echo " ✅ Watchdog-Dateien entfernt"
fi
systemctl daemon-reload
# iptables Chain aufräumen
if [[ -f "$INSTALL_DIR/iptables-helper.sh" ]]; then
@@ -108,6 +124,7 @@ do_uninstall() {
rm -f "$INSTALL_DIR/external-blocklist-worker.sh"
rm -f "$INSTALL_DIR/external-whitelist-worker.sh"
rm -f "$INSTALL_DIR/report-generator.sh"
rm -f "$INSTALL_DIR/adguard-shield-watchdog.sh"
rm -f "$INSTALL_DIR/uninstall.sh"
rm -rf "$INSTALL_DIR/templates"
echo " ✅ Scripts entfernt (Konfiguration und Logs behalten)"