diff --git a/osmtool.sh b/osmtool.sh index ca68166..819b7b6 100644 --- a/osmtool.sh +++ b/osmtool.sh @@ -1,8 +1,62 @@ #!/bin/bash +#?────────────────────────────────────────────────────────────────────────────────────────── +#* Debug in log Datei +#! ACHTUNG das loggen speichert alles auch vertrauliche Daten. +#?────────────────────────────────────────────────────────────────────────────────────────── + +#* Debug-Log-System +# 1. Logging ein/aus schalten + +# LOG_ENABLED=true # Logging ist AKTIV (standard) + LOG_ENABLED=false # Logging ist AUS + + +# 2. Alte Log-Datei löschen + + OLD_LOG_DEL=true # Löscht alte Log-Datei vor Start (standard) +# OLD_LOG_DEL=false # Behält alte Log-Datei und fügt neue Einträge an + + +# 3. Log-Datei Name und Ort + + DEBUG_LOG="osmtool_debug.log" # Speicherort der Log-Datei + + +# Logdatei vorbereiten +if $LOG_ENABLED; then + if $OLD_LOG_DEL; then + rm "$DEBUG_LOG" 2>/dev/null + fi + touch "$DEBUG_LOG" 2>/dev/null || echo "Kann Logdatei nicht erstellen" >&2 +fi + +# Verbesserte Funktion zum Entfernen von ANSI-Codes +clean_ansi() { + echo -e "$1" | sed -E 's/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g' +} + +# Log-Funktion +log() { + local message="$1" + local level="${2:-INFO}" + timestamp=$(date "+%Y-%m-%d %H:%M:%S") + + # Zur Konsole (mit Farben) + echo -e "$message" + + # Zur Logdatei (ohne Farbcodes) + if $LOG_ENABLED; then + clean_message=$(clean_ansi "$message") + echo "[${timestamp}] [${level}] ${clean_message}" >> "$DEBUG_LOG" + fi +} + #?────────────────────────────────────────────────────────────────────────────────────────── #* Informationen Kopfzeile #?────────────────────────────────────────────────────────────────────────────────────────── + +# Quelle: # https://github.com/ManfredAabye/opensimMULTITOOLS-II/blob/main/osmtool.sh tput reset # Bildschirmausgabe loeschen inklusive dem Scrollbereich. @@ -11,11 +65,11 @@ SCRIPTNAME="opensimMULTITOOL II" #testmodus=1 # Testmodus: 1=aktiviert, 0=deaktiviert # Versionsnummer besteht aus: Jahr.Monat.Funktionsanzahl.Eigentliche_Version -VERSION="V25.5.84.342" -echo -e "\e[36m$SCRIPTNAME\e[0m $VERSION" +VERSION="V25.5.84.348" +log "\e[36m$SCRIPTNAME\e[0m $VERSION" echo "Dies ist ein Tool welches der Verwaltung von OpenSim Servern dient." echo "Bitte beachten Sie, dass die Anwendung auf eigene Gefahr und Verantwortung erfolgt." -echo -e "\e[33mZum Abbrechen bitte STRG+C oder CTRL+C drücken.\e[0m" +log "\e[33mZum Abbrechen bitte STRG+C oder CTRL+C drücken.\e[0m" echo " " #?────────────────────────────────────────────────────────────────────────────────────────── @@ -71,8 +125,8 @@ function blankline() { sleep 0.5; echo " ";} SCRIPT_DIR="$(dirname "$(realpath "$0")")" cd "$SCRIPT_DIR" || exit 1 system_ip=$(hostname -I | awk '{print $1}') -echo -e "${COLOR_LABEL}Das Arbeitsverzeichnis ist:${COLOR_RESET} ${COLOR_VALUE}$SCRIPT_DIR${COLOR_RESET}" -echo -e "${COLOR_LABEL}Ihre IP Adresse ist:${COLOR_RESET} ${COLOR_VALUE}$system_ip${COLOR_RESET}" +log "${COLOR_LABEL}Das Arbeitsverzeichnis ist:${COLOR_RESET} ${COLOR_VALUE}$SCRIPT_DIR${COLOR_RESET}" +log "${COLOR_LABEL}Ihre IP Adresse ist:${COLOR_RESET} ${COLOR_VALUE}$system_ip${COLOR_RESET}" blankline # Soll im Hypergrid Modus gearbeitet werden oder in einem Geschlossenen Grid? @@ -87,12 +141,12 @@ function hypergrid() { # Prüfen ob Robust.HG.ini existiert if [[ ! -f "$robust_dir/Robust.HG.ini" ]]; then - echo -e "${COLOR_BAD}FEHLER: Robust.HG.ini nicht gefunden in $robust_dir${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Robust.HG.ini nicht gefunden in $robust_dir${COLOR_RESET}" >&2 return 1 fi cp "$robust_dir/Robust.HG.ini" "$robust_dir/Robust.ini" || { - echo -e "${COLOR_BAD}FEHLER: Konnte Robust.HG.ini nicht kopieren${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Konnte Robust.HG.ini nicht kopieren${COLOR_RESET}" >&2 return 1 } @@ -101,17 +155,17 @@ function hypergrid() { # Prüfen ob Robust.local.ini existiert if [[ ! -f "$robust_dir/Robust.local.ini" ]]; then - echo -e "${COLOR_BAD}FEHLER: Robust.local.ini nicht gefunden in $robust_dir${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Robust.local.ini nicht gefunden in $robust_dir${COLOR_RESET}" >&2 return 1 fi cp "$robust_dir/Robust.local.ini" "$robust_dir/Robust.ini" || { - echo -e "${COLOR_BAD}FEHLER: Konnte Robust.local.ini nicht kopieren${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Konnte Robust.local.ini nicht kopieren${COLOR_RESET}" >&2 return 1 } fi - echo -e "${COLOR_OK}Modus erfolgreich auf $modus gesetzt${COLOR_RESET}" + log "${COLOR_OK}Modus erfolgreich auf $modus gesetzt${COLOR_RESET}" return 0 } @@ -138,14 +192,14 @@ function servercheck() { # elementary OS (Ubuntu-basiert, kann .NET aus Ubuntu-Quellen beziehen) # Raspberry Pi OS (Debian-basiert, erfordert manuelle Installation für .NET) - echo -e "${COLOR_HEADING}🔍 Server-Kompatibilitätscheck wird durchgeführt...${COLOR_RESET}" + log "${COLOR_HEADING}🔍 Server-Kompatibilitätscheck wird durchgeführt...${COLOR_RESET}" # Ermitteln der Distribution und Version os_id=$(grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"') os_version=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2 | tr -d '"') os_codename=$(grep '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2 | tr -d '"') - echo -e "${COLOR_LABEL}Server läuft mit:${COLOR_RESET} ${COLOR_SERVER}$os_id $os_version ($os_codename)${COLOR_RESET}" + log "${COLOR_LABEL}Server läuft mit:${COLOR_RESET} ${COLOR_SERVER}$os_id $os_version ($os_codename)${COLOR_RESET}" # Paketnamen für verschiedene Distributionen definieren declare -A dotnet_pkg=( @@ -178,17 +232,17 @@ function servercheck() { # Spezialfall Ubuntu 24.04 (verwendet jammy Repository) if [[ "$os_version" == "24.04" ]]; then - echo -e "${SYM_INFO} Ubuntu 24.04 verwendet das .NET Repository für Ubuntu 22.04 (jammy)" + log "${SYM_INFO} Ubuntu 24.04 verwendet das .NET Repository für Ubuntu 22.04 (jammy)" fi else - echo -e "${SYM_BAD} ${COLOR_WARNING}Nicht unterstützte Ubuntu-Version: $os_version!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_WARNING}Nicht unterstützte Ubuntu-Version: $os_version!${COLOR_RESET}" return 1 fi elif [[ "$os_id" == "debian" ]]; then if [[ "$os_version" -ge "11" ]]; then required_dotnet=${dotnet_pkg[$os_id]} else - echo -e "${SYM_BAD} ${COLOR_WARNING}Debian Version $os_version wird nicht unterstützt (mindestens Debian 11 erforderlich)!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_WARNING}Debian Version $os_version wird nicht unterstützt (mindestens Debian 11 erforderlich)!${COLOR_RESET}" return 1 fi elif [[ "$os_id" == "arch" || "$os_id" == "manjaro" ]]; then @@ -196,36 +250,36 @@ function servercheck() { elif [[ "$os_id" == "raspbian" ]]; then if [[ "$os_version" -ge "11" ]]; then required_dotnet=${dotnet_pkg[$os_id]} - echo -e "${SYM_INFO} Raspberry Pi OS erfordert möglicherweise manuelle Anpassungen für .NET 8.0" + log "${SYM_INFO} Raspberry Pi OS erfordert möglicherweise manuelle Anpassungen für .NET 8.0" else - echo -e "${SYM_BAD} ${COLOR_WARNING}Raspberry Pi OS Version $os_version wird nicht unterstützt!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_WARNING}Raspberry Pi OS Version $os_version wird nicht unterstützt!${COLOR_RESET}" return 1 fi else - echo -e "${SYM_BAD} ${COLOR_WARNING}Keine unterstützte Distribution für .NET gefunden!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_WARNING}Keine unterstützte Distribution für .NET gefunden!${COLOR_RESET}" return 1 fi # .NET-Installationsstatus prüfen - echo -e "${COLOR_HEADING}🔄 .NET Runtime-Überprüfung:${COLOR_RESET}" + log "${COLOR_HEADING}🔄 .NET Runtime-Überprüfung:${COLOR_RESET}" if [[ "$os_id" == "arch" || "$os_id" == "manjaro" ]]; then if ! pacman -Qi "$required_dotnet" >/dev/null 2>&1; then - echo -e "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$required_dotnet${COLOR_RESET}..." + log "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$required_dotnet${COLOR_RESET}..." sudo pacman -S --noconfirm "$required_dotnet" - echo -e "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}wurde erfolgreich installiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}wurde erfolgreich installiert.${COLOR_RESET}" else - echo -e "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}ist bereits installiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}ist bereits installiert.${COLOR_RESET}" fi else #if ! dpkg -s "$required_dotnet" >/dev/null 2>&1; then # dpkg-query -W hat eine bessere Fehlerabfrage if ! dpkg-query -W "$required_dotnet" >/dev/null 2>&1; then - echo -e "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$required_dotnet${COLOR_RESET}..." + log "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$required_dotnet${COLOR_RESET}..." # Microsoft Repository hinzufügen für Debian/Ubuntu-basierte Systeme if [[ "$os_id" == "ubuntu" || "$os_id" == "debian" || "$os_id" == "linuxmint" || "$os_id" == "pop_os" || "$os_id" == "raspbian" ]]; then - echo -e "${SYM_INFO} Füge Microsoft Repository hinzu..." + log "${SYM_INFO} Füge Microsoft Repository hinzu..." wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb @@ -233,14 +287,14 @@ function servercheck() { fi sudo apt-get install -y "$required_dotnet" - echo -e "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}wurde erfolgreich installiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}wurde erfolgreich installiert.${COLOR_RESET}" else - echo -e "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}ist bereits installiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_SERVER}$required_dotnet${COLOR_RESET} ${COLOR_ACTION}ist bereits installiert.${COLOR_RESET}" fi fi # Fehlende Pakete prüfen und installieren - echo -e "${COLOR_HEADING}📦 Überprüfe fehlende Pakete...${COLOR_RESET}" + log "${COLOR_HEADING}📦 Überprüfe fehlende Pakete...${COLOR_RESET}" # Paketliste basierend auf Distribution auswählen if [[ -n "${required_packages[$os_id]}" ]]; then @@ -253,20 +307,20 @@ function servercheck() { for package in "${pkg_list[@]}"; do if [[ "$os_id" == "arch" || "$os_id" == "manjaro" ]]; then if ! pacman -Qi "$package" >/dev/null 2>&1; then - echo -e "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$package${COLOR_RESET}..." + log "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$package${COLOR_RESET}..." sudo pacman -S --noconfirm "$package" fi else #if ! dpkg -s "$package" >/dev/null 2>&1; then # dpkg-query -W hat eine bessere Fehlerabfrage if ! dpkg-query -W "$package" >/dev/null 2>&1; then - echo -e "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$package${COLOR_RESET}..." + log "${SYM_OK} ${COLOR_ACTION}Installiere ${COLOR_SERVER}$package${COLOR_RESET}..." sudo apt-get install -y "$package" fi fi done - echo -e "${SYM_OK} ${COLOR_HEADING}Alle benötigten Pakete wurden installiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_HEADING}Alle benötigten Pakete wurden installiert.${COLOR_RESET}" blankline } @@ -291,7 +345,7 @@ function validate_sim_name() { local sim_name=$1 # Überprüfe ob der Name dem Muster sim[1-99] entspricht (case-sensitive) if [[ ! "$sim_name" =~ ^sim([1-9]|[1-9][0-9])$ ]]; then - echo -e "${SYM_BAD} ${COLOR_WARNING}Ungültiger Sim-Name! Bitte verwende sim1 bis sim99.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_WARNING}Ungültiger Sim-Name! Bitte verwende sim1 bis sim99.${COLOR_RESET}" return 1 fi return 0 @@ -303,10 +357,10 @@ function simstart() { exit 1 fi - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}$ $simstart ${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}$ $simstart ${COLOR_RESET}" sim_dir="$simstart/bin" cd "$sim_dir" || { - echo -e "${SYM_BAD} ${COLOR_WARNING}Verzeichnis $sim_dir nicht gefunden!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_WARNING}Verzeichnis $sim_dir nicht gefunden!${COLOR_RESET}" exit 1 } screen -fa -S "$simstart" -d -U -m dotnet OpenSim.dll @@ -322,7 +376,7 @@ function simstop() { exit 1 fi - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER} $simstop${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER} $simstop${COLOR_RESET}" screen -S "$simstop" -p 0 -X stuff "shutdown^M" sleep $Simulator_Stop_wait echo "OpenSim stoppen abgeschlossen." @@ -347,11 +401,11 @@ function simrestart() { #* OpenSim starten (robust → money → sim1 bis sim999) function opensimstart() { - echo -e "${SYM_WAIT} ${COLOR_START}Starte das Grid!${COLOR_RESET}" + log "${SYM_WAIT} ${COLOR_START}Starte das Grid!${COLOR_RESET}" # RobustServer starten if [[ -d "robust/bin" && -f "robust/bin/Robust.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}RobustServer ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}RobustServer ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" cd robust/bin || exit 1 # -inifile=Robust.HG.ini @@ -359,25 +413,25 @@ function opensimstart() { cd - >/dev/null 2>&1 || exit 1 sleep $RobustServer_Start_wait else - echo -e "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Robust.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Robust.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" fi # MoneyServer starten if [[ -f "robust/bin/MoneyServer.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" cd robust/bin || exit 1 screen -fa -S moneyserver -d -U -m dotnet MoneyServer.dll cd - >/dev/null 2>&1 || exit 1 sleep $MoneyServer_Start_wait else - echo -e "${SYM_BAD} ${COLOR_SERVER}MoneyServer: ${COLOR_BAD}MoneyServer.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}MoneyServer: ${COLOR_BAD}MoneyServer.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" fi # Sim-Regionen starten for ((i=1; i<=999; i++)); do sim_dir="sim$i/bin" if [[ -d "$sim_dir" && -f "$sim_dir/OpenSim.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim$i${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}$sim_dir...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim$i${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}$sim_dir...${COLOR_RESET}" cd "$sim_dir" || continue screen -fa -S "sim$i" -d -U -m dotnet OpenSim.dll cd - >/dev/null 2>&1 || continue @@ -389,35 +443,35 @@ function opensimstart() { } # Test OpenSim starten Parallel function opensimstartParallel() { - echo -e "${SYM_WAIT} ${COLOR_START}Starte das Grid!${COLOR_RESET}" + log "${SYM_WAIT} ${COLOR_START}Starte das Grid!${COLOR_RESET}" # 1. RobustServer (muss zuerst laufen) if [[ -d "robust/bin" && -f "robust/bin/Robust.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}RobustServer ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}RobustServer ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" (cd robust/bin && screen -fa -S robustserver -d -U -m dotnet Robust.dll) sleep "$RobustServer_Start_wait" else - echo -e "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Robust.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Robust.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" fi # 2. MoneyServer (optional) if [[ -f "robust/bin/MoneyServer.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" (cd robust/bin && screen -fa -S moneyserver -d -U -m dotnet MoneyServer.dll) sleep "$MoneyServer_Start_wait" fi # 3. SIM1 ZUERST (sequentiell) if [[ -d "sim1/bin" && -f "sim1/bin/OpenSim.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim1${COLOR_RESET} ${COLOR_START}(primäre Region)...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim1${COLOR_RESET} ${COLOR_START}(primäre Region)...${COLOR_RESET}" (cd sim1/bin && screen -fa -S sim1 -d -U -m dotnet OpenSim.dll) sleep "$Simulator_Start_wait" else - echo -e "${SYM_BAD} ${COLOR_SERVER}sim1: ${COLOR_BAD}OpenSim.dll nicht gefunden.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}sim1: ${COLOR_BAD}OpenSim.dll nicht gefunden.${COLOR_RESET}" fi # 4. SIM2-SIM99 PARALLEL - echo -e "${SYM_INFO} ${COLOR_START}Starte sekundäre Simulatoren parallel...${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_START}Starte sekundäre Simulatoren parallel...${COLOR_RESET}" # Maximal 10 parallele Jobs MAX_JOBS=10 @@ -430,46 +484,46 @@ function opensimstartParallel() { sleep 1 done - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim$i${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}$sim_dir...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim$i${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}$sim_dir...${COLOR_RESET}" (cd "$sim_dir" && screen -fa -S "sim$i" -d -U -m dotnet OpenSim.dll) & fi done wait # Warte auf alle Hintergrundjobs - echo -e "${SYM_OK} ${COLOR_START}Alle Simulatoren gestartet.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Alle Simulatoren gestartet.${COLOR_RESET}" blankline } #* OpenSim stoppen (sim999 bis sim1 → money → robust) function opensimstop() { - echo -e "${SYM_WAIT} ${COLOR_STOP}Stoppe das Grid!${COLOR_RESET}" + log "${SYM_WAIT} ${COLOR_STOP}Stoppe das Grid!${COLOR_RESET}" # Sim-Regionen stoppen for ((i=999; i>=1; i--)); do sim_dir="sim$i" if screen -list | grep -q "$sim_dir"; then screen -S "sim$i" -p 0 -X stuff "shutdown^M" - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}sim$i${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}sim$i${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" sleep $Simulator_Stop_wait fi done # MoneyServer stoppen if screen -list | grep -q "moneyserver"; then - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" screen -S moneyserver -p 0 -X stuff "shutdown^M" sleep $MoneyServer_Stop_wait else - echo -e "${SYM_BAD} ${COLOR_SERVER}MoneyServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET} ${COLOR_STOP}Überspringe Stopp.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}MoneyServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET} ${COLOR_STOP}Überspringe Stopp.${COLOR_RESET}" fi # RobustServer stoppen if screen -list | grep -q "robust"; then - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}RobustServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}RobustServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" screen -S robustserver -p 0 -X stuff "shutdown^M" sleep $RobustServer_Stop_wait else - echo -e "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET} ${COLOR_STOP}Überspringe Stopp.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET} ${COLOR_STOP}Überspringe Stopp.${COLOR_RESET}" fi echo "OpenSim stoppen abgeschlossen." blankline @@ -477,11 +531,11 @@ function opensimstop() { # Das parallele Stoppen in der Reihenfolge sim999 → sim2 parallel, dann sim1 → MoneyServer → RobustServer function opensimstopParallel() { - echo -e "${SYM_WAIT} ${COLOR_STOP}Stoppe das Grid!${COLOR_RESET}" + log "${SYM_WAIT} ${COLOR_STOP}Stoppe das Grid!${COLOR_RESET}" local MAX_PARALLEL=10 # Maximale parallele Stopp-Vorgänge # 1. Paralleles Stoppen von sim999 bis sim2 - echo -e "${SYM_INFO} ${COLOR_STOP}Stoppe sekundäre Simulatoren parallel...${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_STOP}Stoppe sekundäre Simulatoren parallel...${COLOR_RESET}" for ((i=999; i>=2; i--)); do sim_name="sim$i" @@ -492,7 +546,7 @@ function opensimstopParallel() { done if screen -list | grep -q "$sim_name"; then - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}$sim_name${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}$sim_name${COLOR_RESET}" ( screen -S "$sim_name" -p 0 -X stuff "shutdown^M" sleep $Simulator_Stop_wait @@ -503,30 +557,30 @@ function opensimstopParallel() { # 2. Sim1 sequentiell stoppen if screen -list | grep -q "sim1"; then - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}sim1${COLOR_RESET} ${COLOR_STOP}(primäre Region)...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}sim1${COLOR_RESET} ${COLOR_STOP}(primäre Region)...${COLOR_RESET}" screen -S "sim1" -p 0 -X stuff "shutdown^M" sleep $Simulator_Stop_wait fi # 3. MoneyServer stoppen if screen -list | grep -q "moneyserver"; then - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}MoneyServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" screen -S moneyserver -p 0 -X stuff "shutdown^M" sleep $MoneyServer_Stop_wait else - echo -e "${SYM_BAD} ${COLOR_SERVER}MoneyServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}MoneyServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET}" fi # 4. RobustServer stoppen (zuletzt) if screen -list | grep -q "robustserver"; then - echo -e "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}RobustServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Stoppe ${COLOR_SERVER}RobustServer${COLOR_RESET} ${COLOR_STOP}...${COLOR_RESET}" screen -S robustserver -p 0 -X stuff "shutdown^M" sleep $RobustServer_Stop_wait else - echo -e "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Läuft nicht.${COLOR_RESET}" fi - echo -e "${SYM_OK} ${COLOR_STOP}Alle Dienste gestoppt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_STOP}Alle Dienste gestoppt.${COLOR_RESET}" blankline } @@ -594,58 +648,58 @@ function check_screens() { function opensimgitcopy() { # 30.04.2025: Funktion um OpenSimulator von GitHub zu kopieren - echo -e "${COLOR_HEADING}🔄 OpenSimulator GitHub-Verwaltung${COLOR_RESET}" + log "${COLOR_HEADING}🔄 OpenSimulator GitHub-Verwaltung${COLOR_RESET}" # Benutzerabfrage für Hauptaktion - echo -e "${COLOR_LABEL}Möchten Sie den OpenSimulator vom GitHub verwenden oder aktualisieren? (${COLOR_OK}[upgrade]${COLOR_LABEL}/new)${COLOR_RESET}" + log "${COLOR_LABEL}Möchten Sie den OpenSimulator vom GitHub verwenden oder aktualisieren? (${COLOR_OK}[upgrade]${COLOR_LABEL}/new)${COLOR_RESET}" read -r user_choice user_choice=${user_choice:-upgrade} # Verarbeitung der Benutzerauswahl if [[ "$user_choice" == "new" ]]; then if [[ -d "opensim" ]]; then - echo -e "${COLOR_ACTION}Vorhandene OpenSimulator-Version wird gelöscht...${COLOR_RESET}" + log "${COLOR_ACTION}Vorhandene OpenSimulator-Version wird gelöscht...${COLOR_RESET}" rm -rf opensim - echo -e "${SYM_OK} ${COLOR_ACTION}Alte OpenSimulator-Version wurde erfolgreich entfernt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Alte OpenSimulator-Version wurde erfolgreich entfernt.${COLOR_RESET}" fi - echo -e "${COLOR_ACTION}OpenSimulator wird von GitHub geholt...${COLOR_RESET}" + log "${COLOR_ACTION}OpenSimulator wird von GitHub geholt...${COLOR_RESET}" git clone git://opensimulator.org/git/opensim opensim - echo -e "${SYM_OK} ${COLOR_ACTION}OpenSimulator wurde erfolgreich heruntergeladen.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}OpenSimulator wurde erfolgreich heruntergeladen.${COLOR_RESET}" elif [[ "$user_choice" == "upgrade" ]]; then if [[ -d "opensim/.git" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Repository gefunden. Aktualisiere mit 'git pull'...${COLOR_RESET}" - cd opensim || { echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler: Kann nicht ins Verzeichnis wechseln!${COLOR_RESET}"; return 1; } + log "${SYM_OK} ${COLOR_ACTION}Repository gefunden. Aktualisiere mit 'git pull'...${COLOR_RESET}" + cd opensim || { log "${SYM_BAD} ${COLOR_ERROR}Fehler: Kann nicht ins Verzeichnis wechseln!${COLOR_RESET}"; return 1; } git pull origin master - echo -e "${COLOR_OK}✅ ${COLOR_ACTION}OpenSimulator erfolgreich aktualisiert!${COLOR_RESET}" + log "${COLOR_OK}✅ ${COLOR_ACTION}OpenSimulator erfolgreich aktualisiert!${COLOR_RESET}" cd .. else - echo -e "${COLOR_WARNING}⚠ ${COLOR_ACTION}OpenSimulator-Verzeichnis nicht gefunden. Klone Repository neu...${COLOR_RESET}" + log "${COLOR_WARNING}⚠ ${COLOR_ACTION}OpenSimulator-Verzeichnis nicht gefunden. Klone Repository neu...${COLOR_RESET}" git clone git://opensimulator.org/git/opensim opensim - echo -e "${COLOR_OK}✅ ${COLOR_ACTION}OpenSimulator erfolgreich heruntergeladen!${COLOR_RESET}" + log "${COLOR_OK}✅ ${COLOR_ACTION}OpenSimulator erfolgreich heruntergeladen!${COLOR_RESET}" fi else - echo -e "${SYM_BAD} ${COLOR_ERROR}Abbruch: Keine Aktion durchgeführt.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Abbruch: Keine Aktion durchgeführt.${COLOR_RESET}" return 1 fi # Automatische .NET-Version-Erkennung mit klarer Ausgabe - echo -e "${COLOR_ACTION}Erkenne installierte .NET-Version...${COLOR_RESET}" + log "${COLOR_ACTION}Erkenne installierte .NET-Version...${COLOR_RESET}" if dotnet_version=$(dotnet --version 2>/dev/null | awk -F. '{if($1==6)print"6";else print"8"}'); then - echo -e "${SYM_OK} ${COLOR_ACTION}Erkannte .NET-Version: ${COLOR_OK}$dotnet_version${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Erkannte .NET-Version: ${COLOR_OK}$dotnet_version${COLOR_RESET}" - cd opensim || { echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler: Verzeichnis 'opensim' nicht gefunden.${COLOR_RESET}"; return 1; } + cd opensim || { log "${SYM_BAD} ${COLOR_ERROR}Fehler: Verzeichnis 'opensim' nicht gefunden.${COLOR_RESET}"; return 1; } if [[ "$dotnet_version" == "6" ]]; then git checkout dotnet6 - echo -e "${SYM_OK} ${COLOR_ACTION}OpenSimulator wurde für .NET 6 umgebaut.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}OpenSimulator wurde für .NET 6 umgebaut.${COLOR_RESET}" else - echo -e "${SYM_OK} ${COLOR_ACTION}Verwende Standard .NET 8.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Verwende Standard .NET 8.${COLOR_RESET}" fi cd .. else - echo -e "${COLOR_WARNING}⚠ ${COLOR_ACTION}Keine .NET-Version erkannt, verwende Standard .NET 8.${COLOR_RESET}" + log "${COLOR_WARNING}⚠ ${COLOR_ACTION}Keine .NET-Version erkannt, verwende Standard .NET 8.${COLOR_RESET}" fi versionrevision # Versionierung des OpenSimulators von Flavour.Dev zu Flavour.Extended @@ -654,53 +708,53 @@ function opensimgitcopy() { } function moneygitcopy() { - echo -e "${COLOR_HEADING}💰 MoneyServer GitHub-Verwaltung${COLOR_RESET}" + log "${COLOR_HEADING}💰 MoneyServer GitHub-Verwaltung${COLOR_RESET}" - echo -e "${COLOR_LABEL}Möchten Sie den MoneyServer vom GitHub verwenden oder aktualisieren? (${COLOR_OK}[upgrade]${COLOR_LABEL}/new)${COLOR_RESET}" + log "${COLOR_LABEL}Möchten Sie den MoneyServer vom GitHub verwenden oder aktualisieren? (${COLOR_OK}[upgrade]${COLOR_LABEL}/new)${COLOR_RESET}" read -r user_choice user_choice=${user_choice:-upgrade} if [[ "$user_choice" == "new" ]]; then if [[ -d "opensimcurrencyserver" ]]; then - echo -e "${COLOR_ACTION}Vorhandene MoneyServer-Version wird gelöscht...${COLOR_RESET}" + log "${COLOR_ACTION}Vorhandene MoneyServer-Version wird gelöscht...${COLOR_RESET}" rm -rf opensimcurrencyserver - echo -e "${SYM_OK} ${COLOR_ACTION}Alte MoneyServer-Version wurde erfolgreich entfernt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Alte MoneyServer-Version wurde erfolgreich entfernt.${COLOR_RESET}" fi - echo -e "${COLOR_ACTION}MONEYSERVER: MoneyServer wird vom GIT geholt...${COLOR_RESET}" + log "${COLOR_ACTION}MONEYSERVER: MoneyServer wird vom GIT geholt...${COLOR_RESET}" git clone https://github.com/ManfredAabye/opensimcurrencyserver-dotnet.git opensimcurrencyserver - echo -e "${SYM_OK} ${COLOR_ACTION}MoneyServer wurde erfolgreich heruntergeladen.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}MoneyServer wurde erfolgreich heruntergeladen.${COLOR_RESET}" elif [[ "$user_choice" == "upgrade" ]]; then if [[ -d "opensimcurrencyserver/.git" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Repository gefunden. Aktualisiere mit 'git pull'...${COLOR_RESET}" - cd opensimcurrencyserver || { echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler: Kann nicht ins Verzeichnis wechseln!${COLOR_RESET}"; return 1; } + log "${SYM_OK} ${COLOR_ACTION}Repository gefunden. Aktualisiere mit 'git pull'...${COLOR_RESET}" + cd opensimcurrencyserver || { log "${SYM_BAD} ${COLOR_ERROR}Fehler: Kann nicht ins Verzeichnis wechseln!${COLOR_RESET}"; return 1; } # Automatische Branch-Erkennung branch_name=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') - git pull origin "$branch_name" && echo -e "${COLOR_OK}✅ ${COLOR_ACTION}MoneyServer erfolgreich aktualisiert!${COLOR_RESET}" + git pull origin "$branch_name" && log "${COLOR_OK}✅ ${COLOR_ACTION}MoneyServer erfolgreich aktualisiert!${COLOR_RESET}" cd .. else - echo -e "${COLOR_WARNING}⚠ ${COLOR_ACTION}MoneyServer-Verzeichnis nicht gefunden. Klone Repository neu...${COLOR_RESET}" - git clone https://github.com/ManfredAabye/opensimcurrencyserver-dotnet.git opensimcurrencyserver && echo -e "${COLOR_OK}✅ ${COLOR_ACTION}MoneyServer erfolgreich heruntergeladen!${COLOR_RESET}" + log "${COLOR_WARNING}⚠ ${COLOR_ACTION}MoneyServer-Verzeichnis nicht gefunden. Klone Repository neu...${COLOR_RESET}" + git clone https://github.com/ManfredAabye/opensimcurrencyserver-dotnet.git opensimcurrencyserver && log "${COLOR_OK}✅ ${COLOR_ACTION}MoneyServer erfolgreich heruntergeladen!${COLOR_RESET}" fi else - echo -e "${SYM_BAD} ${COLOR_ERROR}Abbruch: Keine Aktion durchgeführt.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Abbruch: Keine Aktion durchgeführt.${COLOR_RESET}" return 1 fi # Prüfen, ob das Verzeichnis existiert, bevor es kopiert wird if [[ -d "opensimcurrencyserver/addon-modules" ]]; then cp -r opensimcurrencyserver/addon-modules opensim/ - echo -e "${SYM_OK} ${COLOR_ACTION}MONEYSERVER: addon-modules wurde nach opensim kopiert${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}MONEYSERVER: addon-modules wurde nach opensim kopiert${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}MONEYSERVER: addon-modules existiert nicht${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}MONEYSERVER: addon-modules existiert nicht${COLOR_RESET}" fi if [[ -d "opensimcurrencyserver/bin" ]]; then cp -r opensimcurrencyserver/bin opensim/ - echo -e "${SYM_OK} ${COLOR_ACTION}MONEYSERVER: bin wurde nach opensim kopiert${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}MONEYSERVER: bin wurde nach opensim kopiert${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}MONEYSERVER: bin existiert nicht${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}MONEYSERVER: bin existiert nicht${COLOR_RESET}" fi blankline @@ -710,7 +764,7 @@ function moneygitcopy() { #* Das ist erst halb fertig. function ruthrothgit() { # Schritt 1 das bereitstellen der Pakete zur weiteren bearbeitung. - echo -e "${COLOR_HEADING}👥 Ruth & Roth Avatar-Assets Vorbereitung${COLOR_RESET}" + log "${COLOR_HEADING}👥 Ruth & Roth Avatar-Assets Vorbereitung${COLOR_RESET}" base_dir="ruthroth" mkdir -p "$base_dir" @@ -725,39 +779,39 @@ function ruthrothgit() { target_dir="$avatar" if [[ ! -d "$target_dir" ]]; then - echo -e " ${COLOR_ACTION}➜ Klone ${COLOR_SERVER}$avatar${COLOR_ACTION} von GitHub...${COLOR_RESET}" - git clone "$repo_url" "$target_dir" && echo -e " ${COLOR_OK}✅ ${COLOR_SERVER}$avatar${COLOR_RESET} ${COLOR_ACTION}wurde heruntergeladen.${COLOR_RESET}" + log " ${COLOR_ACTION}➜ Klone ${COLOR_SERVER}$avatar${COLOR_ACTION} von GitHub...${COLOR_RESET}" + git clone "$repo_url" "$target_dir" && log " ${COLOR_OK}✅ ${COLOR_SERVER}$avatar${COLOR_RESET} ${COLOR_ACTION}wurde heruntergeladen.${COLOR_RESET}" else - echo -e " ${COLOR_OK}✅ ${COLOR_SERVER}$avatar${COLOR_RESET} ${COLOR_ACTION}ist bereits vorhanden, überspringe Download.${COLOR_RESET}" + log " ${COLOR_OK}✅ ${COLOR_SERVER}$avatar${COLOR_RESET} ${COLOR_ACTION}ist bereits vorhanden, überspringe Download.${COLOR_RESET}" fi # Kopiere nur die relevanten IAR-Dateien direkt nach ruthroth - echo -e " ${COLOR_ACTION}➜ Kopiere benötigte IAR-Dateien nach ${COLOR_DIR}$base_dir${COLOR_ACTION}...${COLOR_RESET}" - cp "$target_dir/Artifacts/IAR/"*.iar "$base_dir/" 2>/dev/null && echo -e " ${SYM_OK} IAR-Dateien von ${COLOR_SERVER}$avatar${COLOR_RESET} kopiert.${COLOR_RESET}" + log " ${COLOR_ACTION}➜ Kopiere benötigte IAR-Dateien nach ${COLOR_DIR}$base_dir${COLOR_ACTION}...${COLOR_RESET}" + cp "$target_dir/Artifacts/IAR/"*.iar "$base_dir/" 2>/dev/null && log " ${SYM_OK} IAR-Dateien von ${COLOR_SERVER}$avatar${COLOR_RESET} kopiert.${COLOR_RESET}" done # Kopiere das updatelibrary.py-Skript ins Hauptverzeichnis ruthroth - echo -e " ${COLOR_ACTION}➜ Kopiere updatelibrary.py nach ${COLOR_DIR}$base_dir${COLOR_ACTION}...${COLOR_RESET}" - cp "updatelibrary.py" "$base_dir/" && echo -e " ${SYM_OK} updatelibrary.py wurde kopiert.${COLOR_RESET}" + log " ${COLOR_ACTION}➜ Kopiere updatelibrary.py nach ${COLOR_DIR}$base_dir${COLOR_ACTION}...${COLOR_RESET}" + cp "updatelibrary.py" "$base_dir/" && log " ${SYM_OK} updatelibrary.py wurde kopiert.${COLOR_RESET}" echo "Verzeichniswechsel in $base_dir" # Wechsel ins ruthroth-Verzeichnis - cd "$base_dir" || { echo -e "${SYM_BAD} Fehler beim Wechsel ins Verzeichnis ${COLOR_DIR}$base_dir${COLOR_RESET}"; return 1; } + cd "$base_dir" || { log "${SYM_BAD} Fehler beim Wechsel ins Verzeichnis ${COLOR_DIR}$base_dir${COLOR_RESET}"; return 1; } # Entpacke die IAR-Dateien direkt in ruthroth - echo -e " ${COLOR_ACTION}➜ Entpacke IAR-Pakete in ${COLOR_DIR}$base_dir${COLOR_ACTION}...${COLOR_RESET}" + log " ${COLOR_ACTION}➜ Entpacke IAR-Pakete in ${COLOR_DIR}$base_dir${COLOR_ACTION}...${COLOR_RESET}" for iar_file in *.iar; do if [[ -f "$iar_file" ]]; then target_dir="${iar_file%.iar}" # Erstellt Verzeichnisname basierend auf Dateiname ohne .iar mkdir -p "$target_dir" - tar -xzf "$iar_file" -C "$target_dir/" && echo -e " ✓ ${iar_file} entpackt nach ${target_dir}" + tar -xzf "$iar_file" -C "$target_dir/" && log " ✓ ${iar_file} entpackt nach ${target_dir}" else - echo -e " ⚠ IAR-Datei ${iar_file} nicht gefunden. Überspringe..." + log " ⚠ IAR-Datei ${iar_file} nicht gefunden. Überspringe..." fi done - echo -e "${COLOR_OK}✅ ${COLOR_ACTION}Grundlage für die OpenSimulator-Pakete wurde erfolgreich erstellt!${COLOR_RESET}" + log "${COLOR_OK}✅ ${COLOR_ACTION}Grundlage für die OpenSimulator-Pakete wurde erfolgreich erstellt!${COLOR_RESET}" # Schritt 2 die verwendung von updatelibrary.py. cd ruthroth @@ -770,9 +824,9 @@ function ruthrothgit() { } function osslscriptsgit() { - echo -e "${COLOR_HEADING}📜 OSSL Beispiel-Skripte GitHub-Verwaltung${COLOR_RESET}" + log "${COLOR_HEADING}📜 OSSL Beispiel-Skripte GitHub-Verwaltung${COLOR_RESET}" - echo -e "${COLOR_LABEL}Möchten Sie die OpenSim OSSL Beispiel-Skripte vom GitHub verwenden oder aktualisieren? (${COLOR_OK}[upgrade]${COLOR_LABEL}/new)${COLOR_RESET}" + log "${COLOR_LABEL}Möchten Sie die OpenSim OSSL Beispiel-Skripte vom GitHub verwenden oder aktualisieren? (${COLOR_OK}[upgrade]${COLOR_LABEL}/new)${COLOR_RESET}" read -r user_choice user_choice=${user_choice:-upgrade} @@ -781,25 +835,25 @@ function osslscriptsgit() { if [[ "$user_choice" == "new" ]]; then if [[ -d "$repo_name" ]]; then - echo -e "${COLOR_ACTION}Vorhandene Version wird gelöscht...${COLOR_RESET}" + log "${COLOR_ACTION}Vorhandene Version wird gelöscht...${COLOR_RESET}" rm -rf "$repo_name" - echo -e "${SYM_OK} ${COLOR_ACTION}Alte Version wurde erfolgreich entfernt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Alte Version wurde erfolgreich entfernt.${COLOR_RESET}" fi - echo -e "${COLOR_ACTION}Beispiel-Skripte werden vom GitHub heruntergeladen...${COLOR_RESET}" - git clone "$repo_url" "$repo_name" && echo -e "${SYM_OK} ${COLOR_ACTION}Repository wurde erfolgreich heruntergeladen.${COLOR_RESET}" + log "${COLOR_ACTION}Beispiel-Skripte werden vom GitHub heruntergeladen...${COLOR_RESET}" + git clone "$repo_url" "$repo_name" && log "${SYM_OK} ${COLOR_ACTION}Repository wurde erfolgreich heruntergeladen.${COLOR_RESET}" elif [[ "$user_choice" == "upgrade" ]]; then if [[ -d "$repo_name/.git" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Repository gefunden. Aktualisiere mit 'git pull'...${COLOR_RESET}" - cd "$repo_name" || { echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler beim Wechsel ins Verzeichnis!${COLOR_RESET}"; return 1; } + log "${SYM_OK} ${COLOR_ACTION}Repository gefunden. Aktualisiere mit 'git pull'...${COLOR_RESET}" + cd "$repo_name" || { log "${SYM_BAD} ${COLOR_ERROR}Fehler beim Wechsel ins Verzeichnis!${COLOR_RESET}"; return 1; } branch_name=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') - git pull origin "$branch_name" && echo -e "${COLOR_OK}✅ ${COLOR_ACTION}Repository erfolgreich aktualisiert.${COLOR_RESET}" + git pull origin "$branch_name" && log "${COLOR_OK}✅ ${COLOR_ACTION}Repository erfolgreich aktualisiert.${COLOR_RESET}" cd .. else - echo -e "${COLOR_WARNING}⚠ ${COLOR_ACTION}Verzeichnis nicht gefunden oder kein Git-Repo. Klone Repository neu...${COLOR_RESET}" - git clone "$repo_url" "$repo_name" && echo -e "${COLOR_OK}✅ ${COLOR_ACTION}Repository wurde erfolgreich heruntergeladen.${COLOR_RESET}" + log "${COLOR_WARNING}⚠ ${COLOR_ACTION}Verzeichnis nicht gefunden oder kein Git-Repo. Klone Repository neu...${COLOR_RESET}" + git clone "$repo_url" "$repo_name" && log "${COLOR_OK}✅ ${COLOR_ACTION}Repository wurde erfolgreich heruntergeladen.${COLOR_RESET}" fi else - echo -e "${SYM_BAD} ${COLOR_ERROR}Abbruch: Keine Aktion durchgeführt.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Abbruch: Keine Aktion durchgeführt.${COLOR_RESET}" return 1 fi @@ -810,16 +864,16 @@ function osslscriptsgit() { # Kopieren der Verzeichnisse if [[ -d "$repo_name/ScriptsAssetSet" ]]; then cp -r "$repo_name/ScriptsAssetSet" opensim/bin/assets/ - echo -e "${SYM_OK} ${COLOR_ACTION}ScriptsAssetSet wurde nach opensim/bin/assets kopiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}ScriptsAssetSet wurde nach opensim/bin/assets kopiert.${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}ScriptsAssetSet Verzeichnis nicht gefunden!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}ScriptsAssetSet Verzeichnis nicht gefunden!${COLOR_RESET}" fi if [[ -d "$repo_name/inventory/ScriptsLibrary" ]]; then cp -r "$repo_name/inventory/ScriptsLibrary" opensim/bin/inventory/ - echo -e "${SYM_OK} ${COLOR_ACTION}ScriptsLibrary wurde nach opensim/bin/inventory kopiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}ScriptsLibrary wurde nach opensim/bin/inventory kopiert.${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}ScriptsLibrary Verzeichnis nicht gefunden!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}ScriptsLibrary Verzeichnis nicht gefunden!${COLOR_RESET}" fi blankline @@ -828,7 +882,7 @@ function osslscriptsgit() { # Es werden die Konfiguartionen jetzt auch geändert. function pbrtexturesgit() { - echo -e "${COLOR_HEADING}🎨 PBR Texturen Installation${COLOR_RESET}" + log "${COLOR_HEADING}🎨 PBR Texturen Installation${COLOR_RESET}" textures_zip_url="https://github.com/ManfredAabye/OpenSim_PBR_Textures/releases/download/PBR/OpenSim_PBR_Textures.zip" zip_file="OpenSim_PBR_Textures.zip" @@ -837,32 +891,32 @@ function pbrtexturesgit() { # ZIP herunterladen, wenn nicht vorhanden if [[ ! -f "$zip_file" ]]; then - echo -e "${COLOR_ACTION}Lade OpenSim PBR Texturen herunter...${COLOR_RESET}" + log "${COLOR_ACTION}Lade OpenSim PBR Texturen herunter...${COLOR_RESET}" if ! wget -q --show-progress -O "$zip_file" "$textures_zip_url"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler beim Herunterladen der Texturen!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler beim Herunterladen der Texturen!${COLOR_RESET}" return 1 fi - echo -e "${SYM_OK} ${COLOR_ACTION}Download abgeschlossen: ${COLOR_DIR}$zip_file${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Download abgeschlossen: ${COLOR_DIR}$zip_file${COLOR_RESET}" else - echo -e "${SYM_OK} ${COLOR_ACTION}ZIP-Datei bereits vorhanden: ${COLOR_DIR}$zip_file${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}ZIP-Datei bereits vorhanden: ${COLOR_DIR}$zip_file${COLOR_RESET}" fi # Entpacken, wenn Verzeichnis noch nicht existiert if [[ ! -d "$unpacked_dir" ]]; then - echo -e "${COLOR_ACTION}Entpacke Texturen nach ${COLOR_DIR}$unpacked_dir${COLOR_ACTION}...${COLOR_RESET}" + log "${COLOR_ACTION}Entpacke Texturen nach ${COLOR_DIR}$unpacked_dir${COLOR_ACTION}...${COLOR_RESET}" unzip -q "$zip_file" -d . - echo -e "${SYM_OK} ${COLOR_ACTION}Entpackt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Entpackt.${COLOR_RESET}" else - echo -e "${SYM_OK} ${COLOR_ACTION}Verzeichnis ${COLOR_DIR}$unpacked_dir${COLOR_ACTION} existiert bereits – überspringe Entpacken.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Verzeichnis ${COLOR_DIR}$unpacked_dir${COLOR_ACTION} existiert bereits – überspringe Entpacken.${COLOR_RESET}" fi # Kopieren nach opensim/bin if [[ -d "$unpacked_dir/bin" ]]; then - echo -e "${COLOR_ACTION}Kopiere Texturen nach ${COLOR_DIR}$target_dir${COLOR_ACTION}...${COLOR_RESET}" + log "${COLOR_ACTION}Kopiere Texturen nach ${COLOR_DIR}$target_dir${COLOR_ACTION}...${COLOR_RESET}" cp -r "$unpacked_dir/bin" "$target_dir" - echo -e "${SYM_OK} ${COLOR_ACTION}Texturen erfolgreich installiert in ${COLOR_DIR}$target_dir${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Texturen erfolgreich installiert in ${COLOR_DIR}$target_dir${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}Verzeichnis ${COLOR_DIR}$unpacked_dir/bin${COLOR_ERROR} nicht gefunden!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Verzeichnis ${COLOR_DIR}$unpacked_dir/bin${COLOR_ERROR} nicht gefunden!${COLOR_RESET}" return 1 fi @@ -898,22 +952,22 @@ function pbrtexturesgit() { } function osWebinterfacegit() { - echo -e "${COLOR_HEADING}🌐 Webinterface Installation${COLOR_RESET}" + log "${COLOR_HEADING}🌐 Webinterface Installation${COLOR_RESET}" webverzeichnis="oswebinterface" # Abfrage zur Installation mit Default "Nein" - echo -e "${COLOR_LABEL}Möchten Sie das OpenSim Webinterface installieren? ()j/N) ${COLOR_RESET} [n]" + log "${COLOR_LABEL}Möchten Sie das OpenSim Webinterface installieren? ()j/N) ${COLOR_RESET} [n]" read -r install_webinterface if [[ ! "$install_webinterface" =~ ^[jJ][aA]?$ ]]; then - echo -e "${COLOR_INFO}Installation abgebrochen (Default: Nein)${COLOR_RESET}" + log "${COLOR_INFO}Installation abgebrochen (Default: Nein)${COLOR_RESET}" blankline return 0 fi # 1. PHP-Check mit Distro-Erkennung if ! command -v php &>/dev/null; then - echo -e "${SYM_WARNING} ${COLOR_WARNING}PHP ist nicht installiert!${COLOR_RESET}" + log "${SYM_WARNING} ${COLOR_WARNING}PHP ist nicht installiert!${COLOR_RESET}" # Distro-Erkennung # shellcheck source=/dev/null @@ -932,27 +986,27 @@ function osWebinterfacegit() { pkg_cmd="sudo zypper install -y php7 php7-mysql php7-gd php7-curl" ;; *) - echo -e "${SYM_BAD} ${COLOR_ERROR}Unterstützte Distribution nicht erkannt!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Unterstützte Distribution nicht erkannt!${COLOR_RESET}" echo "Manuell installieren: php php-mysql php-gd php-curl" return 1 ;; esac - echo -e "PHP auf ${PRETTY_NAME} installieren? (j/n) " + log "PHP auf ${PRETTY_NAME} installieren? (j/n) " read -r install_php if [[ "$install_php" =~ ^[jJ] ]]; then - echo -e "${COLOR_ACTION}Installiere PHP... (${pkg_cmd})${COLOR_RESET}" + log "${COLOR_ACTION}Installiere PHP... (${pkg_cmd})${COLOR_RESET}" if ! eval "$pkg_cmd"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}PHP-Installation fehlgeschlagen!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}PHP-Installation fehlgeschlagen!${COLOR_RESET}" return 1 fi - echo -e "${COLOR_OK}✅ PHP erfolgreich installiert!${COLOR_RESET}" + log "${COLOR_OK}✅ PHP erfolgreich installiert!${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}Abbruch: PHP ist erforderlich.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Abbruch: PHP ist erforderlich.${COLOR_RESET}" return 1 fi else - echo -e "${COLOR_OK}✅ PHP ist installiert ($(php -v | head -n 1))${COLOR_RESET}" + log "${COLOR_OK}✅ PHP ist installiert ($(php -v | head -n 1))${COLOR_RESET}" fi # 2. Webverzeichnis-Check mit automatischer User/Group-Erkennung @@ -960,7 +1014,7 @@ function osWebinterfacegit() { [[ -d "/var/www" && ! -d "$webroot" ]] && webroot="/var/www" # Fallback für einige Distros if [[ ! -d "$webroot" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Webroot nicht gefunden in:${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Webroot nicht gefunden in:${COLOR_RESET}" echo "/var/www/html oder /var/www" echo "Tipp: Apache/Nginx zuerst installieren" return 1 @@ -1016,27 +1070,27 @@ function osWebinterfacegit() { fi # 4. Deployment mit korrekten Berechtigungen - echo -e "${COLOR_ACTION}Kopiere Webinterface nach ${webroot}/${webverzeichnis}...${COLOR_RESET}" + log "${COLOR_ACTION}Kopiere Webinterface nach ${webroot}/${webverzeichnis}...${COLOR_RESET}" if ! sudo cp -r "oswebinterface" "$webroot/$webverzeichnis"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Kopieren fehlgeschlagen!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Kopieren fehlgeschlagen!${COLOR_RESET}" return 1 fi - echo -e "${COLOR_ACTION}Setze Besitzer auf ${target_user}:${target_group}...${COLOR_RESET}" + log "${COLOR_ACTION}Setze Besitzer auf ${target_user}:${target_group}...${COLOR_RESET}" if ! sudo chown -R "$target_user:$target_group" "$webroot/$webverzeichnis"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Besitzer ändern fehlgeschlagen!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Besitzer ändern fehlgeschlagen!${COLOR_RESET}" return 1 fi - echo -e "${COLOR_ACTION}Setze Dateiberechtigungen...${COLOR_RESET}" + log "${COLOR_ACTION}Setze Dateiberechtigungen...${COLOR_RESET}" if ! sudo find "$webroot/$webverzeichnis" -type d -exec chmod 755 {} \; || \ ! sudo find "$webroot/$webverzeichnis" -type f -exec chmod 644 {} \; ; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Berechtigungen setzen fehlgeschlagen!${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Berechtigungen setzen fehlgeschlagen!${COLOR_RESET}" return 1 fi - echo -e "${COLOR_OK}✅ Erfolgreich installiert nach: ${COLOR_DIR}$webroot/$webverzeichnis${COLOR_RESET}" - echo -e " Benutzer/Gruppe: ${COLOR_INFO}$target_user:$target_group${COLOR_RESET}" + log "${COLOR_OK}✅ Erfolgreich installiert nach: ${COLOR_DIR}$webroot/$webverzeichnis${COLOR_RESET}" + log " Benutzer/Gruppe: ${COLOR_INFO}$target_user:$target_group${COLOR_RESET}" blankline return 0 } @@ -1054,11 +1108,11 @@ function versionrevision() { xflavour="Extended" if [[ ! -f "$file" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Datei nicht gefunden: ${COLOR_DIR}$file${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Datei nicht gefunden: ${COLOR_DIR}$file${COLOR_RESET}" return 1 fi - echo -e "${SYM_OK} ${COLOR_ACTION}Bearbeite Datei: ${COLOR_DIR}$file${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Bearbeite Datei: ${COLOR_DIR}$file${COLOR_RESET}" # Ändere Flavour.Dev sed -i 's/public const Flavour VERSION_FLAVOUR = Flavour\.[^;]*;/public const Flavour VERSION_FLAVOUR = Flavour.'"$xflavour"';/' "$file" @@ -1066,7 +1120,7 @@ function versionrevision() { # Entferne "Nessie" aus dem Versions-String sed -i 's/OpenSim {versionNumber} Nessie {flavour}/OpenSim {versionNumber} {flavour}/' "$file" - echo -e "${SYM_OK} ${COLOR_ACTION}Änderungen zu $xflavour wurden erfolgreich vorgenommen.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Änderungen zu $xflavour wurden erfolgreich vorgenommen.${COLOR_RESET}" blankline return 0 } @@ -1150,27 +1204,27 @@ function generate_all_name() { } function opensimbuild() { - echo -e "${COLOR_HEADING}🏗️ OpenSimulator Build-Prozess${COLOR_RESET}" + log "${COLOR_HEADING}🏗️ OpenSimulator Build-Prozess${COLOR_RESET}" - echo -e "${COLOR_LABEL}Möchten Sie den OpenSimulator jetzt erstellen? (${COLOR_OK}[ja]${COLOR_LABEL}/nein)${COLOR_RESET}" + log "${COLOR_LABEL}Möchten Sie den OpenSimulator jetzt erstellen? (${COLOR_OK}[ja]${COLOR_LABEL}/nein)${COLOR_RESET}" read -r user_choice user_choice=${user_choice:-ja} if [[ "$user_choice" == "ja" ]]; then if [[ -d "opensim" ]]; then - cd opensim || { echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler: Verzeichnis 'opensim' nicht gefunden.${COLOR_RESET}"; return 1; } - echo -e "${COLOR_ACTION}Starte Prebuild-Skript...${COLOR_RESET}" + cd opensim || { log "${SYM_BAD} ${COLOR_ERROR}Fehler: Verzeichnis 'opensim' nicht gefunden.${COLOR_RESET}"; return 1; } + log "${COLOR_ACTION}Starte Prebuild-Skript...${COLOR_RESET}" bash runprebuild.sh - echo -e "${COLOR_ACTION}Baue OpenSimulator...${COLOR_RESET}" + log "${COLOR_ACTION}Baue OpenSimulator...${COLOR_RESET}" dotnet build --configuration Release OpenSim.sln - echo -e "${SYM_OK} ${COLOR_ACTION}OpenSimulator wurde erfolgreich erstellt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}OpenSimulator wurde erfolgreich erstellt.${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}OpenSim Build Fehler: Das Verzeichnis 'opensim' existiert nicht.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}OpenSim Build Fehler: Das Verzeichnis 'opensim' existiert nicht.${COLOR_RESET}" return 1 fi else - echo -e "${SYM_BAD} ${COLOR_ERROR}Abbruch: OpenSimulator wird nicht erstellt.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Abbruch: OpenSimulator wird nicht erstellt.${COLOR_RESET}" fi # Wer in ein Verzeichnis wechselt sollte auch wieder zur vorherigen Verzeichnis wechseln! cd .. @@ -1192,32 +1246,32 @@ function removeconfigfiles() { } function createdirectory() { - echo -e "${COLOR_HEADING}📂 Verzeichniserstellung${COLOR_RESET}" + log "${COLOR_HEADING}📂 Verzeichniserstellung${COLOR_RESET}" - echo -e "${COLOR_LABEL}Möchten Sie einen Gridserver oder einen Regionsserver erstellen? (${COLOR_OK}[grid]${COLOR_LABEL}/region)${COLOR_RESET}" + log "${COLOR_LABEL}Möchten Sie einen Gridserver oder einen Regionsserver erstellen? (${COLOR_OK}[grid]${COLOR_LABEL}/region)${COLOR_RESET}" read -r server_type # Standardmäßig Gridserver wählen, falls keine Eingabe erfolgt server_type=${server_type:-grid} if [[ "$server_type" == "grid" ]]; then - echo -e "${COLOR_ACTION}Erstelle robust Verzeichnis...${COLOR_RESET}" + log "${COLOR_ACTION}Erstelle robust Verzeichnis...${COLOR_RESET}" mkdir -p robust/bin - echo -e "${SYM_OK} ${COLOR_ACTION}Robust Verzeichnis wurde erstellt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Robust Verzeichnis wurde erstellt.${COLOR_RESET}" # Nach der Erstellung des Gridservers auch die Regionsserver erstellen lassen - echo -e "${COLOR_LABEL}Wie viele Regionsserver benötigen Sie? ${COLOR_OK}[1]${COLOR_RESET}" + log "${COLOR_LABEL}Wie viele Regionsserver benötigen Sie? ${COLOR_OK}[1]${COLOR_RESET}" read -r num_regions # Standardmäßig 1 Region wählen, falls keine Eingabe erfolgt num_regions=${num_regions:-1} - echo -e "${SYM_OK} ${COLOR_ACTION}Sie haben $num_regions Regionsserver gew‰hlt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Sie haben $num_regions Regionsserver gew‰hlt.${COLOR_RESET}" elif [[ "$server_type" == "region" ]]; then - echo -e "${COLOR_LABEL}Wie viele Regionsserver benötigen Sie? ${COLOR_OK}[1]${COLOR_RESET}" + log "${COLOR_LABEL}Wie viele Regionsserver benötigen Sie? ${COLOR_OK}[1]${COLOR_RESET}" read -r num_regions - echo -e "${SYM_OK} ${COLOR_ACTION}Sie haben $num_regions Regionsserver gew‰hlt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Sie haben $num_regions Regionsserver gew‰hlt.${COLOR_RESET}" else - echo -e "${SYM_BAD} ${COLOR_ERROR}Ungültige Eingabe. Bitte geben Sie 'grid' oder 'region' ein.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Ungültige Eingabe. Bitte geben Sie 'grid' oder 'region' ein.${COLOR_RESET}" return 1 fi @@ -1227,46 +1281,46 @@ function createdirectory() { dir_name="sim$i" if [[ ! -d "$dir_name" ]]; then mkdir -p "$dir_name/bin" - echo -e "${SYM_OK} ${COLOR_DIR}$dir_name${COLOR_RESET} ${COLOR_ACTION}wurde erstellt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_DIR}$dir_name${COLOR_RESET} ${COLOR_ACTION}wurde erstellt.${COLOR_RESET}" sleep 1 else - echo -e "${SYM_OK} ${COLOR_DIR}$dir_name${COLOR_RESET} ${COLOR_WARNING}existiert bereits und wird übersprungen.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_DIR}$dir_name${COLOR_RESET} ${COLOR_WARNING}existiert bereits und wird übersprungen.${COLOR_RESET}" fi done else - echo -e "${SYM_BAD} ${COLOR_ERROR}Ungültige Anzahl an Regionsserver. Bitte geben Sie eine gültige Zahl zwischen 1 und 999 ein.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Ungültige Anzahl an Regionsserver. Bitte geben Sie eine gültige Zahl zwischen 1 und 999 ein.${COLOR_RESET}" fi blankline } function opensimcopy() { - echo -e "${COLOR_HEADING}📦 OpenSim Dateikopie${COLOR_RESET}" + log "${COLOR_HEADING}📦 OpenSim Dateikopie${COLOR_RESET}" # Prüfen, ob das Verzeichnis "opensim" existiert if [[ ! -d "opensim" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}OpenSim Copy Fehler: Das Verzeichnis 'opensim' existiert nicht.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}OpenSim Copy Fehler: Das Verzeichnis 'opensim' existiert nicht.${COLOR_RESET}" return 1 fi # Prüfen, ob das Unterverzeichnis "opensim/bin" existiert if [[ ! -d "opensim/bin" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}OpenSim Copy Fehler: Das Verzeichnis 'opensim/bin' existiert nicht.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}OpenSim Copy Fehler: Das Verzeichnis 'opensim/bin' existiert nicht.${COLOR_RESET}" return 1 fi # Prüfen, ob das Verzeichnis "robust" existiert und Dateien kopieren if [[ -d "robust/bin" ]]; then cp -r opensim/bin/* robust/bin - echo -e "${SYM_OK} ${COLOR_ACTION}Dateien aus ${COLOR_DIR}opensim/bin${COLOR_RESET} ${COLOR_ACTION}wurden nach ${COLOR_DIR}robust/bin${COLOR_RESET} ${COLOR_ACTION}kopiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Dateien aus ${COLOR_DIR}opensim/bin${COLOR_RESET} ${COLOR_ACTION}wurden nach ${COLOR_DIR}robust/bin${COLOR_RESET} ${COLOR_ACTION}kopiert.${COLOR_RESET}" else - echo -e "${COLOR_WARNING}⚠ ${COLOR_ACTION}Hinweis: 'robust' Verzeichnis nicht gefunden, keine Kopie durchgeführt.${COLOR_RESET}" + log "${COLOR_WARNING}⚠ ${COLOR_ACTION}Hinweis: 'robust' Verzeichnis nicht gefunden, keine Kopie durchgeführt.${COLOR_RESET}" fi # Alle simX-Verzeichnisse suchen und Dateien kopieren for sim_dir in sim*; do if [[ -d "$sim_dir/bin" ]]; then cp -r opensim/bin/* "$sim_dir/bin/" - echo -e "${SYM_OK} ${COLOR_ACTION}Dateien aus ${COLOR_DIR}opensim/bin${COLOR_RESET} ${COLOR_ACTION}wurden nach ${COLOR_DIR}$sim_dir/bin${COLOR_RESET} ${COLOR_ACTION}kopiert.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Dateien aus ${COLOR_DIR}opensim/bin${COLOR_RESET} ${COLOR_ACTION}wurden nach ${COLOR_DIR}$sim_dir/bin${COLOR_RESET} ${COLOR_ACTION}kopiert.${COLOR_RESET}" fi done @@ -1275,7 +1329,7 @@ function opensimcopy() { function database_setup() { # 30.04.2025 - echo -e "${COLOR_SECTION}=== MariaDB/MySQL Datenbank-Setup ===${COLOR_RESET}" + log "${COLOR_SECTION}=== MariaDB/MySQL Datenbank-Setup ===${COLOR_RESET}" # 1. Distribution Detection detect_distro() { @@ -1295,37 +1349,37 @@ function database_setup() { # 2. Support-Check if ! printf '%s\n' "${supported_distros[@]}" | grep -q "^${current_distro}$"; then - echo -e "${SYM_BAD} ${COLOR_BAD}Nicht unterstützte Distribution: '${current_distro}'${COLOR_RESET}" - echo -e "${SYM_INFO} Unterstützt: ${supported_distros[*]}" + log "${SYM_BAD} ${COLOR_BAD}Nicht unterstützte Distribution: '${current_distro}'${COLOR_RESET}" + log "${SYM_INFO} Unterstützt: ${supported_distros[*]}" return 1 fi # 3. Installation Check if ! command -v mariadb &> /dev/null && ! command -v mysql &> /dev/null; then - echo -e "${SYM_WAIT} ${COLOR_WARNING}MariaDB/MySQL ist nicht installiert${COLOR_RESET}" + log "${SYM_WAIT} ${COLOR_WARNING}MariaDB/MySQL ist nicht installiert${COLOR_RESET}" echo -ne "${COLOR_ACTION}MariaDB installieren? (j/n) [j] ${COLOR_RESET}" read -r install_choice install_choice=${install_choice:-j} - [[ "$install_choice" =~ ^[jJ] ]] || { echo -e "${SYM_BAD} Installation abgebrochen"; return 0; } + [[ "$install_choice" =~ ^[jJ] ]] || { log "${SYM_BAD} Installation abgebrochen"; return 0; } case $current_distro in debian|ubuntu|*mint|pop|zorin|elementary|kali|mx|raspbian) - echo -e "${SYM_INFO} ${COLOR_ACTION}Installiere MariaDB...${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_ACTION}Installiere MariaDB...${COLOR_RESET}" sudo apt-get update && sudo apt-get install -y mariadb-server ;; centos|fedora) - echo -e "${SYM_INFO} ${COLOR_ACTION}Installiere MariaDB...${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_ACTION}Installiere MariaDB...${COLOR_RESET}" sudo yum install -y mariadb-server sudo systemctl start mariadb sudo systemctl enable mariadb ;; - *) echo -e "${SYM_BAD} ${COLOR_BAD}Automatische Installation nicht verfügbar${COLOR_RESET}"; return 1 ;; + *) log "${SYM_BAD} ${COLOR_BAD}Automatische Installation nicht verfügbar${COLOR_RESET}"; return 1 ;; esac sudo mysql_secure_installation else - echo -e "${SYM_OK} ${COLOR_OK}MariaDB/MySQL ist bereits installiert${COLOR_RESET}" + log "${SYM_OK} ${COLOR_OK}MariaDB/MySQL ist bereits installiert${COLOR_RESET}" fi # 4. Benutzeranmeldedaten - echo -e "\n${COLOR_SECTION}=== Datenbank-Zugangsdaten ===${COLOR_RESET}" + log "\n${COLOR_SECTION}=== Datenbank-Zugangsdaten ===${COLOR_RESET}" echo -ne "${COLOR_ACTION}Zufallszugangsdaten verwenden? (j/n) [j] ${COLOR_RESET}" read -r default_cred_choice default_cred_choice=${default_cred_choice:-j} @@ -1333,7 +1387,7 @@ function database_setup() { if [[ "$default_cred_choice" =~ ^[jJ] ]]; then db_user="${genDatabaseUserName}" db_pass=$(tr -dc 'A-Za-z0-9!@#$%^&*()' < /dev/urandom | head -c 16) - echo -e "${SYM_INFO} ${COLOR_LABEL}Generiertes Passwort: ${COLOR_VALUE}${db_pass}${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_LABEL}Generiertes Passwort: ${COLOR_VALUE}${db_pass}${COLOR_RESET}" else echo -ne "${COLOR_ACTION}DB_Benutzername: ${COLOR_RESET}" read -r db_user @@ -1346,27 +1400,27 @@ function database_setup() { local ini_file="${SCRIPT_DIR}/UserInfo.ini" if [[ ! -f "$ini_file" ]]; then - echo -e "${COLOR_INFO}Erstelle UserInfo.ini${COLOR_RESET}" + log "${COLOR_INFO}Erstelle UserInfo.ini${COLOR_RESET}" sudo touch "$ini_file" fi - echo -e "\n[DatabaseData]" | sudo tee -a "$ini_file" >/dev/null + log "\n[DatabaseData]" | sudo tee -a "$ini_file" >/dev/null echo "DB_Benutzername = ${db_user}" | sudo tee -a "$ini_file" >/dev/null echo "DB_Passwort = ${db_pass}" | sudo tee -a "$ini_file" >/dev/null - echo -e "${SYM_LOG} ${COLOR_LABEL}Datenbank-Zugangsdaten gespeichert in: ${COLOR_FILE}${ini_file}${COLOR_RESET}" + log "${SYM_LOG} ${COLOR_LABEL}Datenbank-Zugangsdaten gespeichert in: ${COLOR_FILE}${ini_file}${COLOR_RESET}" # 6. Datenbankeinrichtung - echo -e "\n${COLOR_SECTION}=== Datenbank-Konfiguration ===${COLOR_RESET}" + log "\n${COLOR_SECTION}=== Datenbank-Konfiguration ===${COLOR_RESET}" # RobustServer DB if [[ -d "robust" ]]; then if ! sudo mysql -e "USE robust" &> /dev/null; then sudo mysql -e "CREATE DATABASE robust CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" - echo -e "${SYM_OK} ${COLOR_VALUE}robust${COLOR_RESET} Datenbank angelegt" + log "${SYM_OK} ${COLOR_VALUE}robust${COLOR_RESET} Datenbank angelegt" else - echo -e "${SYM_INFO} ${COLOR_WARNING}robust-Datenbank existiert bereits${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_WARNING}robust-Datenbank existiert bereits${COLOR_RESET}" fi fi @@ -1376,9 +1430,9 @@ function database_setup() { db_name="sim${i}" if ! sudo mysql -e "USE ${db_name}" &> /dev/null; then sudo mysql -e "CREATE DATABASE ${db_name} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" - echo -e "${SYM_OK} ${COLOR_VALUE}${db_name}${COLOR_RESET} Datenbank angelegt" + log "${SYM_OK} ${COLOR_VALUE}${db_name}${COLOR_RESET} Datenbank angelegt" else - echo -e "${SYM_INFO} ${COLOR_WARNING}${db_name}-Datenbank existiert bereits${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_WARNING}${db_name}-Datenbank existiert bereits${COLOR_RESET}" fi fi done @@ -1386,9 +1440,9 @@ function database_setup() { # Benutzerverwaltung if ! sudo mysql -e "SELECT user FROM mysql.user WHERE user='${db_user}' AND host='localhost'" | grep -q "${db_user}"; then sudo mysql -e "CREATE USER '${db_user}'@'localhost' IDENTIFIED BY '${db_pass}'" - echo -e "${SYM_OK} ${COLOR_VALUE}${db_user}${COLOR_RESET} Benutzer angelegt" + log "${SYM_OK} ${COLOR_VALUE}${db_user}${COLOR_RESET} Benutzer angelegt" else - echo -e "${SYM_INFO} ${COLOR_WARNING}Benutzer ${db_user} existiert bereits${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_WARNING}Benutzer ${db_user} existiert bereits${COLOR_RESET}" fi # Rechte vergeben @@ -1398,7 +1452,7 @@ function database_setup() { done sudo mysql -e "FLUSH PRIVILEGES" - echo -e "${COLOR_OK} Datenbank Setup abgeschlossen!${COLOR_RESET}" + log "${COLOR_OK} Datenbank Setup abgeschlossen!${COLOR_RESET}" } @@ -1408,7 +1462,7 @@ function createmasteruser() { # RobustServer starten echo "RobustServer starten, erster start..." if [[ -d "robust/bin" && -f "robust/bin/Robust.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}RobustServer ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}RobustServer ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}robust/bin...${COLOR_RESET}" cd robust/bin || exit 1 # -inifile=Robust.HG.ini @@ -1416,7 +1470,7 @@ function createmasteruser() { cd - >/dev/null 2>&1 || exit 1 sleep $RobustServer_Start_wait else - echo -e "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Robust.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}RobustServer: ${COLOR_BAD}Robust.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" fi genPasswort=$(tr -dc 'A-Za-z0-9!@#$%^&*()' < /dev/urandom | head -c 16) @@ -1428,7 +1482,7 @@ function createmasteruser() { local EMAIL="${4:-${genFirstname}@${genLastname}.com}" userid="${5:-$genUserid}" - echo -e "${COLOR_INFO}Master User Erstellung (Enter für generierte Werte)${COLOR_RESET}" + log "${COLOR_INFO}Master User Erstellung (Enter für generierte Werte)${COLOR_RESET}" echo -n "Vorname [${VORNAME}]: " read -r input @@ -1452,7 +1506,7 @@ function createmasteruser() { # Überprüfe ob Robust läuft if ! screen -list | grep -q "robustserver"; then - echo -e "${COLOR_BAD}CREATEUSER: Robust existiert nicht oder läuft nicht${COLOR_RESET}" + log "${COLOR_BAD}CREATEUSER: Robust existiert nicht oder läuft nicht${COLOR_RESET}" return 1 fi @@ -1465,18 +1519,18 @@ function createmasteruser() { screen -S robustserver -p 0 -X eval "stuff '$userid'^M" screen -S robustserver -p 0 -X eval "stuff 'Ruth'^M" - echo -e "${COLOR_OK}Masteruser $VORNAME $NACHNAME wurde erstellt${COLOR_RESET}" - echo -e "${COLOR_INFO}UserID: $userid${COLOR_RESET}" + log "${COLOR_OK}Masteruser $VORNAME $NACHNAME wurde erstellt${COLOR_RESET}" + log "${COLOR_INFO}UserID: $userid${COLOR_RESET}" # **Speicherung der Benutzerdaten in UserInfo.ini** NEU local ini_file="${SCRIPT_DIR}/UserInfo.ini" if [[ ! -f "$ini_file" ]]; then - echo -e "${COLOR_INFO}Erstelle UserInfo.ini${COLOR_RESET}" + log "${COLOR_INFO}Erstelle UserInfo.ini${COLOR_RESET}" sudo touch "$ini_file" fi - echo -e "\n[UserData]" | sudo tee -a "$ini_file" >/dev/null + log "\n[UserData]" | sudo tee -a "$ini_file" >/dev/null echo "Vorname = ${VORNAME}" | sudo tee -a "$ini_file" >/dev/null echo "Nachname = ${NACHNAME}" | sudo tee -a "$ini_file" >/dev/null echo "Passwort = ${PASSWORT}" | sudo tee -a "$ini_file" >/dev/null @@ -1484,38 +1538,38 @@ function createmasteruser() { echo "UserID = ${userid}" | sudo tee -a "$ini_file" >/dev/null - echo -e "${SYM_LOG} ${COLOR_LABEL}Benutzerdaten hinzugefügt in: ${COLOR_FILE}${ini_file}${COLOR_RESET}" + log "${SYM_LOG} ${COLOR_LABEL}Benutzerdaten hinzugefügt in: ${COLOR_FILE}${ini_file}${COLOR_RESET}" blankline } function createmasterestate() { # 02.05.2025 Master Estate - echo -e "${COLOR_HEADING}🏡 Master Estate Erstellung${COLOR_RESET}" + log "${COLOR_HEADING}🏡 Master Estate Erstellung${COLOR_RESET}" # sim1 starten echo "Sim1 Welcome starten, erster start..." if [[ -d "sim1/bin" && -f "sim1/bin/OpenSim.dll" ]]; then - echo -e "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim1 ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}sim1/bin...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_START}Starte ${COLOR_SERVER}sim1 ${COLOR_RESET} ${COLOR_START}aus ${COLOR_DIR}sim1/bin...${COLOR_RESET}" cd sim1/bin || exit 1 screen -fa -S sim1 -d -U -m dotnet OpenSim.dll cd - >/dev/null 2>&1 || exit 1 sleep 10 else - echo -e "${SYM_BAD} ${COLOR_SERVER}sim1: ${COLOR_BAD}OpenSim.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_SERVER}sim1: ${COLOR_BAD}OpenSim.dll nicht gefunden.${COLOR_RESET} ${COLOR_START}Überspringe Start.${COLOR_RESET}" fi # 1. Überprüfe ob sim1 läuft if ! screen -list | grep -q "sim1"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}CREATEESTATE: sim1 existiert nicht oder läuft nicht${COLOR_RESET}" - echo -e "${COLOR_INFO}Tipp: Starten Sie die Simulator-Instanz zuerst${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}CREATEESTATE: sim1 existiert nicht oder läuft nicht${COLOR_RESET}" + log "${COLOR_INFO}Tipp: Starten Sie die Simulator-Instanz zuerst${COLOR_RESET}" return 1 fi # 1. INI-Datei auslesen mit angepasstem Parsing local ini_file="${SCRIPT_DIR}/UserInfo.ini" if [[ ! -f "$ini_file" ]]; then - echo -e "${COLOR_BAD}UserInfo.ini nicht gefunden unter: $ini_file${COLOR_RESET}" + log "${COLOR_BAD}UserInfo.ini nicht gefunden unter: $ini_file${COLOR_RESET}" return 1 fi @@ -1539,53 +1593,53 @@ function createmasterestate() { NACHNAME=$(ini_get "UserData" "Nachname") # Debug-Ausgabe - echo -e "${COLOR_DEBUG}Gelesene Werte:" - echo -e "GridName: '${gridname:-NICHT GEFUNDEN}'" - echo -e "Vorname: '${VORNAME:-NICHT GEFUNDEN}'" - echo -e "Nachname: '${NACHNAME:-NICHT GEFUNDEN}'${COLOR_RESET}" + log "${COLOR_DEBUG}Gelesene Werte:" + log "GridName: '${gridname:-NICHT GEFUNDEN}'" + log "Vorname: '${VORNAME:-NICHT GEFUNDEN}'" + log "Nachname: '${NACHNAME:-NICHT GEFUNDEN}'${COLOR_RESET}" if [[ -z "$gridname" || -z "$VORNAME" || -z "$NACHNAME" ]]; then - echo -e "${COLOR_BAD}Fehlende Daten in UserInfo.ini${COLOR_RESET}" - echo -e "Bitte überprüfen Sie folgende Einträge:" - echo -e "[ServerData]" - echo -e "GridName = ..." - echo -e "[UserData]" - echo -e "Vorname = ..." - echo -e "Nachname = ..." + log "${COLOR_BAD}Fehlende Daten in UserInfo.ini${COLOR_RESET}" + log "Bitte überprüfen Sie folgende Einträge:" + log "[ServerData]" + log "GridName = ..." + log "[UserData]" + log "Vorname = ..." + log "Nachname = ..." return 1 fi # 3. Logging vor der Ausführung - echo -e "${COLOR_INFO}Erstelle Master Estate für:" - echo -e "- Grid: ${COLOR_VALUE}$gridname" - echo -e "- Avatar: ${COLOR_VALUE}$VORNAME $NACHNAME${COLOR_RESET}" + log "${COLOR_INFO}Erstelle Master Estate für:" + log "- Grid: ${COLOR_VALUE}$gridname" + log "- Avatar: ${COLOR_VALUE}$VORNAME $NACHNAME${COLOR_RESET}" # 4. Befehle an sim1 senden mit Fehlerprüfung if ! screen -S sim1 -p 0 -X eval "stuff '$gridname Estate'^M"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden des Estate-Befehls${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden des Estate-Befehls${COLOR_RESET}" return 1 fi sleep 1 # Kurze Pause zwischen den Befehlen if ! screen -S sim1 -p 0 -X eval "stuff '$VORNAME'^M"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden des Vornamens${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden des Vornamens${COLOR_RESET}" return 1 fi sleep 1 if ! screen -S sim1 -p 0 -X eval "stuff '$NACHNAME'^M"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden des Nachnamens${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden des Nachnamens${COLOR_RESET}" return 1 fi # 5. Erfolgsmeldung - echo -e "${SYM_OK} ${COLOR_OK}Master Estate erfolgreich erstellt${COLOR_RESET}" - echo -e "${COLOR_INFO}Starte nun die Estate-Akzeptierung für alle Regionen...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_OK}Master Estate erfolgreich erstellt${COLOR_RESET}" + log "${COLOR_INFO}Starte nun die Estate-Akzeptierung für alle Regionen...${COLOR_RESET}" blankline # 6. Alle anderen Starten und Estate akzeptieren if ! createmasterestateall; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler bei createmasterestateall${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler bei createmasterestateall${COLOR_RESET}" return 1 fi @@ -1594,12 +1648,12 @@ function createmasterestate() { function createmasterestateall() { # 02.05.2025 Master Estate Bestätigung mit Simulator-Start - echo -e "${COLOR_HEADING}🌍 Starte Simulatoren & bestätige Master Estate${COLOR_RESET}" + log "${COLOR_HEADING}🌍 Starte Simulatoren & bestätige Master Estate${COLOR_RESET}" # 1. INI-Datei auslesen mit angepasstem Parsing local ini_file="${SCRIPT_DIR}/UserInfo.ini" if [[ ! -f "$ini_file" ]]; then - echo -e "${COLOR_BAD}UserInfo.ini nicht gefunden unter: $ini_file${COLOR_RESET}" + log "${COLOR_BAD}UserInfo.ini nicht gefunden unter: $ini_file${COLOR_RESET}" return 1 fi @@ -1623,24 +1677,24 @@ function createmasterestateall() { NACHNAME=$(ini_get "UserData" "Nachname") # Debug-Ausgabe - echo -e "${COLOR_DEBUG}Gelesene Werte:" - echo -e "GridName: '${gridname:-NICHT GEFUNDEN}'" - echo -e "Vorname: '${VORNAME:-NICHT GEFUNDEN}'" - echo -e "Nachname: '${NACHNAME:-NICHT GEFUNDEN}'${COLOR_RESET}" + log "${COLOR_DEBUG}Gelesene Werte:" + log "GridName: '${gridname:-NICHT GEFUNDEN}'" + log "Vorname: '${VORNAME:-NICHT GEFUNDEN}'" + log "Nachname: '${NACHNAME:-NICHT GEFUNDEN}'${COLOR_RESET}" if [[ -z "$gridname" || -z "$VORNAME" || -z "$NACHNAME" ]]; then - echo -e "${COLOR_BAD}Fehlende Daten in UserInfo.ini${COLOR_RESET}" - echo -e "Bitte überprüfen Sie folgende Einträge:" - echo -e "[ServerData]" - echo -e "GridName = ..." - echo -e "[UserData]" - echo -e "Vorname = ..." - echo -e "Nachname = ..." + log "${COLOR_BAD}Fehlende Daten in UserInfo.ini${COLOR_RESET}" + log "Bitte überprüfen Sie folgende Einträge:" + log "[ServerData]" + log "GridName = ..." + log "[UserData]" + log "Vorname = ..." + log "Nachname = ..." return 1 fi # 2. Starte alle Simulatoren - echo -e "${COLOR_ACTION}Starte Simulator-Instanzen...${COLOR_RESET}" + log "${COLOR_ACTION}Starte Simulator-Instanzen...${COLOR_RESET}" local started_sims=0 for ((i=2; i<=999; i++)); do @@ -1649,11 +1703,11 @@ function createmasterestateall() { echo -n -e "${SYM_INFO} ${COLOR_DIR}sim$i: ${COLOR_RESET}" if cd "$sim_dir" && screen -fa -S "sim$i" -d -U -m dotnet OpenSim.dll; then - echo -e "${COLOR_OK}gestartet${COLOR_RESET}" + log "${COLOR_OK}gestartet${COLOR_RESET}" ((started_sims++)) sleep "${Simulator_Start_wait:-5}" else - echo -e "${COLOR_ERROR}start fehlgeschlagen${COLOR_RESET}" + log "${COLOR_ERROR}start fehlgeschlagen${COLOR_RESET}" fi cd - >/dev/null 2>&1 fi @@ -1661,7 +1715,7 @@ function createmasterestateall() { # 3. Estate-Bestätigung für alle Regionen if [[ $started_sims -gt 0 ]]; then - echo -e "${COLOR_ACTION}Bestätige Estate für $started_sims Simulator(en)...${COLOR_RESET}" + log "${COLOR_ACTION}Bestätige Estate für $started_sims Simulator(en)...${COLOR_RESET}" for ((i=2; i<=999; i++)); do if screen -list | grep -q "sim$i"; then @@ -1669,37 +1723,37 @@ function createmasterestateall() { if [[ -d "$regions_dir" ]]; then # Zähle die Anzahl der Regionen-Konfigurationen region_count=$(find "$regions_dir" -maxdepth 1 -name "*.ini" | wc -l) - echo -e "${SYM_INFO} ${COLOR_DIR}sim$i: ${region_count} Region(en) gefunden${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_DIR}sim$i: ${region_count} Region(en) gefunden${COLOR_RESET}" # Für jede Region die Bestätigung senden for ((r=1; r<=region_count; r++)); do echo -n -e " ${SYM_INFO} Region ${r}: ${COLOR_RESET}" if ! screen -S "sim$i" -p 0 -X eval "stuff 'yes'^M"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden von yes${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden von yes${COLOR_RESET}" return 1 fi sleep 1 if ! screen -S "sim$i" -p 0 -X eval "stuff '$gridname Estate'^M"; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden von $gridname Estate${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler beim Senden von $gridname Estate${COLOR_RESET}" return 1 fi - echo -e "${COLOR_OK}bestätigt${COLOR_RESET}" + log "${COLOR_OK}bestätigt${COLOR_RESET}" sleep 1 done else - echo -e "${SYM_WARNING} ${COLOR_WARNING}sim$i: Kein Regions-Verzeichnis gefunden${COLOR_RESET}" + log "${SYM_WARNING} ${COLOR_WARNING}sim$i: Kein Regions-Verzeichnis gefunden${COLOR_RESET}" sleep 1 fi fi done else - echo -e "${SYM_WARNING} ${COLOR_WARNING}Keine Simulatoren gestartet!${COLOR_RESET}" + log "${SYM_WARNING} ${COLOR_WARNING}Keine Simulatoren gestartet!${COLOR_RESET}" return 1 fi - echo -e "${SYM_OK} ${COLOR_OK}$started_sims Simulatoren gestartet & Estate für alle Regionen bestätigt${COLOR_RESET}" + log "${SYM_OK} ${COLOR_OK}$started_sims Simulatoren gestartet & Estate für alle Regionen bestätigt${COLOR_RESET}" sleep 1 blankline return 0 @@ -1732,41 +1786,41 @@ function setcrontab() { # Strict Mode: Fehler sofort erkennen set -euo pipefail - echo -e "${COLOR_HEADING}⏰ Cron-Job-Einrichtung (Interaktiv)${COLOR_RESET}" + log "${COLOR_HEADING}⏰ Cron-Job-Einrichtung (Interaktiv)${COLOR_RESET}" # Sicherheitsabfrage: Nur als root/sudo ausführen if [ "$(id -u)" -ne 0 ]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}FEHLER: Dieses Skript benötigt root-Rechte! (sudo verwenden)${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_ERROR}FEHLER: Dieses Skript benötigt root-Rechte! (sudo verwenden)${COLOR_RESET}" >&2 return 1 fi # Prüfen, ob SCRIPT_DIR gesetzt und gültig ist if [ -z "${SCRIPT_DIR:-}" ]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}FEHLER: 'SCRIPT_DIR' muss gesetzt sein!${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_ERROR}FEHLER: 'SCRIPT_DIR' muss gesetzt sein!${COLOR_RESET}" >&2 return 1 fi if [ ! -d "$SCRIPT_DIR" ]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}FEHLER: Verzeichnis '${COLOR_DIR}$SCRIPT_DIR${COLOR_ERROR}' existiert nicht!${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_ERROR}FEHLER: Verzeichnis '${COLOR_DIR}$SCRIPT_DIR${COLOR_ERROR}' existiert nicht!${COLOR_RESET}" >&2 return 1 fi # Temporäre Datei für neue Cron-Jobs local temp_cron temp_cron=$(mktemp) || { - echo -e "${SYM_BAD} ${COLOR_ERROR}FEHLER: Temp-Datei konnte nicht erstellt werden.${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_ERROR}FEHLER: Temp-Datei konnte nicht erstellt werden.${COLOR_RESET}" >&2 return 1 } ### Interaktive Abfragen ### - echo -e "\n${COLOR_VALUE}=== Wartung am 1. des Monats ===${COLOR_RESET}" - echo -e "Welche Aktionen sollen ausgeführt werden? (Mehrfachauswahl möglich)" - echo -e " ${SYM_INFO} 1) Nichts (deaktivieren)" - echo -e " ${SYM_INFO} 2) cacheclean (inkl. automatischem stop vorher)" - echo -e " ${SYM_INFO} 3) mapclean (inkl. automatischem stop vorher)" - echo -e " ${SYM_INFO} 4) logclean (inkl. automatischem stop vorher)" - echo -e " ${SYM_INFO} 5) Vollständiger Neustart (stop → cacheclean → mapclean → logclean → reboot)" - echo -e " ${SYM_INFO} 6) Nur Server neustarten (reboot)" + log "\n${COLOR_VALUE}=== Wartung am 1. des Monats ===${COLOR_RESET}" + log "Welche Aktionen sollen ausgeführt werden? (Mehrfachauswahl möglich)" + log " ${SYM_INFO} 1) Nichts (deaktivieren)" + log " ${SYM_INFO} 2) cacheclean (inkl. automatischem stop vorher)" + log " ${SYM_INFO} 3) mapclean (inkl. automatischem stop vorher)" + log " ${SYM_INFO} 4) logclean (inkl. automatischem stop vorher)" + log " ${SYM_INFO} 5) Vollständiger Neustart (stop → cacheclean → mapclean → logclean → reboot)" + log " ${SYM_INFO} 6) Nur Server neustarten (reboot)" read -r -p "Auswahl (z.B. '2 3' oder '5'): " -a monthly_actions # Abfrage ob nach clean-Operationen ein reboot erfolgen soll @@ -1776,14 +1830,14 @@ function setcrontab() { [[ "$add_reboot" =~ [jJ] ]] && needs_reboot=true fi - echo -e "\n${COLOR_VALUE}=== Tägliche Wartung ===${COLOR_RESET}" + log "\n${COLOR_VALUE}=== Tägliche Wartung ===${COLOR_RESET}" read -r -p "Soll ein täglicher Restart durchgeführt werden? (j/n) " daily_restart if [[ "$daily_restart" =~ [jJ] ]]; then read -r -p "Uhrzeit (Stunde, 0-23): " daily_hour daily_hour=${daily_hour:-5} # Default: 5 Uhr fi - echo -e "\n${COLOR_VALUE}=== Überwachung ===${COLOR_RESET}" + log "\n${COLOR_VALUE}=== Überwachung ===${COLOR_RESET}" read -r -p "Soll die Überwachung aktiviert werden? (j/n) " enable_monitoring if [[ "$enable_monitoring" =~ [jJ] ]]; then read -r -p "Intervall in Minuten (Standard: 30): " monitor_interval @@ -1839,31 +1893,31 @@ function setcrontab() { # Tägliche Wartung if [[ "$daily_restart" =~ [jJ] ]]; then - echo -e "\n# Täglicher Restart" + log "\n# Täglicher Restart" echo "0 ${daily_hour} * * * bash '$SCRIPT_DIR/osmtool.sh' restart" else - echo -e "\n# Deaktiviert: Täglicher Restart" + log "\n# Deaktiviert: Täglicher Restart" fi # Überwachung if [[ "$enable_monitoring" =~ [jJ] ]]; then - echo -e "\n# Überwachung" + log "\n# Überwachung" echo "*/${monitor_interval} * * * * bash '$SCRIPT_DIR/osmtool.sh' check_screens" else - echo -e "\n# Deaktiviert: Überwachung" + log "\n# Deaktiviert: Überwachung" fi } > "$temp_cron" # Cron-Jobs installieren if crontab "$temp_cron"; then rm -f "$temp_cron" - echo -e "\n${SYM_OK} ${COLOR_OK}Cron-Jobs wurden aktualisiert:${COLOR_RESET}" + log "\n${SYM_OK} ${COLOR_OK}Cron-Jobs wurden aktualisiert:${COLOR_RESET}" crontab -l | grep -v '^#' | sed '/^$/d' | while read -r line; do - echo -e "${COLOR_DIR}$line${COLOR_RESET}" + log "${COLOR_DIR}$line${COLOR_RESET}" done return 0 else - echo -e "${SYM_BAD} ${COLOR_ERROR}FEHLER: Installation fehlgeschlagen. Prüfe $temp_cron manuell.${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_ERROR}FEHLER: Installation fehlgeschlagen. Prüfe $temp_cron manuell.${COLOR_RESET}" >&2 return 1 fi } @@ -1894,38 +1948,38 @@ calculate_relative_time() { #?────────────────────────────────────────────────────────────────────────────────────────── function opensimupgrade() { - echo -e "\n${COLOR_WARNING}⚠ Der OpenSimulator muss zuerst im Verzeichnis 'opensim' vorliegen!${COLOR_RESET}" - echo -e "${COLOR_LABEL}Möchten Sie den OpenSimulator aktualisieren? (${COLOR_BAD}[no]${COLOR_LABEL}/yes)${COLOR_RESET}" + log "\n${COLOR_WARNING}⚠ Der OpenSimulator muss zuerst im Verzeichnis 'opensim' vorliegen!${COLOR_RESET}" + log "${COLOR_LABEL}Möchten Sie den OpenSimulator aktualisieren? (${COLOR_BAD}[no]${COLOR_LABEL}/yes)${COLOR_RESET}" read -r user_choice user_choice=${user_choice:-no} # Prüfe, ob das Verzeichnis vorhanden ist if [[ ! -d "opensim" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler: Das Verzeichnis '${COLOR_DIR}opensim${COLOR_ERROR}' existiert nicht${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler: Das Verzeichnis '${COLOR_DIR}opensim${COLOR_ERROR}' existiert nicht${COLOR_RESET}" return 1 fi # Prüfe, ob im Verzeichnis 'opensim/bin' die Dateien OpenSim.dll und Robust.dll vorhanden sind if [[ ! -f "opensim/bin/OpenSim.dll" || ! -f "opensim/bin/Robust.dll" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Fehler: Benötigte Dateien (OpenSim.dll und/oder Robust.dll) fehlen im Verzeichnis '${COLOR_DIR}opensim/bin${COLOR_ERROR}'${COLOR_RESET}" - echo -e "\n${COLOR_WARNING}❓ Haben Sie vergessen den OpenSimulator zuerst zu Kompilieren?${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Fehler: Benötigte Dateien (OpenSim.dll und/oder Robust.dll) fehlen im Verzeichnis '${COLOR_DIR}opensim/bin${COLOR_ERROR}'${COLOR_RESET}" + log "\n${COLOR_WARNING}❓ Haben Sie vergessen den OpenSimulator zuerst zu Kompilieren?${COLOR_RESET}" return 1 fi if [[ "$user_choice" == "yes" ]]; then - echo -e "${COLOR_ACTION}OpenSimulator wird gestoppt...${COLOR_RESET}" + log "${COLOR_ACTION}OpenSimulator wird gestoppt...${COLOR_RESET}" opensimstop sleep $Simulator_Stop_wait - echo -e "${COLOR_ACTION}OpenSimulator wird kopiert...${COLOR_RESET}" + log "${COLOR_ACTION}OpenSimulator wird kopiert...${COLOR_RESET}" opensimcopy - echo -e "${COLOR_ACTION}OpenSimulator wird gestartet...${COLOR_RESET}" + log "${COLOR_ACTION}OpenSimulator wird gestartet...${COLOR_RESET}" opensimstart - echo -e "${COLOR_OK}✔ ${COLOR_ACTION}Upgrade abgeschlossen.${COLOR_RESET}" + log "${COLOR_OK}✔ ${COLOR_ACTION}Upgrade abgeschlossen.${COLOR_RESET}" else - echo -e "${COLOR_WARNING}Upgrade vom Benutzer abgebrochen.${COLOR_RESET}" + log "${COLOR_WARNING}Upgrade vom Benutzer abgebrochen.${COLOR_RESET}" fi blankline } @@ -1935,11 +1989,11 @@ function opensimupgrade() { #?────────────────────────────────────────────────────────────────────────────────────────── function dataclean() { - echo -e "${COLOR_HEADING}🧹 Datenbereinigung wird durchgeführt...${COLOR_RESET}" + log "${COLOR_HEADING}🧹 Datenbereinigung wird durchgeführt...${COLOR_RESET}" # RobustServer bereinigen if [[ -d "robust/bin" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Lösche Dateien im RobustServer...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Lösche Dateien im RobustServer...${COLOR_RESET}" find "robust/bin" -maxdepth 1 -type f \( -name "*.log" -o -name "*.dll" -o -name "*.exe" -o -name "*.so" -o -name "*.xml" -o -name "*.dylib" -o -name "*.example" -o -name "*.sample" -o -name "*.txt" -o -name "*.config" -o -name "*.py" -o -name "*.old" -o -name "*.pdb" \) -delete fi @@ -1947,12 +2001,12 @@ function dataclean() { for ((i=1; i<=999; i++)); do sim_dir="sim$i/bin" if [[ -d "$sim_dir" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Lösche Dateien in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Lösche Dateien in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" find "$sim_dir" -maxdepth 1 -type f \( -name "*.log" -o -name "*.dll" -o -name "*.exe" -o -name "*.so" -o -name "*.xml" -o -name "*.dylib" -o -name "*.example" -o -name "*.sample" -o -name "*.txt" -o -name "*.config" -o -name "*.py" -o -name "*.old" -o -name "*.pdb" \) -delete sleep 1 fi done - echo -e "${COLOR_HEADING}✅ Datenbereinigung abgeschlossen${COLOR_RESET}" + log "${COLOR_HEADING}✅ Datenbereinigung abgeschlossen${COLOR_RESET}" blankline } @@ -1960,18 +2014,18 @@ function pathclean() { directories=("assetcache" "maptiles" "MeshCache" "j2kDecodeCache" "ScriptEngines" "bakes" "addon-modules") wildcard_dirs=("addin-db-*") # Separate Liste für Wildcard-Verzeichnisse - echo -e "${COLOR_HEADING}🗂️ Verzeichnisbereinigung wird durchgeführt...${COLOR_RESET}" + log "${COLOR_HEADING}🗂️ Verzeichnisbereinigung wird durchgeführt...${COLOR_RESET}" # RobustServer bereinigen if [[ -d "robust/bin" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Lösche komplette Verzeichnisse im RobustServer...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Lösche komplette Verzeichnisse im RobustServer...${COLOR_RESET}" # Normale Verzeichnisse for dir in "${directories[@]}"; do target="robust/bin/$dir" if [[ -d "$target" ]]; then rm -rf "$target" - echo -e " ${COLOR_ACTION}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" + log " ${COLOR_ACTION}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" fi done @@ -1980,7 +2034,7 @@ function pathclean() { for target in robust/bin/$pattern; do if [[ -d "$target" ]]; then rm -rf "$target" - echo -e " ${COLOR_WARNING}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" + log " ${COLOR_WARNING}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" fi done done @@ -1990,14 +2044,14 @@ function pathclean() { for ((i=1; i<=999; i++)); do sim_dir="sim$i/bin" if [[ -d "$sim_dir" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Lösche komplette Verzeichnisse in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Lösche komplette Verzeichnisse in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" # Normale Verzeichnisse for dir in "${directories[@]}"; do target="$sim_dir/$dir" if [[ -d "$target" ]]; then rm -rf "$target" - echo -e " ${COLOR_ACTION}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" + log " ${COLOR_ACTION}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" sleep 1 fi done @@ -2007,13 +2061,13 @@ function pathclean() { for target in $sim_dir/$pattern; do if [[ -d "$target" ]]; then rm -rf "$target" - echo -e " ${COLOR_WARNING}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" + log " ${COLOR_WARNING}Verzeichnis gelöscht: ${COLOR_DIR}$target${COLOR_RESET}" fi done done fi done - echo -e "${COLOR_HEADING}✅ Verzeichnisbereinigung abgeschlossen${COLOR_RESET}" + log "${COLOR_HEADING}✅ Verzeichnisbereinigung abgeschlossen${COLOR_RESET}" blankline } @@ -2021,16 +2075,16 @@ function cacheclean() { #cache_dirs=("assetcache" "maptiles" "MeshCache" "j2kDecodeCache" "ScriptEngines") cache_dirs=("assetcache" "MeshCache" "j2kDecodeCache" "ScriptEngines") - echo -e "${COLOR_HEADING}♻️ Cache-Bereinigung wird durchgeführt...${COLOR_RESET}" + log "${COLOR_HEADING}♻️ Cache-Bereinigung wird durchgeführt...${COLOR_RESET}" # RobustServer bereinigen if [[ -d "robust/bin" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Leere Cache-Verzeichnisse im RobustServer...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Leere Cache-Verzeichnisse im RobustServer...${COLOR_RESET}" for dir in "${cache_dirs[@]}"; do target="robust/bin/$dir" if [[ -d "$target" ]]; then find "$target" -mindepth 1 -delete - echo -e " ${COLOR_ACTION}Inhalt geleert: ${COLOR_DIR}$target${COLOR_RESET}" + log " ${COLOR_ACTION}Inhalt geleert: ${COLOR_DIR}$target${COLOR_RESET}" fi done fi @@ -2039,27 +2093,27 @@ function cacheclean() { for ((i=1; i<=999; i++)); do sim_dir="sim$i/bin" if [[ -d "$sim_dir" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Leere Cache-Verzeichnisse in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Leere Cache-Verzeichnisse in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" for dir in "${cache_dirs[@]}"; do target="$sim_dir/$dir" if [[ -d "$target" ]]; then find "$target" -mindepth 1 -delete - echo -e " ${COLOR_ACTION}Inhalt geleert: ${COLOR_DIR}$target${COLOR_RESET}" + log " ${COLOR_ACTION}Inhalt geleert: ${COLOR_DIR}$target${COLOR_RESET}" sleep 1 fi done fi done - echo -e "${COLOR_HEADING}✅ Cache-Bereinigung abgeschlossen${COLOR_RESET}" + log "${COLOR_HEADING}✅ Cache-Bereinigung abgeschlossen${COLOR_RESET}" blankline } function logclean() { - echo -e "${SYM_LOG}${COLOR_HEADING} Log-Bereinigung wird durchgeführt...${COLOR_RESET}" + log "${SYM_LOG}${COLOR_HEADING} Log-Bereinigung wird durchgeführt...${COLOR_RESET}" # RobustServer bereinigen if [[ -d "robust/bin" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Lösche Log-Dateien in ${COLOR_DIR}robust/bin...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Lösche Log-Dateien in ${COLOR_DIR}robust/bin...${COLOR_RESET}" rm -f robust/bin/*.log fi @@ -2067,23 +2121,23 @@ function logclean() { for ((i=1; i<=999; i++)); do sim_dir="sim$i/bin" if [[ -d "$sim_dir" ]]; then - echo -e "${SYM_OK} ${COLOR_ACTION}Lösche Log-Dateien in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Lösche Log-Dateien in ${COLOR_DIR}$sim_dir...${COLOR_RESET}" rm -f "$sim_dir"/*.log sleep 1 fi done - echo -e "${COLOR_HEADING}Log-Bereinigung abgeschlossen${COLOR_RESET}" + log "${COLOR_HEADING}Log-Bereinigung abgeschlossen${COLOR_RESET}" blankline } function mapclean() { - echo -e "${COLOR_HEADING}🗺️ Map-Tile-Bereinigung wird durchgeführt...${COLOR_RESET}" + log "${COLOR_HEADING}🗺️ Map-Tile-Bereinigung wird durchgeführt...${COLOR_RESET}" # Sicherheitscheck für robust/bin/maptiles if [[ -d "robust/bin/maptiles" ]]; then rm -rf -- "robust/bin/maptiles/"* - echo -e "${SYM_OK} ${COLOR_ACTION}robust/bin/maptiles geleert${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}robust/bin/maptiles geleert${COLOR_RESET}" fi # Sicherheitscheck für alle simX/bin/maptiles @@ -2092,12 +2146,12 @@ function mapclean() { if [[ -d "$sim_dir" ]]; then # shellcheck disable=SC2115 rm -rf -- "${sim_dir}/"* - echo -e "${SYM_OK} ${COLOR_ACTION}${COLOR_DIR}$sim_dir${COLOR_RESET} ${COLOR_ACTION}geleert${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}${COLOR_DIR}$sim_dir${COLOR_RESET} ${COLOR_ACTION}geleert${COLOR_RESET}" sleep 1 fi done - echo -e "${COLOR_HEADING}✅ Map-Tile-Bereinigung abgeschlossen${COLOR_RESET}" + log "${COLOR_HEADING}✅ Map-Tile-Bereinigung abgeschlossen${COLOR_RESET}" blankline } @@ -2105,39 +2159,39 @@ function autoallclean() { local confirm # Warnung in Gelb (konsistenter mit \e anstelle von \033) - echo -e "\e[33m" + log "\e[33m" cat >&2 <<'WARNUNG' === WARNUNG: Alle Daten-, Verzeichnis-, Cache-, Log- und Map-Daten werden bereinigt! === === DIESE OPERATION KANN NICHT RÜCKGÄNGIG GEMACHT WERDEN! === === DER OPENSIMULATOR MUSS IM ANSCHLUSS NEU INSTALLIERT WERDEN! === WARNUNG - echo -e "\e[0m" + log "\e[0m" # Bestätigung mit Timeout (10 Sekunden) für Sicherheit read -t 30 -r -p "Fortfahren? (ja/NEIN): " confirm || { - echo -e "\n\e[31mTimeout: Keine Bestätigung erhalten. Abbruch.\e[0m" >&2 + log "\n\e[31mTimeout: Keine Bestätigung erhalten. Abbruch.\e[0m" >&2 return 1 } case "${confirm,,}" in ja|j|y|yes) - echo -e "\e[32mBereinigung wird gestartet...\e[0m" >&2 + log "\e[32mBereinigung wird gestartet...\e[0m" >&2 # Jede Clean-Funktion mit Fehlerprüfung local clean_functions=(dataclean pathclean cacheclean logclean mapclean) for func in "${clean_functions[@]}"; do if ! command -v "$func" &>/dev/null; then - echo -e "\e[31mFehler: '$func' ist keine gültige Funktion!\e[0m" >&2 + log "\e[31mFehler: '$func' ist keine gültige Funktion!\e[0m" >&2 return 1 fi "$func" || { - echo -e "\e[31mFehler bei $func!\e[0m" >&2 + log "\e[31mFehler bei $func!\e[0m" >&2 return 1 } done - echo -e "\e[32mBereinigung abgeschlossen.\e[0m" >&2 + log "\e[32mBereinigung abgeschlossen.\e[0m" >&2 ;; *) - echo -e "\e[33mAbbruch: Bereinigung wurde nicht durchgeführt.\e[0m" >&2 + log "\e[33mAbbruch: Bereinigung wurde nicht durchgeführt.\e[0m" >&2 return 1 ;; esac @@ -2146,35 +2200,35 @@ WARNUNG function clean_linux_logs() { local log_files=() - echo -e "${COLOR_SECTION}${SYM_LOG} Suche nach alten Log-Dateien...${COLOR_RESET}" + log "${COLOR_SECTION}${SYM_LOG} Suche nach alten Log-Dateien...${COLOR_RESET}" # Find and list files to be deleted while IFS= read -r -d $'\0' file; do log_files+=("$file") - echo -e "${COLOR_FILE}${SYM_INFO} ${COLOR_LABEL}Gelöscht wird:${COLOR_RESET} ${COLOR_VALUE}$file${COLOR_RESET}" + log "${COLOR_FILE}${SYM_INFO} ${COLOR_LABEL}Gelöscht wird:${COLOR_RESET} ${COLOR_VALUE}$file${COLOR_RESET}" done < <(find "/var/log" -name "*.log" -type f -mtime +7 -print0) if [ ${#log_files[@]} -eq 0 ]; then - echo -e "${SYM_OK} ${COLOR_LABEL}Keine alten Log-Dateien gefunden.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_LABEL}Keine alten Log-Dateien gefunden.${COLOR_RESET}" return 0 fi - echo -e "${COLOR_WARNING}${#log_files[@]} Log-Dateien werden gelöscht. Fortfahren? (j/N) ${COLOR_RESET}" + log "${COLOR_WARNING}${#log_files[@]} Log-Dateien werden gelöscht. Fortfahren? (j/N) ${COLOR_RESET}" read -r confirm case "${confirm,,}" in j|ja|y|yes) find "/var/log" -name "*.log" -type f -mtime +7 -delete - echo -e "${SYM_OK} ${COLOR_OK}${#log_files[@]} Log-Dateien wurden gelöscht.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_OK}${#log_files[@]} Log-Dateien wurden gelöscht.${COLOR_RESET}" ;; *) - echo -e "${SYM_BAD} ${COLOR_BAD}Bereinigung abgebrochen.${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_BAD}Bereinigung abgebrochen.${COLOR_RESET}" return 1 ;; esac } function delete_opensim() { - echo -e "${COLOR_HEADING}🗺️ Das komplette löschen vom OpenSimulator wird durchgeführt...${COLOR_RESET}" + log "${COLOR_HEADING}🗺️ Das komplette löschen vom OpenSimulator wird durchgeführt...${COLOR_RESET}" # Sicherheitsabfrage hinzufügen read -rp "Sind Sie sicher, dass Sie ALLE OpenSimulator-Daten löschen möchten? (ja/N) " answer @@ -2183,7 +2237,7 @@ function delete_opensim() { # Robust-Verzeichnis sicher löschen if [[ -d "robust" ]]; then rm -rf -- "robust" # Keine Wildcard mehr - echo -e "${SYM_OK} ${COLOR_ACTION}robust komplett entfernt${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}robust komplett entfernt${COLOR_RESET}" fi # Simulator-Verzeichnisse sicher löschen @@ -2191,12 +2245,12 @@ function delete_opensim() { local sim_dir="sim$i" if [[ -d "$sim_dir" ]]; then rm -rf -- "$sim_dir" # Keine Wildcard mehr - echo -e "${SYM_OK} ${COLOR_ACTION}${COLOR_DIR}$sim_dir${COLOR_RESET} ${COLOR_ACTION}komplett entfernt${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}${COLOR_DIR}$sim_dir${COLOR_RESET} ${COLOR_ACTION}komplett entfernt${COLOR_RESET}" sleep 1 fi done - echo -e "${COLOR_HEADING}✅ Das komplette löschen vom OpenSimulator abgeschlossen${COLOR_RESET}" + log "${COLOR_HEADING}✅ Das komplette löschen vom OpenSimulator abgeschlossen${COLOR_RESET}" blankline } @@ -2219,15 +2273,15 @@ function verify_ini_section() { local section="$2" if [ ! -f "$file" ]; then - echo -e "${SYM_BAD} Error: File ${file} does not exist" >&2 + log "${SYM_BAD} Error: File ${file} does not exist" >&2 return 2 fi if grep -q "^\[${section}\]" "$file"; then - echo -e "${SYM_OK} Section [${section}] exists in ${file}" + log "${SYM_OK} Section [${section}] exists in ${file}" return 0 else - echo -e "${SYM_BAD} Section [${section}] not found in ${file}" + log "${SYM_BAD} Section [${section}] not found in ${file}" return 1 fi } @@ -2241,17 +2295,17 @@ function verify_ini_key() { local key="$3" if [ ! -f "$file" ]; then - echo -e "${SYM_BAD} Error: File ${file} does not exist" >&2 + log "${SYM_BAD} Error: File ${file} does not exist" >&2 return 2 fi # Einfacher grep-Befehl, der Leerzeichen & Kommentare ignoriert if grep -Eq "^[[:space:]]*\[${section}\][[:space:]]*$" "$file" && \ grep -Eq "^[[:space:]]*${key}[[:space:]]*=" "$file"; then - echo -e "${SYM_OK} Key '${key}' exists in section [${section}]" + log "${SYM_OK} Key '${key}' exists in section [${section}]" return 0 else - echo -e "${SYM_BAD} Key '${key}' NOT FOUND in section [${section}]" >&2 + log "${SYM_BAD} Key '${key}' NOT FOUND in section [${section}]" >&2 return 1 fi } @@ -2267,14 +2321,14 @@ function add_ini_section() { return 0 fi - echo -e "${SYM_INFO} Adding section [${section}] to ${file}" + log "${SYM_INFO} Adding section [${section}] to ${file}" # Abschnitt am Ende der Datei hinzufügen if printf "\n[%s]\n" "$section" >> "$file"; then - echo -e "${SYM_OK} Successfully added section [${section}] to ${file}" + log "${SYM_OK} Successfully added section [${section}] to ${file}" return 0 else - echo -e "${SYM_BAD} Failed to add section [${section}] to ${file}" >&2 + log "${SYM_BAD} Failed to add section [${section}] to ${file}" >&2 return 1 fi } @@ -2291,7 +2345,7 @@ function add_ini_before_section() { return 0 fi - #echo -e "${SYM_INFO} Adding section [${section}] to ${file} before [${target_section}]" + #log "${SYM_INFO} Adding section [${section}] to ${file} before [${target_section}]" # Temporäre Datei erstellen temp_file=$(mktemp) @@ -2309,15 +2363,15 @@ function add_ini_before_section() { # Falls Zielabschnitt nicht gefunden, am Ende einfügen (Fallback) if [[ $found -eq 0 ]]; then printf "\n[%s]\n" "$section" >> "$temp_file" - echo -e "${SYM_WARNING} Target section [${target_section}] not found, appended [${section}] at end of file" + log "${SYM_WARNING} Target section [${target_section}] not found, appended [${section}] at end of file" fi # Originaldatei ersetzen if mv "$temp_file" "$file"; then - echo -e "${SYM_OK} Successfully added section [${section}] to ${file}" + log "${SYM_OK} Successfully added section [${section}] to ${file}" return 0 else - echo -e "${SYM_BAD} Failed to update ${file}" >&2 + log "${SYM_BAD} Failed to update ${file}" >&2 return 1 fi } @@ -2333,7 +2387,7 @@ function set_ini_key() { local file="$1" section="$2" key="$3" value="$4" local temp_file temp_file=$(mktemp) || { - echo -e "${COLOR_BAD}Fehler beim Erstellen der temporären Datei${COLOR_RESET}" >&2 + log "${COLOR_BAD}Fehler beim Erstellen der temporären Datei${COLOR_RESET}" >&2 return 1 } @@ -2378,18 +2432,18 @@ function set_ini_key() { printf "\n[%s]\n%s = %s\n", section, key, value } }' "$file" > "$temp_file" || { - echo -e "${COLOR_BAD}AWK-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 + log "${COLOR_BAD}AWK-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 rm -f "$temp_file" return 1 } if ! mv "$temp_file" "$file"; then - echo -e "${COLOR_BAD}Konnte Datei ${COLOR_FILE}${file}${COLOR_RESET} nicht aktualisieren" >&2 + log "${COLOR_BAD}Konnte Datei ${COLOR_FILE}${file}${COLOR_RESET} nicht aktualisieren" >&2 rm -f "$temp_file" return 1 fi - echo -e "${COLOR_OK}Gesetzt: ${COLOR_KEY}${key} = ${COLOR_VALUE}${value}${COLOR_OK} in [${section}]${COLOR_RESET}" + log "${COLOR_OK}Gesetzt: ${COLOR_KEY}${key} = ${COLOR_VALUE}${value}${COLOR_OK} in [${section}]${COLOR_RESET}" return 0 } @@ -2400,7 +2454,7 @@ function add_ini_key() { local file="$1" section="$2" key="$3" value="$4" local temp_file temp_file=$(mktemp) || { - echo -e "${COLOR_BAD}Failed to create temp file${COLOR_RESET}" >&2 + log "${COLOR_BAD}Failed to create temp file${COLOR_RESET}" >&2 return 1 } @@ -2432,17 +2486,17 @@ function add_ini_key() { } } ' "$file" > "$temp_file"; then - echo -e "${COLOR_BAD}AWK processing failed${COLOR_RESET}" >&2 + log "${COLOR_BAD}AWK processing failed${COLOR_RESET}" >&2 rm -f "$temp_file" return 1 fi if ! mv "$temp_file" "$file"; then - echo -e "${COLOR_BAD}Failed to update ${COLOR_FILE}${file}${COLOR_RESET}" >&2 + log "${COLOR_BAD}Failed to update ${COLOR_FILE}${file}${COLOR_RESET}" >&2 return 1 fi - echo -e "${COLOR_OK}Set ${COLOR_KEY}${key} = ${COLOR_VALUE}${value}${COLOR_OK} in [${section}]${COLOR_RESET}" + log "${COLOR_OK}Set ${COLOR_KEY}${key} = ${COLOR_VALUE}${value}${COLOR_OK} in [${section}]${COLOR_RESET}" return 0 } @@ -2452,16 +2506,16 @@ function del_ini_section() { # Verifizieren ob der Abschnitt existiert (still, ohne Ausgabe) if ! verify_ini_section "$file" "$section" >/dev/null; then - echo -e "${SYM_INFO} Section [${section}] not found in ${COLOR_FILE}${file}${COLOR_RESET}" + log "${SYM_INFO} Section [${section}] not found in ${COLOR_FILE}${file}${COLOR_RESET}" return 0 fi - echo -e "${SYM_INFO} Removing section [${COLOR_SECTION}${section}${COLOR_RESET}] from ${COLOR_FILE}${file}${COLOR_RESET}" + log "${SYM_INFO} Removing section [${COLOR_SECTION}${section}${COLOR_RESET}] from ${COLOR_FILE}${file}${COLOR_RESET}" # Temporäre Datei mit Fehlerbehandlung local temp_file temp_file=$(mktemp) || { - echo -e "${SYM_BAD} Failed to create temporary file" >&2 + log "${SYM_BAD} Failed to create temporary file" >&2 return 1 } @@ -2473,16 +2527,16 @@ function del_ini_section() { ' "$file" > "$temp_file"; then if mv "$temp_file" "$file"; then - echo -e "${SYM_OK} Successfully removed section [${COLOR_SECTION}${section}${COLOR_RESET}]" + log "${SYM_OK} Successfully removed section [${COLOR_SECTION}${section}${COLOR_RESET}]" return 0 else - echo -e "${SYM_BAD} Failed to update ${COLOR_FILE}${file}${COLOR_RESET}" >&2 + log "${SYM_BAD} Failed to update ${COLOR_FILE}${file}${COLOR_RESET}" >&2 rm -f "$temp_file" return 1 fi else - echo -e "${SYM_BAD} AWK processing failed" >&2 + log "${SYM_BAD} AWK processing failed" >&2 rm -f "$temp_file" return 1 fi @@ -2493,26 +2547,26 @@ function uncomment_ini_line() { local search_key="$2" # Sicherheitsprüfungen - [ ! -f "$file" ] && { echo -e "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } - [ -z "$search_key" ] && { echo -e "${COLOR_BAD}Suchschlüssel darf nicht leer sein${COLOR_RESET}" >&2; return 1; } + [ ! -f "$file" ] && { log "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } + [ -z "$search_key" ] && { log "${COLOR_BAD}Suchschlüssel darf nicht leer sein${COLOR_RESET}" >&2; return 1; } # Temporäre Datei erstellen local temp_file - temp_file=$(mktemp) || { echo -e "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } + temp_file=$(mktemp) || { log "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } # Entkommentieren der Zeile sed -E "/^[[:space:]]*;[[:space:]]*${search_key}[[:space:]]*=/s/^[[:space:]]*;//" "$file" > "$temp_file" || { rm -f "$temp_file" - echo -e "${COLOR_BAD}Sed-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 + log "${COLOR_BAD}Sed-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 return 1 } # Originaldatei ersetzen if mv "$temp_file" "$file"; then - echo -e "${COLOR_OK}Zeile '${search_key}' erfolgreich entkommentiert${COLOR_RESET}" + log "${COLOR_OK}Zeile '${search_key}' erfolgreich entkommentiert${COLOR_RESET}" return 0 else - echo -e "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 + log "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 return 1 fi } @@ -2523,13 +2577,13 @@ function uncomment_ini_section_line() { local search_key="$3" # Sicherheitsprüfungen - [ ! -f "$file" ] && { echo -e "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } - [ -z "$section" ] && { echo -e "${COLOR_BAD}Sektion darf nicht leer sein${COLOR_RESET}" >&2; return 1; } - [ -z "$search_key" ] && { echo -e "${COLOR_BAD}Suchschlüssel darf nicht leer sein${COLOR_RESET}" >&2; return 1; } + [ ! -f "$file" ] && { log "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } + [ -z "$section" ] && { log "${COLOR_BAD}Sektion darf nicht leer sein${COLOR_RESET}" >&2; return 1; } + [ -z "$search_key" ] && { log "${COLOR_BAD}Suchschlüssel darf nicht leer sein${COLOR_RESET}" >&2; return 1; } # Temporäre Datei erstellen local temp_file - temp_file=$(mktemp) || { echo -e "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } + temp_file=$(mktemp) || { log "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } # Entkommentieren der Zeile in der richtigen Sektion awk -v section="[$section]" -v key="$search_key" ' @@ -2542,16 +2596,16 @@ function uncomment_ini_section_line() { { print } ' "$file" > "$temp_file" || { rm -f "$temp_file" - echo -e "${COLOR_BAD}AWK-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 + log "${COLOR_BAD}AWK-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 return 1 } # Originaldatei ersetzen if mv "$temp_file" "$file"; then - echo -e "${COLOR_OK}Zeile '${search_key}' in Sektion '${section}' erfolgreich entkommentiert${COLOR_RESET}" + log "${COLOR_OK}Zeile '${search_key}' in Sektion '${section}' erfolgreich entkommentiert${COLOR_RESET}" return 0 else - echo -e "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 + log "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 return 1 fi } @@ -2561,13 +2615,13 @@ function comment_ini_line() { local search_key="$3" # Sicherheitsprüfungen - [ ! -f "$file" ] && { echo -e "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } - [ -z "$section" ] && { echo -e "${COLOR_BAD}Sektion darf nicht leer sein${COLOR_RESET}" >&2; return 1; } - [ -z "$search_key" ] && { echo -e "${COLOR_BAD}Suchschlüssel darf nicht leer sein${COLOR_RESET}" >&2; return 1; } + [ ! -f "$file" ] && { log "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } + [ -z "$section" ] && { log "${COLOR_BAD}Sektion darf nicht leer sein${COLOR_RESET}" >&2; return 1; } + [ -z "$search_key" ] && { log "${COLOR_BAD}Suchschlüssel darf nicht leer sein${COLOR_RESET}" >&2; return 1; } # Temporäre Datei erstellen local temp_file - temp_file=$(mktemp) || { echo -e "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } + temp_file=$(mktemp) || { log "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } # Zeile in der richtigen Sektion kommentieren awk -v section="[$section]" -v key="$search_key" ' @@ -2583,16 +2637,16 @@ function comment_ini_line() { { print } ' "$file" > "$temp_file" || { rm -f "$temp_file" - echo -e "${COLOR_BAD}AWK-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 + log "${COLOR_BAD}AWK-Verarbeitung fehlgeschlagen${COLOR_RESET}" >&2 return 1 } # Originaldatei ersetzen if mv "$temp_file" "$file"; then - echo -e "${COLOR_OK}Zeile '${search_key}' in Sektion '${section}' erfolgreich kommentiert${COLOR_RESET}" + log "${COLOR_OK}Zeile '${search_key}' in Sektion '${section}' erfolgreich kommentiert${COLOR_RESET}" return 0 else - echo -e "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 + log "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 return 1 fi } @@ -2602,12 +2656,12 @@ function clear_ini_section() { local section="$2" # Sicherheitsprüfungen - [ ! -f "$file" ] && { echo -e "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } - [ -z "$section" ] && { echo -e "${COLOR_BAD}Sektion darf nicht leer sein${COLOR_RESET}" >&2; return 1; } + [ ! -f "$file" ] && { log "${COLOR_BAD}Datei nicht gefunden: ${file}${COLOR_RESET}" >&2; return 1; } + [ -z "$section" ] && { log "${COLOR_BAD}Sektion darf nicht leer sein${COLOR_RESET}" >&2; return 1; } # Temporäre Datei erstellen local temp_file - temp_file=$(mktemp) || { echo -e "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } + temp_file=$(mktemp) || { log "${COLOR_BAD}Temp-Datei konnte nicht erstellt werden${COLOR_RESET}" >&2; return 1; } # AWK zum Leeren der Sektion (behält Header) awk -v section="$section" ' @@ -2634,10 +2688,10 @@ function clear_ini_section() { # Originaldatei ersetzen if mv "$temp_file" "$file"; then - echo -e "${COLOR_OK}Sektion '[${section}]' erfolgreich geleert${COLOR_RESET}" + log "${COLOR_OK}Sektion '[${section}]' erfolgreich geleert${COLOR_RESET}" return 0 else - echo -e "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 + log "${COLOR_BAD}Datei konnte nicht aktualisiert werden${COLOR_RESET}" >&2 return 1 fi } @@ -2667,7 +2721,7 @@ function database_set_iniconfig() { if [[ -z "$db_user" || -z "$db_pass" ]]; then - echo -e "${COLOR_BAD}DB_Benutzername oder DB_Passwort fehlt in UserInfo.ini${COLOR_RESET}" + log "${COLOR_BAD}DB_Benutzername oder DB_Passwort fehlt in UserInfo.ini${COLOR_RESET}" return 1 fi @@ -2680,7 +2734,7 @@ function database_set_iniconfig() { if [[ -f "$robust_hg_ini" ]]; then add_ini_key "$robust_hg_ini" "$section" "ConnectionString" "\"$robust_conn\"" else - echo -e "${COLOR_WARNING}Datei nicht gefunden: $robust_hg_ini${COLOR_RESET}" + log "${COLOR_WARNING}Datei nicht gefunden: $robust_hg_ini${COLOR_RESET}" fi # Robust.local.ini @@ -2688,7 +2742,7 @@ function database_set_iniconfig() { if [[ -f "$robust_ini" ]]; then add_ini_key "$robust_ini" "$section" "ConnectionString" "\"$robust_conn\"" else - echo -e "${COLOR_WARNING}Datei nicht gefunden: $robust_ini${COLOR_RESET}" + log "${COLOR_WARNING}Datei nicht gefunden: $robust_ini${COLOR_RESET}" fi # === simX-Datenbanken === @@ -2700,7 +2754,7 @@ function database_set_iniconfig() { fi done - echo -e "${COLOR_OK}Datenbanken erfolgreich konfiguriert${COLOR_RESET}" + log "${COLOR_OK}Datenbanken erfolgreich konfiguriert${COLOR_RESET}" blankline } @@ -2719,7 +2773,7 @@ function welcomeiniconfig() { # Überprüfen ob die Welcome-Region bereits existiert if [[ -f "$welcome_ini" ]]; then - echo -e "${COLOR_INFO}Überspringe Erstellung der Welcome-Region: '$gridname.ini' existiert bereits${COLOR_RESET}" + log "${COLOR_INFO}Überspringe Erstellung der Welcome-Region: '$gridname.ini' existiert bereits${COLOR_RESET}" # Vorsichtshalber Region in Robust-Konfigurationen eintragen. set_ini_key "${SCRIPT_DIR}/robust/bin/Robust.HG.ini" "GridService" "Region_$gridname" "\"DefaultRegion, DefaultHGRegion, FallbackRegion\"" set_ini_key "${SCRIPT_DIR}/robust/bin/Robust.local.ini" "GridService" "Region_$gridname" "\"DefaultRegion, FallbackRegion\"" @@ -2775,7 +2829,7 @@ function welcomeiniconfig() { set_ini_key "${SCRIPT_DIR}/robust/bin/Robust.HG.ini" "GridService" "Region_$gridname" "\"DefaultRegion, DefaultHGRegion, FallbackRegion\"" set_ini_key "${SCRIPT_DIR}/robust/bin/Robust.local.ini" "GridService" "Region_$gridname" "\"DefaultRegion, FallbackRegion\"" - echo -e "${COLOR_OK}Welcome_Area.ini Konfiguration abgeschlossen für $gridname${COLOR_RESET}" + log "${COLOR_OK}Welcome_Area.ini Konfiguration abgeschlossen für $gridname${COLOR_RESET}" blankline } @@ -2795,7 +2849,7 @@ function moneyserveriniconfig() { # Falls keine Benutzer- und Passwortwerte gelesen wurden, abbrechen if [[ -z "$db_user" || -z "$db_pass" ]]; then - echo -e "${COLOR_BAD}Fehler: DB_Benutzername oder DB_Passwort fehlen in UserInfo.ini${COLOR_RESET}" + log "${COLOR_BAD}Fehler: DB_Benutzername oder DB_Passwort fehlen in UserInfo.ini${COLOR_RESET}" return 1 fi @@ -2804,13 +2858,13 @@ function moneyserveriniconfig() { # Sicherstellen, dass die Vorlage existiert if [[ ! -f "$file.example" ]]; then - echo -e "${COLOR_BAD}FEHLER: Konfigurationsvorlage '$file.example' fehlt!${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Konfigurationsvorlage '$file.example' fehlt!${COLOR_RESET}" >&2 exit 1 fi # Kopieren der Vorlage cp "$file.example" "$file" || { - echo -e "${COLOR_BAD}FEHLER: Konnte '$file' nicht erstellen${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Konnte '$file' nicht erstellen${COLOR_RESET}" >&2 exit 1 } @@ -2837,7 +2891,7 @@ function moneyserveriniconfig() { set_ini_key "$file" "Certificate" "CheckClientCert" "\"false\"" set_ini_key "$file" "Certificate" "CheckServerCert" "\"false\"" - echo -e "${COLOR_OK}MoneyServer.ini Konfiguration abgeschlossen${COLOR_RESET}" + log "${COLOR_OK}MoneyServer.ini Konfiguration abgeschlossen${COLOR_RESET}" blankline } @@ -2874,7 +2928,7 @@ function opensiminiconfig() { sleep 1 - echo -e "${COLOR_INFO}Konfiguriere OpenSim.ini in $dir${COLOR_RESET}" + log "${COLOR_INFO}Konfiguriere OpenSim.ini in $dir${COLOR_RESET}" # Portberechnung pro Instanz local public_port=$((base_port + (sim_counter - 1) * 100)) @@ -3007,7 +3061,7 @@ function opensiminiconfig() { fi done - echo -e "${COLOR_OK}${sim_counter} Simulationen konfiguriert.${COLOR_RESET}" + log "${COLOR_OK}${sim_counter} Simulationen konfiguriert.${COLOR_RESET}" blankline } @@ -3101,7 +3155,7 @@ function robusthginiconfig() { # [Groups] set_ini_key "$file" "Groups" "MaxAgentGroups" "100" - echo -e "${COLOR_OK}Robust.HG.ini konfiguriert.${COLOR_RESET}" + log "${COLOR_OK}Robust.HG.ini konfiguriert.${COLOR_RESET}" blankline } @@ -3137,13 +3191,13 @@ function oswebinterfaceconfig() { # Prüfe, ob Konfigurationsverzeichnis existiert if [[ ! -d "$config_dir" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Verzeichnis nicht gefunden: ${COLOR_DIR}$config_dir${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Verzeichnis nicht gefunden: ${COLOR_DIR}$config_dir${COLOR_RESET}" return 1 fi # Prüfe, ob INI-Datei existiert if [[ ! -f "$ini_file" ]]; then - echo -e "${SYM_BAD} ${COLOR_ERROR}Konfigurationsdatei nicht gefunden: ${COLOR_DIR}$ini_file${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_ERROR}Konfigurationsdatei nicht gefunden: ${COLOR_DIR}$ini_file${COLOR_RESET}" return 1 fi @@ -3187,7 +3241,7 @@ EOF if [[ -f "$config_example_file" ]]; then #mv "$config_example_file" "$config_file" cp "$config_example_file" "$config_file" - echo -e "${SYM_OK} ${COLOR_ACTION}Konfigurationsdatei umbenannt: ${COLOR_DIR}$config_file${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Konfigurationsdatei umbenannt: ${COLOR_DIR}$config_file${COLOR_RESET}" # Konfiguration in config.php einfügen if [[ -f "$config_file" ]]; then @@ -3218,10 +3272,10 @@ EOF replace_passwords "registration_passwords_economy" "$config_file" replace_passwords "registration_passwords_events" "$config_file" - echo -e "${SYM_OK} ${COLOR_ACTION}Konfiguration in ${COLOR_DIR}$config_file${COLOR_ACTION} eingetragen${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Konfiguration in ${COLOR_DIR}$config_file${COLOR_ACTION} eingetragen${COLOR_RESET}" fi else - echo -e "${SYM_INFO} ${COLOR_INFO}Konfigurationsvorlage nicht gefunden: ${COLOR_DIR}$config_example_file${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_INFO}Konfigurationsvorlage nicht gefunden: ${COLOR_DIR}$config_example_file${COLOR_RESET}" fi # Berechtigungen anpassen (falls nötig) @@ -3233,7 +3287,7 @@ EOF chown www-data:www-data "$config_file" fi - echo -e "${SYM_OK} ${COLOR_ACTION}Konfiguration geschrieben nach: ${COLOR_DIR}$php_config_file${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Konfiguration geschrieben nach: ${COLOR_DIR}$php_config_file${COLOR_RESET}" return 0 } @@ -3248,14 +3302,14 @@ function robustiniconfig() { gridname=$(echo "$gridname" | sed -e 's/ä/ae/g' -e 's/ö/oe/g' -e 's/ü/ue/g' -e 's/[-&]/_/g' -e 's/ */_/g' -e 's/__\+/_/g') if [[ ! -f "$source_file" ]]; then - echo -e "${COLOR_BAD}FEHLER: Konfigurationsvorlage '$source_file' fehlt!${COLOR_RESET}" >&2 - echo -e "${COLOR_BAD}Das Programm benötigt diese Datei zum Starten.${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Konfigurationsvorlage '$source_file' fehlt!${COLOR_RESET}" >&2 + log "${COLOR_BAD}Das Programm benötigt diese Datei zum Starten.${COLOR_RESET}" >&2 exit 1 fi # Vorlage nach Robust.local.ini kopieren cp "$source_file" "$target_file" || { - echo -e "${COLOR_BAD}FEHLER: Konnte '$target_file' nicht erstellen${COLOR_RESET}" >&2 + log "${COLOR_BAD}FEHLER: Konnte '$target_file' nicht erstellen${COLOR_RESET}" >&2 exit 1 } @@ -3287,7 +3341,7 @@ function robustiniconfig() { set_ini_key "$target_file" "GridInfoService" "password" "\"\${Const|BaseURL}/password\"" set_ini_key "$target_file" "GridInfoService" "GridStatusRSS" "\"\${Const|BaseURL}:\${Const|PublicPort}/GridStatusRSS\"" - echo -e "${COLOR_OK}Robust.local.ini erfolgreich konfiguriert.${COLOR_RESET}" + log "${COLOR_OK}Robust.local.ini erfolgreich konfiguriert.${COLOR_RESET}" blankline } @@ -3301,7 +3355,7 @@ function flotsaminiconfig() { local file="$config_dir/FlotsamCache.ini" if [[ -d "$config_dir" ]]; then - echo -e "${COLOR_FILE}Erstelle $file${COLOR_RESET}" + log "${COLOR_FILE}Erstelle $file${COLOR_RESET}" mkdir -p "$config_dir" # Datei erstellen @@ -3328,11 +3382,11 @@ function flotsaminiconfig() { set_ini_key "$file" "AssetCache" "FileCacheTimeout" "48" set_ini_key "$file" "AssetCache" "FileCleanupTimer" "1.0" - echo -e "${COLOR_OK}→ FlotsamCache.ini neu geschrieben für sim$i${COLOR_RESET}" + log "${COLOR_OK}→ FlotsamCache.ini neu geschrieben für sim$i${COLOR_RESET}" fi done - echo -e "${COLOR_OK}FlotsamCache.ini konfiguriert.${COLOR_RESET}" + log "${COLOR_OK}FlotsamCache.ini konfiguriert.${COLOR_RESET}" blankline } @@ -3440,12 +3494,12 @@ function gridcommoniniconfig() { # [MuteListService] set_ini_key "$file" "MuteListService" "MuteListServerURI" "\"\${Const|PrivURL}:\${Const|PrivatePort}\"" - echo -e "${COLOR_OK}✓ sim$i: GridCommon.ini erfolgreich${COLOR_RESET}" + log "${COLOR_OK}✓ sim$i: GridCommon.ini erfolgreich${COLOR_RESET}" sleep 1 done - echo -e "${COLOR_OK}GridCommon.ini konfiguriert.${COLOR_RESET}" + log "${COLOR_OK}GridCommon.ini konfiguriert.${COLOR_RESET}" blankline } @@ -3456,7 +3510,7 @@ function osslenableiniconfig() { local file="$config_dir/osslEnable.ini" if [[ -d "$config_dir" ]]; then - echo -e "${COLOR_FILE}Erstelle $file${COLOR_RESET}" + log "${COLOR_FILE}Erstelle $file${COLOR_RESET}" mkdir -p "$config_dir" touch "$file" 2>/dev/null || echo "" > "$file" @@ -3594,13 +3648,13 @@ function osslenableiniconfig() { set_ini_key "$file" "OSSL" "Allow_osSetRot" "true" set_ini_key "$file" "OSSL" "Allow_osSetParcelDetails" "\${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER" - echo -e "${COLOR_OK}→ osslEnable.ini neu geschrieben für sim$i${COLOR_RESET}" + log "${COLOR_OK}→ osslEnable.ini neu geschrieben für sim$i${COLOR_RESET}" sleep 1 fi done - echo -e "${COLOR_OK}osslEnable.ini konfiguriert.${COLOR_RESET}" + log "${COLOR_OK}osslEnable.ini konfiguriert.${COLOR_RESET}" blankline } @@ -3616,7 +3670,7 @@ function standalonecommoniniconfig() { local file="$config_dir/StandaloneCommon.ini" local example_file="$config_dir/StandaloneCommon.ini.example" - echo -e "${COLOR_FILE}Erstelle StandaloneCommon.ini in opensim/bin${COLOR_RESET}" + log "${COLOR_FILE}Erstelle StandaloneCommon.ini in opensim/bin${COLOR_RESET}" mkdir -p "$config_dir" # Datei erstellen @@ -3640,7 +3694,7 @@ function standalonecommoniniconfig() { set_ini_key "$file" "GridInfoService" "GridName" "\"$gridname\"" set_ini_key "$file" "GridInfoService" "GridLoginURI" "\"http://$ip:8002\"" - echo -e "${COLOR_OK}→ StandaloneCommon.ini erfolgreich erstellt${COLOR_RESET}" + log "${COLOR_OK}→ StandaloneCommon.ini erfolgreich erstellt${COLOR_RESET}" blankline } @@ -3668,29 +3722,29 @@ function regionsiniconfig() { declare -A used_ports # Benutzereingabe mit Symbol und Farbe - echo -e "${SYM_INFO}${COLOR_LABEL} Wie viele Zufallsregionen sollen pro Simulator erstellt werden? ${COLOR_OK}[1]${COLOR_RESET}" + log "${SYM_INFO}${COLOR_LABEL} Wie viele Zufallsregionen sollen pro Simulator erstellt werden? ${COLOR_OK}[1]${COLOR_RESET}" read -r regions_per_sim # Eingabeprüfung if [[ -z "$regions_per_sim" ]]; then regions_per_sim=1 elif ! [[ "$regions_per_sim" =~ ^[1-9][0-9]*$ ]]; then - echo -e "${SYM_BAD} ${COLOR_BAD}Ungültige Eingabe: Bitte eine positive Zahl eingeben${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_BAD}Ungültige Eingabe: Bitte eine positive Zahl eingeben${COLOR_RESET}" >&2 return 1 fi - echo -e "${SYM_OK} ${COLOR_ACTION}Sie haben ${COLOR_OK}$regions_per_sim${COLOR_ACTION} Regionen pro Simulator gewählt.${COLOR_RESET}" + log "${SYM_OK} ${COLOR_ACTION}Sie haben ${COLOR_OK}$regions_per_sim${COLOR_ACTION} Regionen pro Simulator gewählt.${COLOR_RESET}" system_ip=$(hostname -I | awk '{print $1}') - echo -e "\n${SYM_SERVER}${COLOR_HEADING} Starte Regionserstellung...${COLOR_RESET}" + log "\n${SYM_SERVER}${COLOR_HEADING} Starte Regionserstellung...${COLOR_RESET}" # Simulatoren durchlaufen (beginnt bei 2 um sim1 für Welcome-Region freizuhalten) for ((sim_num=2; sim_num<=999; sim_num++)); do sim_dir="${SCRIPT_DIR}/sim${sim_num}/bin/Regions" if [[ -d "$sim_dir" ]]; then - echo -e "${SYM_FOLDER}${COLOR_SERVER} Simulator ${sim_num}:${COLOR_RESET} ${COLOR_ACTION}Erstelle ${regions_per_sim} Region(en)${COLOR_RESET}" >&2 + log "${SYM_FOLDER}${COLOR_SERVER} Simulator ${sim_num}:${COLOR_RESET} ${COLOR_ACTION}Erstelle ${regions_per_sim} Region(en)${COLOR_RESET}" >&2 # Bestehende Ports erfassen local existing_port_count=0 @@ -3726,7 +3780,7 @@ function regionsiniconfig() { attempts=$((attempts + 1)) if (( attempts >= max_attempts )); then - echo -e "${SYM_BAD} ${COLOR_WARNING}Fehler: Konnte nach ${max_attempts} Versuchen keine eindeutige Position finden${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_WARNING}Fehler: Konnte nach ${max_attempts} Versuchen keine eindeutige Position finden${COLOR_RESET}" >&2 return 1 fi done @@ -3743,7 +3797,7 @@ function regionsiniconfig() { ((port++)) ((port_attempts++)) if (( port_attempts >= max_port_attempts )); then - echo -e "${SYM_BAD} ${COLOR_WARNING}Fehler: Konnte nach ${max_port_attempts} Versuchen keinen freien Port finden${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_WARNING}Fehler: Konnte nach ${max_port_attempts} Versuchen keinen freien Port finden${COLOR_RESET}" >&2 return 1 fi done @@ -3756,7 +3810,7 @@ function regionsiniconfig() { ((port_attempts++)) if (( port_attempts >= max_port_attempts )); then - echo -e "${SYM_BAD} ${COLOR_WARNING}Fehler: Konnte nach ${max_port_attempts} Versuchen keinen freien Port finden${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_WARNING}Fehler: Konnte nach ${max_port_attempts} Versuchen keinen freien Port finden${COLOR_RESET}" >&2 return 1 fi done @@ -3773,7 +3827,7 @@ function regionsiniconfig() { # Prüfen ob Region existiert if [[ -f "$config_file" ]]; then - echo -e "${SYM_WAIT} ${COLOR_WARNING}Überspringe ${COLOR_VALUE}${region_name}${COLOR_RESET}${COLOR_WARNING} - existiert bereits${COLOR_RESET}" >&2 + log "${SYM_WAIT} ${COLOR_WARNING}Überspringe ${COLOR_VALUE}${region_name}${COLOR_RESET}${COLOR_WARNING} - existiert bereits${COLOR_RESET}" >&2 continue fi @@ -3813,12 +3867,12 @@ function regionsiniconfig() { set_ini_key "$config_file" "$region_name" ";MasterAvatarLastName" "Doe" set_ini_key "$config_file" "$region_name" ";MasterAvatarSandboxPassword" "passwd" - echo -e "${SYM_OK} ${COLOR_VALUE}${region_name} ${COLOR_DIR}(${location}, Port ${port})${COLOR_RESET}" >&2 + log "${SYM_OK} ${COLOR_VALUE}${region_name} ${COLOR_DIR}(${location}, Port ${port})${COLOR_RESET}" >&2 done fi done - echo -e "${SYM_OK}${COLOR_OK} Regionserstellung abgeschlossen!${COLOR_RESET}" + log "${SYM_OK}${COLOR_OK} Regionserstellung abgeschlossen!${COLOR_RESET}" blankline return 0 } @@ -3852,16 +3906,16 @@ function iniconfig() { local ini_file="${SCRIPT_DIR}/UserInfo.ini" if [[ ! -f "$ini_file" ]]; then - echo -e "${COLOR_INFO}Erstelle UserInfo.ini${COLOR_RESET}" + log "${COLOR_INFO}Erstelle UserInfo.ini${COLOR_RESET}" sudo touch "$ini_file" fi - echo -e "\n[ServerData]" | sudo tee -a "$ini_file" >/dev/null + log "\n[ServerData]" | sudo tee -a "$ini_file" >/dev/null echo "Arbeitsverzeichnis = ${SCRIPT_DIR}" | sudo tee -a "$ini_file" >/dev/null echo "ServerIP = ${ip}" | sudo tee -a "$ini_file" >/dev/null echo "GridName = ${gridname}" | sudo tee -a "$ini_file" >/dev/null - echo -e "${SYM_LOG} ${COLOR_LABEL}Serverdaten gespeichert in: ${COLOR_FILE}${ini_file}${COLOR_RESET}" + log "${SYM_LOG} ${COLOR_LABEL}Serverdaten gespeichert in: ${COLOR_FILE}${ini_file}${COLOR_RESET}" #! ⚠️ **Wichtige Sicherheitsinformation!** # Die Datei UserInfo.ini enthält Zugangsdaten. @@ -3908,15 +3962,15 @@ function verify_xml_section() { local section_name="$2" if [ ! -f "$file" ]; then - echo -e "${SYM_BAD} ${COLOR_BAD}Error: File ${COLOR_DIR}${file}${COLOR_BAD} does not exist${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_BAD}Error: File ${COLOR_DIR}${file}${COLOR_BAD} does not exist${COLOR_RESET}" >&2 return 2 fi if grep -q "
" "$file"; then - echo -e "${SYM_OK} ${COLOR_LABEL}Section ${COLOR_VALUE}'$section_name'${COLOR_LABEL} exists in ${COLOR_DIR}${file}${COLOR_RESET}" + log "${SYM_OK} ${COLOR_LABEL}Section ${COLOR_VALUE}'$section_name'${COLOR_LABEL} exists in ${COLOR_DIR}${file}${COLOR_RESET}" return 0 else - echo -e "${SYM_BAD} ${COLOR_LABEL}Section ${COLOR_VALUE}'$section_name'${COLOR_LABEL} not found in ${COLOR_DIR}${file}${COLOR_RESET}" + log "${SYM_BAD} ${COLOR_LABEL}Section ${COLOR_VALUE}'$section_name'${COLOR_LABEL} not found in ${COLOR_DIR}${file}${COLOR_RESET}" return 1 fi } @@ -3937,17 +3991,17 @@ function add_xml_section() { local temp_file temp_file=$(mktemp) - echo -e "${SYM_INFO} ${COLOR_ACTION}Adding section ${COLOR_VALUE}'$section_name'${COLOR_ACTION} to ${COLOR_DIR}${file}${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_ACTION}Adding section ${COLOR_VALUE}'$section_name'${COLOR_ACTION} to ${COLOR_DIR}${file}${COLOR_RESET}" # Abschnitt vor dem schließenden Tag einfügen if sed "s|$closing_tag|
\n$content\n
\n$closing_tag|" "$file" > "$temp_file"; then if mv "$temp_file" "$file"; then - echo -e "${SYM_OK} ${COLOR_OK}Successfully added section ${COLOR_VALUE}'$section_name'${COLOR_OK} to ${COLOR_DIR}${file}${COLOR_RESET}" + log "${SYM_OK} ${COLOR_OK}Successfully added section ${COLOR_VALUE}'$section_name'${COLOR_OK} to ${COLOR_DIR}${file}${COLOR_RESET}" return 0 fi fi - echo -e "${SYM_BAD} ${COLOR_BAD}Failed to add section ${COLOR_VALUE}'$section_name'${COLOR_BAD} to ${COLOR_DIR}${file}${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_BAD}Failed to add section ${COLOR_VALUE}'$section_name'${COLOR_BAD} to ${COLOR_DIR}${file}${COLOR_RESET}" >&2 return 1 } @@ -3965,17 +4019,17 @@ function del_xml_section() { local temp_file temp_file=$(mktemp) - echo -e "${SYM_INFO} ${COLOR_ACTION}Removing section ${COLOR_VALUE}'$section_name'${COLOR_ACTION} from ${COLOR_DIR}${file}${COLOR_RESET}" + log "${SYM_INFO} ${COLOR_ACTION}Removing section ${COLOR_VALUE}'$section_name'${COLOR_ACTION} from ${COLOR_DIR}${file}${COLOR_RESET}" # Abschnitt entfernen (inklusive aller Zeilen zwischen Section-Tags) if sed "/
/,/<\/Section>/d" "$file" > "$temp_file"; then if mv "$temp_file" "$file"; then - echo -e "${SYM_OK} ${COLOR_OK}Successfully removed section ${COLOR_VALUE}'$section_name'${COLOR_OK} from ${COLOR_DIR}${file}${COLOR_RESET}" + log "${SYM_OK} ${COLOR_OK}Successfully removed section ${COLOR_VALUE}'$section_name'${COLOR_OK} from ${COLOR_DIR}${file}${COLOR_RESET}" return 0 fi fi - echo -e "${SYM_BAD} ${COLOR_BAD}Failed to remove section ${COLOR_VALUE}'$section_name'${COLOR_BAD} from ${COLOR_DIR}${file}${COLOR_RESET}" >&2 + log "${SYM_BAD} ${COLOR_BAD}Failed to remove section ${COLOR_VALUE}'$section_name'${COLOR_BAD} from ${COLOR_DIR}${file}${COLOR_RESET}" >&2 return 1 } @@ -3984,7 +4038,7 @@ function configure_pbr_textures() { local asset_sets_file="opensim/bin/assets/AssetSets.xml" local libraries_file="opensim/bin/inventory/Libraries.xml" - echo -e "\n${COLOR_HEADING}=== Configuring PBR Textures ===${COLOR_RESET}" + log "\n${COLOR_HEADING}=== Configuring PBR Textures ===${COLOR_RESET}" # AssetSets.xml bearbeiten add_xml_section "$asset_sets_file" "PBR Textures AssetSet" \ @@ -3994,12 +4048,12 @@ function configure_pbr_textures() { add_xml_section "$libraries_file" "PBRTextures Library" \ " \n " || return 1 - echo -e "${SYM_OK} ${COLOR_OK}PBR Textures configuration completed successfully${COLOR_RESET}" + log "${SYM_OK} ${COLOR_OK}PBR Textures configuration completed successfully${COLOR_RESET}" } function regionsclean() { - echo -e "\033[33mWARNUNG: Dies wird ALLE Regionskonfigurationen in allen Simulatoren löschen!\033[0m" + log "\033[33mWARNUNG: Dies wird ALLE Regionskonfigurationen in allen Simulatoren löschen!\033[0m" echo "Sicher fortfahren? (j/N): " read -r confirm @@ -4012,7 +4066,7 @@ function regionsclean() { sim_dir="sim${sim_num}/bin/Regions" if [[ -d "$sim_dir" ]]; then - echo -e "\033[33m ✓ Überprüfe $sim_dir...\033[0m" + log "\033[33m ✓ Überprüfe $sim_dir...\033[0m" # Lösche nur .ini-Dateien (keine anderen Dateitypen) while IFS= read -r -d $'\0' config_file; do @@ -4024,7 +4078,7 @@ function regionsclean() { fi done - echo -e "\033[32mFertig! Gelöschte Regionen: $deleted_count\033[0m" + log "\033[32mFertig! Gelöschte Regionen: $deleted_count\033[0m" else echo "Abbruch: Keine Dateien wurden gelöscht." fi @@ -4035,11 +4089,11 @@ function renamefiles() { timestamp=$(date +"%Y%m%d_%H%M%S") if [ ! -d "$SCRIPT_DIR" ]; then - echo -e "${RED}Fehler: Verzeichnis $SCRIPT_DIR nicht gefunden!${RESET}" + log "${RED}Fehler: Verzeichnis $SCRIPT_DIR nicht gefunden!${RESET}" return 1 fi - echo -e "${CYAN}Starte Umbenennung aller *.example Dateien in ${SCRIPT_DIR} und Unterverzeichnissen...${RESET}" + log "${CYAN}Starte Umbenennung aller *.example Dateien in ${SCRIPT_DIR} und Unterverzeichnissen...${RESET}" # Verarbeite robust/bin zuerst find "$SCRIPT_DIR" -type f -name "*.example" 2>/dev/null | while read -r example_file; do @@ -4048,18 +4102,18 @@ function renamefiles() { if [ -f "$target_file" ]; then local backup_file="${target_file}_${timestamp}.bak" mv "$target_file" "$backup_file" - echo -e "${YELLOW}Gesichert: ${target_file} → ${backup_file}${RESET}" + log "${YELLOW}Gesichert: ${target_file} → ${backup_file}${RESET}" fi mv "$example_file" "$target_file" - echo -e "${GREEN}Umbenannt: ${example_file} → ${target_file}${RESET}" + log "${GREEN}Umbenannt: ${example_file} → ${target_file}${RESET}" done # Jetzt alle simX/bin Verzeichnisse durchlaufen for ((i=999; i>=1; i--)); do sim_dir="${SCRIPT_DIR}/sim$i/bin" if [ -d "$sim_dir" ]; then - echo -e "${CYAN}Verarbeite: $sim_dir ${RESET}" + log "${CYAN}Verarbeite: $sim_dir ${RESET}" find "$sim_dir" -type f -name "*.example" 2>/dev/null | while read -r example_file; do local target_file="${example_file%.example}" @@ -4068,27 +4122,27 @@ function renamefiles() { if [ -f "$target_file" ]; then local backup_file="${target_file}_${timestamp}.bak" mv "$target_file" "$backup_file" - echo -e "${YELLOW}Gesichert: ${target_file} → ${backup_file}${RESET}" + log "${YELLOW}Gesichert: ${target_file} → ${backup_file}${RESET}" fi mv "$example_file" "$target_file" - echo -e "${GREEN}Umbenannt: ${example_file} → ${target_file}${RESET}" + log "${GREEN}Umbenannt: ${example_file} → ${target_file}${RESET}" done fi done - echo -e "${GREEN}Alle *.example Dateien wurden erfolgreich verarbeitet.${RESET}" + log "${GREEN}Alle *.example Dateien wurden erfolgreich verarbeitet.${RESET}" blankline return 0 } # Standalone ist die erste Funktion, die funktioniert. function standalone() { - echo -e "\e[33m[Standalone] Setup wird durchgeführt...\e[0m" + log "\e[33m[Standalone] Setup wird durchgeführt...\e[0m" # Prüfen ob SCRIPT_DIR gesetzt ist if [ -z "${SCRIPT_DIR}" ]; then - echo -e "\e[31mFehler: SCRIPT_DIR ist nicht gesetzt!\e[0m" + log "\e[31mFehler: SCRIPT_DIR ist nicht gesetzt!\e[0m" return 1 fi @@ -4098,7 +4152,7 @@ function standalone() { # Sicherstellen, dass das Verzeichnis existiert if [ ! -d "${opensim_bin}" ]; then - echo -e "\e[31mFehler: Verzeichnis ${opensim_bin} nicht gefunden!\e[0m" + log "\e[31mFehler: Verzeichnis ${opensim_bin} nicht gefunden!\e[0m" return 1 fi @@ -4107,23 +4161,23 @@ function standalone() { target="${file%.example}" if [ -e "${target}" ]; then - echo -e "\e[33mÜbersprungen: ${target} existiert bereits\e[0m" + log "\e[33mÜbersprungen: ${target} existiert bereits\e[0m" ((skipped++)) else if mv "${file}" "${target}"; then - echo -e "\e[32mUmbenannt: ${file} → ${target}\e[0m" + log "\e[32mUmbenannt: ${file} → ${target}\e[0m" ((renamed++)) else - echo -e "\e[31mFehler beim Umbenennen von ${file}\e[0m" + log "\e[31mFehler beim Umbenennen von ${file}\e[0m" ((skipped++)) fi fi done < <(find "${opensim_bin}" -type f -name "*.example" -print0) - echo -e "\n\e[36mZusammenfassung:\e[0m" - echo -e "\e[32mUmbenannte Dateien: ${renamed}\e[0m" - echo -e "\e[33mÜbersprungene Dateien: ${skipped}\e[0m" - echo -e "\e[32mStandalone-Konfiguration abgeschlossen!\e[0m" + log "\n\e[36mZusammenfassung:\e[0m" + log "\e[32mUmbenannte Dateien: ${renamed}\e[0m" + log "\e[33mÜbersprungene Dateien: ${skipped}\e[0m" + log "\e[32mStandalone-Konfiguration abgeschlossen!\e[0m" blankline } @@ -4186,13 +4240,24 @@ function opensimrestart() { logclean # Logbereinigung sleep $Simulator_Start_wait # Wartezeit vor Neustart opensimstart - echo -e "\033[36mAktive Screen-Sessions:\033[0m" + log "\033[36mAktive Screen-Sessions:\033[0m" + screen -ls || echo "Keine Screen-Sessions gefunden" +} + +# Kompletter OpenSim-Neustart mit Logrotation +function opensimrestartParallel() { + opensimstopParallel + sleep $Simulator_Stop_wait # Wartezeit für Dienst-Stopp + logclean # Logbereinigung + sleep $Simulator_Start_wait # Wartezeit vor Neustart + opensimstartParallel + log "\033[36mAktive Screen-Sessions:\033[0m" screen -ls || echo "Keine Screen-Sessions gefunden" } # Server-Reboot mit Vorbereitung function reboot() { - echo -e "\033[1;33m⚠ Server-Neustart wird eingeleitet...\033[0m" + log "\033[1;33m⚠ Server-Neustart wird eingeleitet...\033[0m" opensimstop sleep $Simulator_Stop_wait @@ -4280,146 +4345,146 @@ function autoinstall() { function help() { # Allgemeine Befehle - echo -e "${COLOR_SECTION}${SYM_SERVER} OpenSim Grundbefehle:${COLOR_RESET}" - echo -e "\t${COLOR_START}opensimstart${COLOR_RESET}\t\t# Startet OpenSimulator komplett" - echo -e "\t${COLOR_STOP}opensimstop${COLOR_RESET}\t\t# Stoppt OpenSimulator komplett" - echo -e "\t${COLOR_START}opensimrestart${COLOR_RESET}\t\t# Startet den OpenSimulator komplett neu" + log "${COLOR_SECTION}${SYM_SERVER} OpenSim Grundbefehle:${COLOR_RESET}" + log "\t${COLOR_START}opensimstart${COLOR_RESET}\t\t# Startet OpenSimulator komplett" + log "\t${COLOR_STOP}opensimstop${COLOR_RESET}\t\t# Stoppt OpenSimulator komplett" + log "\t${COLOR_START}opensimrestart${COLOR_RESET}\t\t# Startet den OpenSimulator komplett neu" echo - echo -e "\t${COLOR_START}simstart${COLOR_RESET}\t\t# simX angeben - startet einen Regionsserver" - echo -e "\t${COLOR_STOP}simstop${COLOR_RESET}\t\t\t# simX angeben - stoppt einen Regionsserver" - echo -e "\t${COLOR_START}simrestart${COLOR_RESET}\t\t# simX angeben - startet einen Regionsserver neu" + log "\t${COLOR_START}simstart${COLOR_RESET}\t\t# simX angeben - startet einen Regionsserver" + log "\t${COLOR_STOP}simstop${COLOR_RESET}\t\t\t# simX angeben - stoppt einen Regionsserver" + log "\t${COLOR_START}simrestart${COLOR_RESET}\t\t# simX angeben - startet einen Regionsserver neu" echo "" # System-Checks & Setup - echo -e "${COLOR_SECTION}${SYM_TOOLS} System-Checks & Setup:${COLOR_RESET}" - echo -e "\t${COLOR_OK}check_screens${COLOR_RESET}\t\t# Prüft laufende Prozesse und handelt entsprechend" + log "${COLOR_SECTION}${SYM_TOOLS} System-Checks & Setup:${COLOR_RESET}" + log "\t${COLOR_OK}check_screens${COLOR_RESET}\t\t# Prüft laufende Prozesse und handelt entsprechend" echo - #echo -e "\t${COLOR_OK}servercheck${COLOR_RESET}\t\t# Installiert und Prüft den Server" - #echo -e "\t${COLOR_OK}createdirectory${COLOR_RESET}\t\t# Erstellt alle benötigten Verzeichnisse" - echo -e "\t${COLOR_OK}autoinstall${COLOR_RESET}\t\t# OpenSimulator Automatisiert installieren und einrichten" - echo -e "\t${COLOR_OK}setcrontab${COLOR_RESET}\t\t# Richtet Crontab ein damit der Server wartungsfrei laeuft" + #log "\t${COLOR_OK}servercheck${COLOR_RESET}\t\t# Installiert und Prüft den Server" + #log "\t${COLOR_OK}createdirectory${COLOR_RESET}\t\t# Erstellt alle benötigten Verzeichnisse" + log "\t${COLOR_OK}autoinstall${COLOR_RESET}\t\t# OpenSimulator Automatisiert installieren und einrichten" + log "\t${COLOR_OK}setcrontab${COLOR_RESET}\t\t# Richtet Crontab ein damit der Server wartungsfrei laeuft" echo "" # Git-Operationen - #echo -e "${COLOR_SECTION}${SYM_SYNC} Git-Operationen:${COLOR_RESET}" - #echo -e "\t${COLOR_OK}opensimgitcopy${COLOR_RESET}\t\t# Klont den OpenSim Code" - #echo -e "\t${COLOR_OK}moneygitcopy${COLOR_RESET}\t\t# Baut den MoneyServer in den OpenSimulator ein" - #echo -e "\t${COLOR_OK}osslscriptsgit${COLOR_RESET}\t\t# Klont OSSL-Skripte" - #echo -e "\t${COLOR_OK}versionrevision${COLOR_RESET}\t\t# Setzt Versionsrevision" + #log "${COLOR_SECTION}${SYM_SYNC} Git-Operationen:${COLOR_RESET}" + #log "\t${COLOR_OK}opensimgitcopy${COLOR_RESET}\t\t# Klont den OpenSim Code" + #log "\t${COLOR_OK}moneygitcopy${COLOR_RESET}\t\t# Baut den MoneyServer in den OpenSimulator ein" + #log "\t${COLOR_OK}osslscriptsgit${COLOR_RESET}\t\t# Klont OSSL-Skripte" + #log "\t${COLOR_OK}versionrevision${COLOR_RESET}\t\t# Setzt Versionsrevision" #echo "" # OpenSim Build & Deploy - #echo -e "${COLOR_SECTION}${SYM_FOLDER} OpenSim Build & Deploy:${COLOR_RESET}" - #echo -e "\t${COLOR_OK}opensimbuild${COLOR_RESET}\t\t# Kompiliert OpenSim zu ausführbaren Dateien" - #echo -e "\t${COLOR_OK}opensimcopy${COLOR_RESET}\t\t# Kopiert OpenSim in alle Verzeichnisse" - #echo -e "\t${COLOR_OK}opensimupgrade${COLOR_RESET}\t\t# Upgradet OpenSim" - #echo -e "\t${COLOR_OK}database_setup${COLOR_RESET}\t\t# Erstellt alle Datenbanken" + #log "${COLOR_SECTION}${SYM_FOLDER} OpenSim Build & Deploy:${COLOR_RESET}" + #log "\t${COLOR_OK}opensimbuild${COLOR_RESET}\t\t# Kompiliert OpenSim zu ausführbaren Dateien" + #log "\t${COLOR_OK}opensimcopy${COLOR_RESET}\t\t# Kopiert OpenSim in alle Verzeichnisse" + #log "\t${COLOR_OK}opensimupgrade${COLOR_RESET}\t\t# Upgradet OpenSim" + #log "\t${COLOR_OK}database_setup${COLOR_RESET}\t\t# Erstellt alle Datenbanken" #echo "" # Konfigurationsmanagement - #echo -e "${COLOR_SECTION}${SYM_CONFIG} Konfigurationsmanagement:${COLOR_RESET}" - #echo -e "\t${COLOR_WARNING}moneyserveriniconfig${COLOR_RESET}\t# Konfiguriert MoneyServer.ini (experimentell)" - #echo -e "\t${COLOR_WARNING}opensiminiconfig${COLOR_RESET}\t# Konfiguriert OpenSim.ini (experimentell)" - #echo -e "\t${COLOR_WARNING}regionsiniconfig${COLOR_RESET}\t# Konfiguriert Regionen (experimentell)" + #log "${COLOR_SECTION}${SYM_CONFIG} Konfigurationsmanagement:${COLOR_RESET}" + #log "\t${COLOR_WARNING}moneyserveriniconfig${COLOR_RESET}\t# Konfiguriert MoneyServer.ini (experimentell)" + #log "\t${COLOR_WARNING}opensiminiconfig${COLOR_RESET}\t# Konfiguriert OpenSim.ini (experimentell)" + #log "\t${COLOR_WARNING}regionsiniconfig${COLOR_RESET}\t# Konfiguriert Regionen (experimentell)" #echo "" # Systembereinigung - echo -e "${COLOR_SECTION}${SYM_CLEAN} Systembereinigung:${COLOR_RESET}" - echo -e "\t${COLOR_OK}cacheclean${COLOR_RESET}\t\t# Bereinigt OpenSimulator Cache" - echo -e "\t${COLOR_OK}logclean${COLOR_RESET}\t\t# Bereinigt OpenSimulator Logs" - echo -e "\t${COLOR_OK}mapclean${COLOR_RESET}\t\t# Bereinigt OpenSimulator Maptiles" - #echo -e "\t${COLOR_OK}clean_linux_logs${COLOR_RESET}\t# Bereinigt Systemlogs" + log "${COLOR_SECTION}${SYM_CLEAN} Systembereinigung:${COLOR_RESET}" + log "\t${COLOR_OK}cacheclean${COLOR_RESET}\t\t# Bereinigt OpenSimulator Cache" + log "\t${COLOR_OK}logclean${COLOR_RESET}\t\t# Bereinigt OpenSimulator Logs" + log "\t${COLOR_OK}mapclean${COLOR_RESET}\t\t# Bereinigt OpenSimulator Maptiles" + #log "\t${COLOR_OK}clean_linux_logs${COLOR_RESET}\t# Bereinigt Systemlogs" echo "" # Hilfe - echo -e "${COLOR_SECTION}${SYM_INFO} Hilfe:${COLOR_RESET}" - echo -e "\t${COLOR_OK}help${COLOR_RESET}\t\t\t# Zeigt diese Hilfe" - echo -e "\t${COLOR_OK}prohelp${COLOR_RESET}\t\t\t# Zeigt die Pro Hilfe" + log "${COLOR_SECTION}${SYM_INFO} Hilfe:${COLOR_RESET}" + log "\t${COLOR_OK}help${COLOR_RESET}\t\t\t# Zeigt diese Hilfe" + log "\t${COLOR_OK}prohelp${COLOR_RESET}\t\t\t# Zeigt die Pro Hilfe" echo "" } function prohelp() { #* OpenSim Grundbefehle - echo -e "${COLOR_SECTION}${SYM_SERVER} OpenSim Grundbefehle:${COLOR_RESET}" - echo -e "\t${COLOR_START}opensimstart${COLOR_RESET} \t\t\t # OpenSim starten" - echo -e "\t${COLOR_STOP}opensimstop${COLOR_RESET} \t\t\t # OpenSim stoppen" - echo -e "\t${COLOR_START}opensimrestart${COLOR_RESET} \t\t\t # OpenSim neu starten" - echo -e "\t${COLOR_OK}check_screens${COLOR_RESET} \t\t\t # Laufende OpenSim-Prozesse prüfen und neu starten" + log "${COLOR_SECTION}${SYM_SERVER} OpenSim Grundbefehle:${COLOR_RESET}" + log "\t${COLOR_START}opensimstart${COLOR_RESET} \t\t\t # OpenSim starten" + log "\t${COLOR_STOP}opensimstop${COLOR_RESET} \t\t\t # OpenSim stoppen" + log "\t${COLOR_START}opensimrestart${COLOR_RESET} \t\t\t # OpenSim neu starten" + log "\t${COLOR_OK}check_screens${COLOR_RESET} \t\t\t # Laufende OpenSim-Prozesse prüfen und neu starten" echo " " #* System-Checks & Setup - echo -e "${COLOR_SECTION}${SYM_TOOLS} System-Checks & Setup:${COLOR_RESET}" - echo -e "\t${COLOR_OK}servercheck${COLOR_RESET} \t\t\t # Serverbereitschaft prüfen und Abhängigkeiten installieren" - echo -e "\t${COLOR_OK}createdirectory${COLOR_RESET} \t\t # OpenSim-Verzeichnisse erstellen" - echo -e "\t${COLOR_OK}setcrontab${COLOR_RESET} \t\t\t # Crontab Automatisierungen einrichten" - echo -e "\t${COLOR_OK}autoinstall${COLOR_RESET} \t\t\t # OpenSimulator Automatisiert installieren und einrichten" + log "${COLOR_SECTION}${SYM_TOOLS} System-Checks & Setup:${COLOR_RESET}" + log "\t${COLOR_OK}servercheck${COLOR_RESET} \t\t\t # Serverbereitschaft prüfen und Abhängigkeiten installieren" + log "\t${COLOR_OK}createdirectory${COLOR_RESET} \t\t # OpenSim-Verzeichnisse erstellen" + log "\t${COLOR_OK}setcrontab${COLOR_RESET} \t\t\t # Crontab Automatisierungen einrichten" + log "\t${COLOR_OK}autoinstall${COLOR_RESET} \t\t\t # OpenSimulator Automatisiert installieren und einrichten" echo " " #* Git-Operationen - echo -e "${COLOR_SECTION}${SYM_SYNC} Git-Operationen:${COLOR_RESET}" - echo -e "\t${COLOR_OK}opensimgitcopy${COLOR_RESET} \t\t\t # OpenSim aus Git herunterladen" - echo -e "\t${COLOR_OK}moneygitcopy${COLOR_RESET} \t\t\t # MoneyServer aus Git holen" - echo -e "\t${COLOR_WARNING}ruthrothgit${COLOR_RESET} \t\t\t # Ruth Roth IAR Dateien ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}avatarassetsgit${COLOR_RESET} \t\t # Avatar-Assets ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" - echo -e "\t${COLOR_OK}osslscriptsgit${COLOR_RESET} \t\t\t # OSSL Beispielskripte herunterladen" - echo -e "\t${COLOR_WARNING}pbrtexturesgit${COLOR_RESET} \t\t\t # PBR-Texturen ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" - echo -e "\t${COLOR_OK}downloadallgit${COLOR_RESET} \t\t\t # Alle Git-Repos herunterladen" - echo -e "\t${COLOR_OK}versionrevision${COLOR_RESET} \t\t # Versionsverwaltung aktivieren" + log "${COLOR_SECTION}${SYM_SYNC} Git-Operationen:${COLOR_RESET}" + log "\t${COLOR_OK}opensimgitcopy${COLOR_RESET} \t\t\t # OpenSim aus Git herunterladen" + log "\t${COLOR_OK}moneygitcopy${COLOR_RESET} \t\t\t # MoneyServer aus Git holen" + log "\t${COLOR_WARNING}ruthrothgit${COLOR_RESET} \t\t\t # Ruth Roth IAR Dateien ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" + log "\t${COLOR_WARNING}avatarassetsgit${COLOR_RESET} \t\t # Avatar-Assets ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" + log "\t${COLOR_OK}osslscriptsgit${COLOR_RESET} \t\t\t # OSSL Beispielskripte herunterladen" + log "\t${COLOR_WARNING}pbrtexturesgit${COLOR_RESET} \t\t\t # PBR-Texturen ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" + log "\t${COLOR_OK}downloadallgit${COLOR_RESET} \t\t\t # Alle Git-Repos herunterladen" + log "\t${COLOR_OK}versionrevision${COLOR_RESET} \t\t # Versionsverwaltung aktivieren" echo " " #* OpenSim Build & Deployment - echo -e "${COLOR_SECTION}${SYM_FOLDER} OpenSim Build & Deploy:${COLOR_RESET}" - echo -e "\t${COLOR_OK}opensimbuild${COLOR_RESET} \t\t\t # OpenSim kompilieren" - echo -e "\t${COLOR_OK}opensimcopy${COLOR_RESET} \t\t\t # OpenSim Dateien kopieren" - echo -e "\t${COLOR_OK}opensimupgrade${COLOR_RESET} \t\t\t # OpenSim aktualisieren" - echo -e "\t${COLOR_OK}database_setup${COLOR_RESET} \t\t\t # Datenbank für OpenSim einrichten" + log "${COLOR_SECTION}${SYM_FOLDER} OpenSim Build & Deploy:${COLOR_RESET}" + log "\t${COLOR_OK}opensimbuild${COLOR_RESET} \t\t\t # OpenSim kompilieren" + log "\t${COLOR_OK}opensimcopy${COLOR_RESET} \t\t\t # OpenSim Dateien kopieren" + log "\t${COLOR_OK}opensimupgrade${COLOR_RESET} \t\t\t # OpenSim aktualisieren" + log "\t${COLOR_OK}database_setup${COLOR_RESET} \t\t\t # Datenbank für OpenSim einrichten" echo " " #* Konfigurationsmanagement - echo -e "${COLOR_SECTION}${SYM_CONFIG} Konfigurationsmanagement:${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}moneyserveriniconfig${COLOR_RESET} \t\t # Konfiguriert MoneyServer.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}opensiminiconfig${COLOR_RESET} \t\t # Konfiguriert OpenSim.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}robusthginiconfig${COLOR_RESET} \t\t # Konfiguriert Robust.HG.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}robustiniconfig${COLOR_RESET} \t\t # Konfiguriert Robust.local.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}gridcommoniniconfig${COLOR_RESET} \t\t # Erstellt GridCommon.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}standalonecommoniniconfig${COLOR_RESET} \t # Erstellt StandaloneCommon.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}flotsaminiconfig${COLOR_RESET} \t\t # Erstellt FlotsamCache.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}osslenableiniconfig${COLOR_RESET} \t\t # Konfiguriert osslEnable.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}welcomeiniconfig${COLOR_RESET} \t\t # Konfiguriert Begrüßungsregion ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}regionsiniconfig${COLOR_RESET} \t\t # Startet neue Regionen-Konfigurationen ${COLOR_BAD}(experimentell)${COLOR_RESET}" - echo -e "\t${COLOR_WARNING}iniconfig${COLOR_RESET} \t\t\t # Startet ALLE Konfigurationen ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "${COLOR_SECTION}${SYM_CONFIG} Konfigurationsmanagement:${COLOR_RESET}" + log "\t${COLOR_WARNING}moneyserveriniconfig${COLOR_RESET} \t\t # Konfiguriert MoneyServer.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}opensiminiconfig${COLOR_RESET} \t\t # Konfiguriert OpenSim.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}robusthginiconfig${COLOR_RESET} \t\t # Konfiguriert Robust.HG.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}robustiniconfig${COLOR_RESET} \t\t # Konfiguriert Robust.local.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}gridcommoniniconfig${COLOR_RESET} \t\t # Erstellt GridCommon.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}standalonecommoniniconfig${COLOR_RESET} \t # Erstellt StandaloneCommon.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}flotsaminiconfig${COLOR_RESET} \t\t # Erstellt FlotsamCache.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}osslenableiniconfig${COLOR_RESET} \t\t # Konfiguriert osslEnable.ini ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}welcomeiniconfig${COLOR_RESET} \t\t # Konfiguriert Begrüßungsregion ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}regionsiniconfig${COLOR_RESET} \t\t # Startet neue Regionen-Konfigurationen ${COLOR_BAD}(experimentell)${COLOR_RESET}" + log "\t${COLOR_WARNING}iniconfig${COLOR_RESET} \t\t\t # Startet ALLE Konfigurationen ${COLOR_BAD}(experimentell)${COLOR_RESET}" echo " " #* XML & INI-Operationen - echo -e "${COLOR_SECTION}${SYM_SCRIPT} INI-Operationen:${COLOR_RESET}" - echo -e "\t${COLOR_OK}verify_ini_section${COLOR_RESET} \t\t # INI-Abschnitt verifizieren" - echo -e "\t${COLOR_OK}verify_ini_key${COLOR_RESET} \t\t\t # INI-Schlüssel verifizieren" - echo -e "\t${COLOR_OK}add_ini_section${COLOR_RESET} \t\t # INI-Abschnitt hinzufügen" - echo -e "\t${COLOR_OK}set_ini_key${COLOR_RESET} \t\t\t # INI-Schlüssel setzen" - echo -e "\t${COLOR_WARNING}del_ini_section${COLOR_RESET} \t\t # INI-Abschnitt löschen ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" + log "${COLOR_SECTION}${SYM_SCRIPT} INI-Operationen:${COLOR_RESET}" + log "\t${COLOR_OK}verify_ini_section${COLOR_RESET} \t\t # INI-Abschnitt verifizieren" + log "\t${COLOR_OK}verify_ini_key${COLOR_RESET} \t\t\t # INI-Schlüssel verifizieren" + log "\t${COLOR_OK}add_ini_section${COLOR_RESET} \t\t # INI-Abschnitt hinzufügen" + log "\t${COLOR_OK}set_ini_key${COLOR_RESET} \t\t\t # INI-Schlüssel setzen" + log "\t${COLOR_WARNING}del_ini_section${COLOR_RESET} \t\t # INI-Abschnitt löschen ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" echo " " #* XML-Operationen - echo -e "${COLOR_SECTION}${SYM_SCRIPT} XML-Operationen:${COLOR_RESET}" - echo -e "\t${COLOR_OK}verify_xml_section${COLOR_RESET} \t\t # XML-Abschnitt verifizieren" - echo -e "\t${COLOR_OK}add_xml_section${COLOR_RESET} \t\t # XML-Abschnitt hinzufügen" - echo -e "\t${COLOR_WARNING}del_xml_section${COLOR_RESET} \t\t # XML-Abschnitt löschen ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" + log "${COLOR_SECTION}${SYM_SCRIPT} XML-Operationen:${COLOR_RESET}" + log "\t${COLOR_OK}verify_xml_section${COLOR_RESET} \t\t # XML-Abschnitt verifizieren" + log "\t${COLOR_OK}add_xml_section${COLOR_RESET} \t\t # XML-Abschnitt hinzufügen" + log "\t${COLOR_WARNING}del_xml_section${COLOR_RESET} \t\t # XML-Abschnitt löschen ${COLOR_BAD}(Vorsicht)${COLOR_RESET}" echo " " #* System-Bereinigung - echo -e "${COLOR_SECTION}${SYM_CLEAN} Systembereinigung:${COLOR_RESET}" - echo -e "\t${COLOR_OK}reboot${COLOR_RESET} \t\t\t\t # Linux Server neu starten" - echo -e "\t${COLOR_OK}cacheclean${COLOR_RESET} \t\t\t # OpenSimulator Cache bereinigen" - echo -e "\t${COLOR_OK}logclean${COLOR_RESET} \t\t\t # OpenSimulator Logs bereinigen" - echo -e "\t${COLOR_OK}mapclean${COLOR_RESET} \t\t\t # OpenSimulator Maptiles bereinigen" - echo -e "\t${COLOR_OK}renamefiles${COLOR_RESET} \t\t\t # OpenSimulator Beispieldateien umbenennen" - echo -e "\t${COLOR_OK}clean_linux_logs${COLOR_RESET} \t\t # Linux-Logs bereinigen" - echo -e "\t${COLOR_OK}delete_opensim${COLOR_RESET} \t\t # OpenSimulator mit Verzeichnisse entfernen" + log "${COLOR_SECTION}${SYM_CLEAN} Systembereinigung:${COLOR_RESET}" + log "\t${COLOR_OK}reboot${COLOR_RESET} \t\t\t\t # Linux Server neu starten" + log "\t${COLOR_OK}cacheclean${COLOR_RESET} \t\t\t # OpenSimulator Cache bereinigen" + log "\t${COLOR_OK}logclean${COLOR_RESET} \t\t\t # OpenSimulator Logs bereinigen" + log "\t${COLOR_OK}mapclean${COLOR_RESET} \t\t\t # OpenSimulator Maptiles bereinigen" + log "\t${COLOR_OK}renamefiles${COLOR_RESET} \t\t\t # OpenSimulator Beispieldateien umbenennen" + log "\t${COLOR_OK}clean_linux_logs${COLOR_RESET} \t\t # Linux-Logs bereinigen" + log "\t${COLOR_OK}delete_opensim${COLOR_RESET} \t\t # OpenSimulator mit Verzeichnisse entfernen" echo " " #* Hilfe - echo -e "${COLOR_SECTION}${SYM_INFO} Hilfe:${COLOR_RESET}" - echo -e "\t${COLOR_OK}help${COLOR_RESET} \t\t\t\t # Diese Hilfeseite anzeigen" + log "${COLOR_SECTION}${SYM_INFO} Hilfe:${COLOR_RESET}" + log "\t${COLOR_OK}help${COLOR_RESET} \t\t\t\t # Diese Hilfeseite anzeigen" echo " " } @@ -4528,6 +4593,7 @@ case $KOMMANDO in # Tests # opensimstartParallel) opensimstartParallel ;; opensimstopParallel) opensimstopParallel ;; + opensimrestartParallel) opensimrestartParallel ;; # HILFE & SONSTIGES # generate_all_name) generate_all_name ;; @@ -4537,5 +4603,5 @@ esac # Programm Ende mit Zeitstempel blankline -echo -e "\e[36m${SCRIPTNAME}\e[0m ${VERSION} wurde beendet $(date +'%Y-%m-%d %H:%M:%S')" >&2 +log "\e[36m${SCRIPTNAME}\e[0m ${VERSION} wurde beendet $(date +'%Y-%m-%d %H:%M:%S')" >&2 exit 0