50 lines
1.3 KiB
Bash
50 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
echo "📦 Installiere Temp Cleanup System..."
|
|
|
|
# 🧠 Basisverzeichnis bestimmen
|
|
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# 🔍 Prüfen wo wir sind
|
|
if [[ -f "$BASE_DIR/cleanup_temp.sh" ]]; then
|
|
# install.sh liegt in temp-cleanup/
|
|
SCRIPT_DIR="$BASE_DIR"
|
|
elif [[ -f "$BASE_DIR/temp-cleanup/cleanup_temp.sh" ]]; then
|
|
# install.sh liegt im Repo-Root
|
|
SCRIPT_DIR="$BASE_DIR/temp-cleanup"
|
|
else
|
|
echo "❌ cleanup_temp.sh nicht gefunden!"
|
|
exit 1
|
|
fi
|
|
|
|
SERVICE_FILE="$SCRIPT_DIR/systemd/cleanup-temp.service"
|
|
SCRIPT_TARGET="$SCRIPT_DIR/cleanup_temp.sh"
|
|
|
|
SYSTEMD_USER_DIR="$HOME/.config/systemd/user"
|
|
TARGET_SERVICE="$SYSTEMD_USER_DIR/cleanup-temp.service"
|
|
LOG_FILE="$HOME/cleanup_temp.log"
|
|
|
|
echo "📁 Script gefunden unter: $SCRIPT_TARGET"
|
|
|
|
# 🔐 Script ausführbar machen
|
|
chmod +x "$SCRIPT_TARGET"
|
|
|
|
# 📁 systemd user dir sicherstellen
|
|
mkdir -p "$SYSTEMD_USER_DIR"
|
|
|
|
# 📄 Service installieren
|
|
echo "📄 Installiere systemd Service..."
|
|
cp "$SERVICE_FILE" "$TARGET_SERVICE"
|
|
|
|
# 🔄 systemd reload
|
|
echo "🔄 Reload systemd..."
|
|
systemctl --user daemon-reload
|
|
|
|
# ▶️ Service aktivieren + starten
|
|
systemctl --user enable cleanup-temp.service || true
|
|
systemctl --user restart cleanup-temp.service || true
|
|
|
|
echo "📜 Logfile: $LOG_FILE"
|
|
echo "✅ Installation abgeschlossen!" |