Make fix_wt_config.sh executable to ensure proper execution of configuration fixes.
This commit is contained in:
48
fix_opt_wt_config.py
Executable file
48
fix_opt_wt_config.py
Executable file
@@ -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: <head-matter> 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")
|
||||
|
||||
Reference in New Issue
Block a user