From 4b674c7c600b2eb975ce494edd840cdd54c2a263 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 28 Nov 2025 10:46:27 +0100 Subject: [PATCH] Ensure fix_wt_config.sh is executable and properly configured for improved execution of configuration tasks. --- add_head_matter_global.py | 62 ++++++++++++++++++++++++++++++++ restore_progressive_bootstrap.sh | 5 +++ 2 files changed, 67 insertions(+) create mode 100755 add_head_matter_global.py create mode 100755 restore_progressive_bootstrap.sh diff --git a/add_head_matter_global.py b/add_head_matter_global.py new file mode 100755 index 0000000..b014077 --- /dev/null +++ b/add_head_matter_global.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +""" +Füge head-matter in die globale /etc/wt/wt_config.xml ein +für application-settings location="*" +""" + +import sys +import xml.etree.ElementTree as ET +from datetime import datetime +import shutil + +CONFIG_FILE = "/etc/wt/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=== Suche application-settings location='*' ===") +app_settings = None +for settings in root.findall(".//application-settings"): + if settings.get("location") == "*": + app_settings = settings + break + +if app_settings is None: + print("FEHLER: application-settings location='*' nicht gefunden!") + sys.exit(1) + +print(f"Gefunden: application-settings location='*'") + +print("\n=== Prüfe, ob head-matter bereits existiert ===") +if app_settings.find("head-matter") is not None: + print("WARNUNG: existiert bereits!") + sys.exit(1) + +print("\n=== Füge head-matter hinzu ===") +head_matter = ET.SubElement(app_settings, "head-matter") +meta = ET.SubElement(head_matter, "meta") +meta.set("name", "robots") +meta.set("content", "index,follow") +print("Hinzugefügt zu application-settings location='*'") + +print("\n=== Speichere geänderte Konfiguration ===") +# Formatierung verbessern +ET.indent(tree, space=" ") +tree.write(CONFIG_FILE, encoding="UTF-8", xml_declaration=True) + +print("\n=== Geänderte Konfiguration anzeigen ===") +with open(CONFIG_FILE, 'r') as f: + lines = f.readlines() + for i, line in enumerate(lines, 1): + if 'head-matter' in line or ('robots' in line and i < 20): + print(f"{i}: {line.rstrip()}") + +print("\n=== Fertig! ===") +print("Bitte Service neu starten: sudo systemctl restart ypchat.service") + diff --git a/restore_progressive_bootstrap.sh b/restore_progressive_bootstrap.sh new file mode 100755 index 0000000..40157e5 --- /dev/null +++ b/restore_progressive_bootstrap.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Stelle progressive-bootstrap wieder auf true zurück +sudo sed -i 's|false|true|' /etc/wt/wt_config.xml +echo "progressive-bootstrap wieder auf true gesetzt" +sudo grep -n "progressive-bootstrap" /etc/wt/wt_config.xml