Files
singlechat/fix_opt_wt_config.sh

49 lines
1.6 KiB
Bash
Executable File

#!/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 "<head-matter>" "$CONFIG_FILE"; then
echo "WARNUNG: <head-matter> 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 </application> ein
sudo sed -i 's|</application>| <!-- Configure <head> matter -->\n <head-matter>\n <meta name="robots" content="index,follow" />\n </head-matter>\n </application>|' "$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! ==="