claude-vault/scripts/setup-cron.sh
2026-02-04 22:35:40 +01:00

111 lines
3.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Richtet alle automatischen Wartungs-Jobs ein
# WICHTIG: Einmalig ausführen, dann via Cron automatisch
set -e
VAULT="$HOME/Work/claude-vault"
echo "⚙️ Richte Cron-Jobs für Claude-Vault ein..."
echo ""
# Prüfe ob Scripts existieren und ausführbar sind
SCRIPTS=(
"weekly-health-check.sh"
"analyze-skill-usage.sh"
"detect-skill-proposals.sh"
"sync-project-memory.sh"
"update-dashboard.sh"
)
echo "🔍 Prüfe Scripts..."
for script in "${SCRIPTS[@]}"; do
SCRIPT_PATH="$VAULT/scripts/$script"
if [ ! -f "$SCRIPT_PATH" ]; then
echo " ❌ Fehlt: $script"
exit 1
fi
if [ ! -x "$SCRIPT_PATH" ]; then
echo " 🔧 Mache ausführbar: $script"
chmod +x "$SCRIPT_PATH"
else
echo " ✅ OK: $script"
fi
done
echo ""
echo "📋 Sichere aktuelle Crontab..."
crontab -l > /tmp/crontab.backup 2>/dev/null || echo "# Neue Crontab" > /tmp/crontab.backup
# Prüfe ob Claude-Vault Cron-Jobs bereits existieren
if grep -q "# Claude-Vault Automatisierung" /tmp/crontab.backup; then
echo "⚠️ Cron-Jobs bereits installiert!"
echo ""
echo "Möchtest du die Cron-Jobs neu installieren? (y/N)"
read -r response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
echo "Abgebrochen."
rm /tmp/crontab.backup
exit 0
fi
# Entferne alte Claude-Vault Einträge
echo "🗑️ Entferne alte Cron-Jobs..."
sed -i.bak '/# Claude-Vault Automatisierung/,/^$/d' /tmp/crontab.backup
fi
echo ""
echo " Füge neue Cron-Jobs hinzu..."
# Füge neue Cron-Jobs hinzu
cat >> /tmp/crontab.backup <<EOF
# Claude-Vault Automatisierung
# Auto-generiert via setup-cron.sh am $(date +%Y-%m-%d)
# Montag 09:00 - Weekly Health Check + Skill-Usage-Matrix
0 9 * * 1 $VAULT/scripts/weekly-health-check.sh >> $VAULT/memory/log/cron.log 2>&1 && $VAULT/scripts/analyze-skill-usage.sh >> $VAULT/memory/log/cron.log 2>&1
# Montag 10:00 - Skill-Proposal Detection
0 10 * * 1 $VAULT/scripts/detect-skill-proposals.sh >> $VAULT/memory/log/cron.log 2>&1
# Täglich 20:00 - Projekt-Memory Sync
0 20 * * * $VAULT/scripts/sync-project-memory.sh >> $VAULT/memory/log/cron.log 2>&1
# Täglich 21:00 - Dashboard Update
0 21 * * * $VAULT/scripts/update-dashboard.sh >> $VAULT/memory/log/cron.log 2>&1
EOF
# Crontab installieren
echo ""
echo "💾 Installiere Crontab..."
crontab /tmp/crontab.backup
echo ""
echo "✅ Cron-Jobs erfolgreich installiert!"
echo ""
echo "📅 Zeitplan:"
echo " - Montag 09:00: Health Check + Skill-Usage-Matrix"
echo " - Montag 10:00: Skill-Proposal Detection"
echo " - Täglich 20:00: Projekt-Memory Sync"
echo " - Täglich 21:00: Dashboard Update"
echo ""
echo "🔍 Prüfe Installation:"
echo " crontab -l"
echo ""
echo "📝 Logs:"
echo " tail -f $VAULT/memory/log/cron.log"
echo ""
echo "🗑️ Deinstallieren:"
echo " crontab -e # Manuell Claude-Vault Sektion löschen"
# Erstelle Cron-Log-File falls nicht vorhanden
touch "$VAULT/memory/log/cron.log"
echo ""
echo "Tipp: Teste Scripts manuell bevor Cron läuft:"
echo " $VAULT/scripts/weekly-health-check.sh"
echo " $VAULT/scripts/analyze-skill-usage.sh"