homelab importiert jetzt alle Server aus Mobaxterm Datei

This commit is contained in:
2025-06-14 09:27:13 +02:00
parent a71807d3b6
commit 4af61e614b

View File

@@ -1,18 +1,28 @@
#!/bin/bash
rm serverliste.csv
wget http://fileserver.fritz.box/Mobaxterm/Homelab.mxtsessions
# Eingabedatei
INPUT_FILE="Homelab.mxtsessions"
# Ausgabedatei
OUTPUT_FILE="serverliste.csv"
# Kopfzeile der CSV schreiben
# Kopfzeile der CSV-Datei
echo "Name,Adresse / Host" > "$OUTPUT_FILE"
# Daten extrahieren und formatieren
grep -oP '^[^=]+=#109#0%[^%]+' "$INPUT_FILE" | while IFS= read -r line; do
name=$(echo "$line" | cut -d'=' -f1 | sed 's/.*\\n//')
host=$(echo "$line" | cut -d'%' -f2)
echo "$name,$host" >> "$OUTPUT_FILE"
done
# Alle Zeilen in Bookmarks-Abschnitten durchsuchen
awk '
/^\[Bookmarks/ { in_section=1; next }
/^\[/ && !/^\[Bookmarks/ { in_section=0 }
in_section && /=#109#0%/ {
split($0, parts, "=")
name = parts[1]
split(parts[2], details, "%")
host = details[2]
gsub(/.*\\n/, "", name)
print name "," host
}
' "$INPUT_FILE" >> "$OUTPUT_FILE"
echo "Export abgeschlossen: $OUTPUT_FILE"