From 08b7e0e919152217e92d407a65dc5dd5b4722da9 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 28 Nov 2025 10:34:01 +0100 Subject: [PATCH] Make fix_wt_config.sh executable to ensure proper execution of configuration fixes. --- fix_opt_wt_config.py | 48 ++++++++++++++++++++++++++++++++++++++++++++ fix_opt_wt_config.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100755 fix_opt_wt_config.py create mode 100755 fix_opt_wt_config.sh diff --git a/fix_opt_wt_config.py b/fix_opt_wt_config.py new file mode 100755 index 0000000..2f96a33 --- /dev/null +++ b/fix_opt_wt_config.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +""" +Skript zum Hinzufügen von head-matter in /opt/ypchat/wt_config.xml +um das robots Meta-Tag auf index,follow zu setzen +""" + +import sys +import xml.etree.ElementTree as ET +from datetime import datetime +import shutil + +CONFIG_FILE = "/opt/ypchat/wt_config.xml" +BACKUP_FILE = f"{CONFIG_FILE}.backup.{datetime.now().strftime('%Y%m%d_%H%M%S')}" + +print("=== Backup erstellen ===") +shutil.copy2(CONFIG_FILE, BACKUP_FILE) +print(f"Backup erstellt: {BACKUP_FILE}") + +print("\n=== Parse XML ===") +tree = ET.parse(CONFIG_FILE) +root = tree.getroot() + +print("\n=== Prüfe, ob head-matter bereits existiert ===") +for app in root.findall(".//application"): + if app.find("head-matter") is not None: + print("WARNUNG: existiert bereits!") + sys.exit(1) + +print("\n=== Füge head-matter hinzu ===") +for app in root.findall(".//application"): + head_matter = ET.SubElement(app, "head-matter") + meta = ET.SubElement(head_matter, "meta") + meta.set("name", "robots") + meta.set("content", "index,follow") + print(f"Hinzugefügt zu application path='{app.get('path', '/')}'") + +print("\n=== Speichere geänderte Konfiguration ===") +tree.write(CONFIG_FILE, encoding="UTF-8", xml_declaration=True) + +print("\n=== Geänderte Konfiguration anzeigen ===") +with open(CONFIG_FILE, 'r') as f: + for line in f: + if 'head-matter' in line or 'robots' in line: + print(line.rstrip()) + +print("\n=== Fertig! ===") +print("Bitte Service neu starten: sudo systemctl restart ypchat.service") + diff --git a/fix_opt_wt_config.sh b/fix_opt_wt_config.sh new file mode 100755 index 0000000..6bb541b --- /dev/null +++ b/fix_opt_wt_config.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Skript zum Hinzufügen von head-matter in /opt/ypchat/wt_config.xml +# um das robots Meta-Tag auf index,follow zu setzen + +CONFIG_FILE="/opt/ypchat/wt_config.xml" +BACKUP_FILE="${CONFIG_FILE}.backup.$(date +%Y%m%d_%H%M%S)" + +echo "=== Backup erstellen ===" +sudo cp "$CONFIG_FILE" "$BACKUP_FILE" +echo "Backup erstellt: $BACKUP_FILE" + +echo -e "\n=== Prüfe, ob head-matter bereits existiert ===" +if sudo grep -q "" "$CONFIG_FILE"; then + echo "WARNUNG: existiert bereits!" + exit 1 +fi + +echo -e "\n=== Füge head-matter hinzu ===" +# Erstelle temporäre Datei mit head-matter +TEMP_FILE=$(mktemp) +sudo cat "$CONFIG_FILE" > "$TEMP_FILE" + +# Füge head-matter vor ein +sudo sed -i 's|| \n \n \n \n |' "$TEMP_FILE" + +sudo mv "$TEMP_FILE" "$CONFIG_FILE" +sudo chmod 644 "$CONFIG_FILE" + +echo -e "\n=== Geänderte Konfiguration anzeigen ===" +sudo grep -A 3 "head-matter" "$CONFIG_FILE" + +echo -e "\n=== Service neu starten ===" +sudo systemctl restart ypchat.service +sleep 3 + +echo -e "\n=== Service-Status ===" +sudo systemctl status ypchat.service --no-pager | grep -E "Active|since" | head -2 + +echo -e "\n=== Test mit curl ===" +curl -s -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \ + https://www.ypchat.net/ | grep -i "meta.*robots" | head -1 + +echo -e "\n=== Test mit Googlebot ===" +curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" \ + https://www.ypchat.net/ | grep -i "meta.*robots" | head -1 + +echo -e "\n=== Fertig! ===" +