147 lines
4.8 KiB
Bash
147 lines
4.8 KiB
Bash
#!/usr/bin/env bash
|
|
# =============================================================
|
|
# test_setup.sh — Überprüft die Installation Schritt für Schritt
|
|
# Ausführen nach install.sh: bash scripts/test_setup.sh
|
|
# =============================================================
|
|
|
|
set -euo pipefail
|
|
|
|
# Farben
|
|
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; CYAN='\033[0;36m'; NC='\033[0m'
|
|
ok() { echo -e "${GREEN} [✓] $*${NC}"; }
|
|
fail() { echo -e "${RED} [✗] $*${NC}"; FAILED=$((FAILED+1)); }
|
|
info() { echo -e "${CYAN} [i] $*${NC}"; }
|
|
|
|
FAILED=0
|
|
|
|
echo ""
|
|
echo -e "${CYAN}══════════════════════════════════════════════════${NC}"
|
|
echo -e "${CYAN} OpenClaw mailbox.org Kalender+Aufgaben — Selbsttest${NC}"
|
|
echo -e "${CYAN}══════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
# --- 1. Binaries vorhanden? ---
|
|
echo "▶ 1. Programm-Verfügbarkeit"
|
|
for bin in vdirsyncer khal todo python3; do
|
|
if command -v "$bin" &>/dev/null; then
|
|
ok "$bin → $(command -v $bin)"
|
|
else
|
|
fail "$bin nicht gefunden — install.sh ausführen"
|
|
fi
|
|
done
|
|
|
|
# --- 2. Konfigurationsdateien ---
|
|
echo ""
|
|
echo "▶ 2. Konfigurationsdateien"
|
|
declare -A CONFIGS=(
|
|
["vdirsyncer"]="$HOME/.config/vdirsyncer/config"
|
|
["khal"]="$HOME/.config/khal/config"
|
|
["todoman"]="$HOME/.config/todoman/config.cfg"
|
|
)
|
|
for name in "${!CONFIGS[@]}"; do
|
|
path="${CONFIGS[$name]}"
|
|
if [[ -f "$path" ]]; then
|
|
ok "$name → $path"
|
|
else
|
|
fail "$name-Config fehlt: $path"
|
|
fi
|
|
done
|
|
|
|
# --- 3. Berechtigungen vdirsyncer-Config (enthält Passwort) ---
|
|
echo ""
|
|
echo "▶ 3. Sicherheit"
|
|
VDIR_CONF="$HOME/.config/vdirsyncer/config"
|
|
if [[ -f "$VDIR_CONF" ]]; then
|
|
PERMS=$(stat -c "%a" "$VDIR_CONF")
|
|
if [[ "$PERMS" == "600" ]]; then
|
|
ok "vdirsyncer config Berechtigungen: $PERMS (korrekt)"
|
|
else
|
|
fail "vdirsyncer config Berechtigungen: $PERMS (sollte 600 sein) → chmod 600 $VDIR_CONF"
|
|
fi
|
|
fi
|
|
|
|
# Prüfe ob Klartext-Passwort in Config steht
|
|
if grep -q 'password.*=.*"[^$]' "$VDIR_CONF" 2>/dev/null; then
|
|
info "Passwort in Plaintext erkannt — Erwäge pass(1) oder python-keyring als Alternative"
|
|
fi
|
|
|
|
# --- 4. Sync-Verzeichnisse ---
|
|
echo ""
|
|
echo "▶ 4. Sync-Verzeichnisse"
|
|
for dir in \
|
|
"$HOME/.local/share/vdirsyncer/status" \
|
|
"$HOME/.local/share/vdirsyncer/calendars" \
|
|
"$HOME/.local/share/vdirsyncer/tasks"; do
|
|
if [[ -d "$dir" ]]; then
|
|
COUNT=$(find "$dir" -name "*.ics" 2>/dev/null | wc -l)
|
|
ok "$dir (${COUNT} .ics Dateien)"
|
|
else
|
|
fail "Verzeichnis fehlt: $dir"
|
|
fi
|
|
done
|
|
|
|
# --- 5. vdirsyncer Verbindungstest ---
|
|
echo ""
|
|
echo "▶ 5. vdirsyncer — Verbindungstest"
|
|
info "Führe 'vdirsyncer sync' aus (Timeout: 30s)..."
|
|
if timeout 30 vdirsyncer sync 2>&1 | tail -5; then
|
|
ok "vdirsyncer sync erfolgreich"
|
|
else
|
|
fail "vdirsyncer sync fehlgeschlagen — Zugangsdaten und Netzwerk prüfen"
|
|
fi
|
|
|
|
# --- 6. khal-Test ---
|
|
echo ""
|
|
echo "▶ 6. khal — Termine heute"
|
|
if khal list --format "{start-time} {title}" today today 2>/dev/null; then
|
|
ok "khal list ausgeführt"
|
|
else
|
|
fail "khal list fehlgeschlagen — khal.conf prüfen"
|
|
fi
|
|
|
|
# --- 7. todoman-Test ---
|
|
echo ""
|
|
echo "▶ 7. todoman — Aufgabenliste"
|
|
if todo list 2>/dev/null; then
|
|
ok "todo list ausgeführt"
|
|
else
|
|
fail "todo list fehlgeschlagen — todoman.conf prüfen"
|
|
fi
|
|
|
|
# --- 8. systemd-Timer ---
|
|
echo ""
|
|
echo "▶ 8. systemd Timer"
|
|
if systemctl --user is-active vdirsyncer-sync.timer &>/dev/null; then
|
|
ok "vdirsyncer-sync.timer: aktiv"
|
|
NEXT=$(systemctl --user list-timers vdirsyncer-sync.timer --no-legend 2>/dev/null | awk '{print $1, $2}')
|
|
info "Nächster Sync: $NEXT"
|
|
else
|
|
fail "vdirsyncer-sync.timer nicht aktiv → systemctl --user enable --now vdirsyncer-sync.timer"
|
|
fi
|
|
|
|
# --- 9. Log-Datei ---
|
|
echo ""
|
|
echo "▶ 9. Log-Datei"
|
|
LOG="/var/log/openclaw-mailbox-cal/sync.log"
|
|
if [[ -f "$LOG" ]]; then
|
|
SIZE=$(du -sh "$LOG" | cut -f1)
|
|
ok "Log vorhanden: $LOG ($SIZE)"
|
|
info "Letzte 5 Zeilen:"
|
|
tail -5 "$LOG" | sed 's/^/ /'
|
|
else
|
|
info "Log noch nicht vorhanden (wird beim ersten Sync erstellt)"
|
|
fi
|
|
|
|
# --- Zusammenfassung ---
|
|
echo ""
|
|
echo -e "${CYAN}══════════════════════════════════════════════════${NC}"
|
|
if [[ $FAILED -eq 0 ]]; then
|
|
echo -e "${GREEN} Alle Tests bestanden! Setup ist korrekt.${NC}"
|
|
else
|
|
echo -e "${RED} $FAILED Test(s) fehlgeschlagen — siehe Details oben.${NC}"
|
|
fi
|
|
echo -e "${CYAN}══════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
exit $FAILED
|