Files

60 lines
1.7 KiB
Bash
Raw Permalink 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
# ============================================================
# Installation auf ebesch-docker (192.168.252.10)
# Ausführen als root: bash install.sh
# ============================================================
set -e
INSTALL_DIR="/opt/homematic-presence"
CRON_FILE="/etc/cron.d/homematic-presence"
VENV_DIR="$INSTALL_DIR/venv"
echo "=== HomeMatic Anwesenheitserkennung Installation ==="
# Verzeichnis anlegen
mkdir -p "$INSTALL_DIR"
cp presence_check.py "$INSTALL_DIR/"
# Config nur kopieren wenn noch nicht vorhanden (Passwörter schützen)
if [ ! -f "$INSTALL_DIR/config.ini" ]; then
cp config.ini "$INSTALL_DIR/"
echo "config.ini kopiert bitte MACs eintragen!"
else
echo "config.ini existiert bereits nicht überschrieben."
fi
# Python venv + requests installieren
python3 -m venv "$VENV_DIR"
"$VENV_DIR/bin/pip" install --quiet --upgrade requests
# Cronjob: jede Minute
cat > "$CRON_FILE" << EOF
# HomeMatic Anwesenheitserkennung via MikroTik CAPsMAN
# Läuft jede Minute auf ebesch-docker
SHELL=/bin/bash
* * * * * root $VENV_DIR/bin/python3 $INSTALL_DIR/presence_check.py >> /var/log/homematic-presence.log 2>&1
EOF
chmod 644 "$CRON_FILE"
echo "Cronjob installiert: $CRON_FILE"
# Log-Rotation
cat > /etc/logrotate.d/homematic-presence << EOF
/var/log/homematic-presence.log {
daily
rotate 7
compress
missingok
notifempty
}
EOF
echo ""
echo "=== Installation abgeschlossen ==="
echo ""
echo "NÄCHSTE SCHRITTE:"
echo " 1. MAC-Adressen in $INSTALL_DIR/config.ini eintragen"
echo " (iPhone → Einstellungen → WLAN → ⓘ → WLAN-Adresse)"
echo " 2. Test: $VENV_DIR/bin/python3 $INSTALL_DIR/presence_check.py --dry-run --verbose"
echo " 3. Logfile: tail -f /var/log/homematic-presence.log"