v0.5.0 – Clownfischserver HomeIP Auto-Update: myfritz Automatik für SSH (5-Min Cron)

Features:
- install.sh: Frage in Step 4 ob myfritz-Adresse für Auto-SSH-Freigabe genutzt werden soll
- clownfischserver-homeip-updater.sh: DNS-Auflösung + UFW-Update (alle 5 Min via Cron)
- .env-Variable: CLOWNFISCHSERVER_HOME_IP_DOMAIN für myfritz-Adresse
- State-File tracking zur Vermeidung unnötiger UFW-Updates
- Logging: /var/log/clownfischserver-homeip.log
- Dokumentation: scripts/README-HOMEIP.md + CLOWNFISCHSERVER.md update

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 23:28:36 +02:00
co-authored by Claude Haiku 4.5
commit eff7d0d98b
23 changed files with 4143 additions and 0 deletions
+114
View File
@@ -0,0 +1,114 @@
#!/usr/bin/env python3
"""
🐠 Clownfischserver – Boot Notification
Sends a Telegram message after server boot with service status.
Author: Mehlzoerwer-Claude (https://github.com/mehlzoerwer-claude)
License: GPL-3.0 – Keep it open. Always.
Repo: https://github.com/mehlzoerwer-claude/clownfischserver
"""
import os
import subprocess
import sys
from datetime import datetime
from dotenv import load_dotenv
import requests
# Load .env
INSTALL_DIR = os.getenv("INSTALL_DIR", "/opt/clownfischserver")
load_dotenv(os.path.join(INSTALL_DIR, "config", ".env"))
BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
CHAT_ID = os.getenv("TELEGRAM_CHAT_ID")
SERVICES = ["clownfisch", "ollama", "ufw", "ssh", "cron"]
def get_service_status(name: str) -> str:
"""Check if a systemd service is active."""
try:
result = subprocess.run(
["systemctl", "is-active", name],
capture_output=True, text=True, timeout=5
)
status = result.stdout.strip()
if status == "active":
return "✅"
elif status == "inactive":
return "⚪"
else:
return "❌"
except Exception:
return "❓"
def get_uptime() -> str:
"""Get system uptime."""
try:
result = subprocess.run(
["uptime", "-p"], capture_output=True, text=True, timeout=5
)
return result.stdout.strip()
except Exception:
return "unbekannt"
def get_memory() -> str:
"""Get memory usage."""
try:
result = subprocess.run(
["free", "-h", "--si"], capture_output=True, text=True, timeout=5
)
for line in result.stdout.splitlines():
if line.startswith("Mem:"):
parts = line.split()
return f"{parts[2]} / {parts[1]}"
except Exception:
pass
return "unbekannt"
def send_message(text: str):
"""Send Telegram message."""
if not BOT_TOKEN or not CHAT_ID:
print("ERROR: Token oder Chat-ID fehlt in .env")
sys.exit(1)
try:
requests.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={"chat_id": CHAT_ID, "text": text, "parse_mode": "Markdown"},
timeout=10
)
except Exception as e:
print(f"Telegram Fehler: {e}")
sys.exit(1)
def main():
zeit = datetime.now().strftime("%H:%M:%S")
datum = datetime.now().strftime("%d.%m.%Y")
# Build service status list
status_lines = []
for svc in SERVICES:
icon = get_service_status(svc)
status_lines.append(f" {icon} {svc}")
uptime = get_uptime()
memory = get_memory()
msg = (
f"🐠 *Server gestartet!*\n\n"
f"Zeit: {datum} {zeit}\n"
f"Uptime: {uptime}\n"
f"RAM: {memory}\n\n"
f"*Dienste:*\n" +
"\n".join(status_lines)
)
send_message(msg)
print(f"Boot notification sent at {datum} {zeit}")
if __name__ == "__main__":
main()