Files
homelab-infra/services/posture-check/unraid-user-scripts.md
2026-05-27 06:38:57 +02:00

105 lines
2.6 KiB
Markdown

# Unraid User Scripts fuer Posture-Checks
Host-Repo-Pfad:
```text
/mnt/user/services/homelab-infra
```
## `posture-check-at-start`
Zeit: Array Start.
```bash
#!/bin/bash
bash /mnt/user/services/homelab-infra/services/posture-check/posture-check.sh
```
## `posture-check-hourly`
Zeit: stuendlich bei Minute 17, Cron `17 * * * *`.
```bash
#!/bin/bash
bash /mnt/user/services/homelab-infra/services/posture-check/posture-check.sh
```
## `cert-token-check-daily`
Zeit: taeglich 06:10, Cron `10 6 * * *`.
```bash
#!/bin/bash
bash /mnt/user/services/homelab-infra/services/posture-check/cert-token-check.sh
```
## `compose-runtime-drift-daily`
Zeit: taeglich 06:20, Cron `20 6 * * *`.
```bash
#!/bin/bash
bash /mnt/user/services/homelab-infra/services/posture-check/compose-runtime-drift.sh
```
## `prometheus-textfile-export-15min`
Zeit: alle 15 Minuten, Cron `*/15 * * * *`.
Zweck:
- Borg-Backup-Frische fuer Prometheus sichtbar machen
- kritische Container als explizite 0/1-Metrik exportieren
- Grundlage fuer `HomelabBorgBackupStale`, `HomelabBorgLastJobFailed` und `HomelabCriticalContainerDown`
```bash
#!/bin/bash
bash /mnt/user/services/homelab-infra/services/posture-check/export-prometheus-textfile.sh
```
Ziel-Datei:
```text
/mnt/user/services/posture-check/textfile/homelab.prom
```
## `homelab-operations-report-daily`
Zeit: taeglich nach Borg und den Morgenchecks, z. B. 07:30, Cron `30 7 * * *`.
Voraussetzung: SMTP-Passwort liegt **nicht im Repo**, sondern auf dem Host:
```bash
mkdir -p /mnt/user/appdata/secrets
chmod 700 /mnt/user/appdata/secrets
printf '%s' 'SMTP_PASSWORT_HIER_EINTRAGEN' > /mnt/user/appdata/secrets/homelab_smtp_password.txt
chmod 600 /mnt/user/appdata/secrets/homelab_smtp_password.txt
```
User Script:
```bash
#!/bin/bash
SEND_MAIL=1 \
MAIL_MODE=always \
MAIL_FROM="michideheld@gmx.de" \
MAIL_TO="Mi.Kaleschke@gmx.de" \
SMTP_HOST="smtp.gmx.net" \
SMTP_PORT="587" \
SMTP_USER="michideheld@gmx.de" \
SMTP_PASS_FILE="/mnt/user/appdata/secrets/homelab_smtp_password.txt" \
bash /mnt/user/services/homelab-infra/services/posture-check/daily-status-report.sh
```
## `docker-critical-events-at-start`
Zeit: Array Start. Dieser Job startet einen Hintergrund-Watcher und beendet sich sofort.
```bash
#!/bin/bash
ps -ef | grep -F -- "docker events --filter event=die --filter event=oom --filter event=kill" | grep -v grep >/dev/null && exit 0
mkdir -p /mnt/user/services/posture-check
nohup bash /mnt/user/services/homelab-infra/services/posture-check/docker-critical-events.sh >/mnt/user/services/posture-check/docker-critical-events.out 2>&1 </dev/null &
exit 0
```