diff --git a/GRIDSERVER.md b/GRIDSERVER.md new file mode 100644 index 0000000..275fdb6 --- /dev/null +++ b/GRIDSERVER.md @@ -0,0 +1,95 @@ +# Handbuch: Grid-Server mit Hypergrid + +Dieses Handbuch beschreibt den Betrieb eines OpenSim Grid-Servers mit Robust-Diensten und Hypergrid-Funktion auf Basis von opensimMULTITOOLS-II. + +## 1. Zweck und Rolle + +Ein Grid-Server stellt zentral bereit: + +- Robust-Dienste (Login, Grid, Inventory, Assets, Gatekeeper) +- optional lokale Regionen (sim1, sim2, ...) +- optional Janus fuer WebRTC + +## 2. Voraussetzungen + +- Linux Server + +Wichtig: + +- Die technische Server-Vorbereitung erfolgt ueber die Install-Aktionen (prepare-ubuntu, install-opensim-deps, install-dotnet8). +- Es wird keine vorinstallierte Firewall vorausgesetzt. +- Paketinstallation und Basis-Setup werden vom Tool ausgefuehrt. + +Manuelle Eingaben durch den Betreiber: + +- DNS/FQDN bzw. oeffentliche Host/IP-Werte fuer Hypergrid +- Datenbank-Zugangsdaten (z. B. --db-user, --db-pass) +- Oeffentliche Hostangabe fuer Janus/OpenSim (z. B. --public-host) + +## 3. Grundinstallation + +```bash +cd /opt/opensimMULTITOOLS-II +chmod +x osmtool_main.sh modular/*.sh + +# Pflicht: Tool richtet den Server technisch ein +bash osmtool_main.sh server_install +# Betreiber gibt DB-Zugangsdaten vor +export OSM_DB_USER=opensim +export OSM_DB_PASS='DEIN_PASSWORT' +bash osmtool_main.sh dbsetup +``` + +## 4. Hypergrid-Konfiguration + +Datei pruefen/anpassen: + +- /opt/robust/bin/Robust.ini + +Wichtige Punkte: + +- Externe Endpunkte auf echten FQDN/IP setzen +- Keine localhost oder 127.0.0.1 fuer externe HG-URIs +- Gatekeeper/UserAgent-Endpunkte konsistent halten + +Wenn lokale Regionen laufen, auch deren OpenSim.ini gegen Robust-FQDN pruefen. + +## 5. Betrieb + +### 5.1 Start/Stop/Restart + +```bash +bash osmtool_main.sh opensimstart +bash osmtool_main.sh opensimrestart +bash osmtool_main.sh opensimstop +``` + +### 5.2 Monitoring + +```bash +bash osmtool_main.sh healthcheck +bash osmtool_main.sh smoketest +bash osmtool_main.sh dailyreport +``` + +## 6. Cron fuer Stabilitaet + +```bash +bash osmtool_main.sh croninstall +bash osmtool_main.sh cronlist +``` + +## 7. Janus (optional) + +```bash +bash osmtool_main.sh janusinstall +bash osmtool_main.sh janusrestart +``` + +## 8. Abnahmecheckliste + +- [ ] Robust startet fehlerfrei +- [ ] Regionen verbinden sich mit Robust +- [ ] Hypergrid-Endpunkte extern erreichbar +- [ ] smoke/report laufen erfolgreich +- [ ] HG-Reise von externem Grid erfolgreich diff --git a/README.md b/README.md index 0e3017d..c363d79 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,16 @@ Fuer die Aufteilung in einzelne Aufgaben gibt es jetzt eine modulare Basis: ### Beispiele ```bash -# CLI: zentrale Server-Vorbereitung als Pflichtschritt -bash osmtool_main.sh --module install --action bootstrap-server --workdir /opt --profile grid-sim - # CLI: Ubuntu vorbereiten bash osmtool_main.sh --module install --action prepare-ubuntu +# CLI: OpenSim-Abhaengigkeiten und dotnet installieren +bash osmtool_main.sh --module install --action install-opensim-deps --workdir /opt --profile grid-sim +bash osmtool_main.sh --module install --action install-dotnet8 --workdir /opt --profile grid-sim + +# CLI: Server-Readiness pruefen +bash osmtool_main.sh --module install --action server-check --workdir /opt --profile grid-sim + # CLI: OpenSim klonen, Zusatzmodule einbinden und bauen bash osmtool_main.sh --module install --action install-opensim --workdir /opt --profile grid-sim @@ -105,7 +109,7 @@ bash osmtool_main.sh --mode ui Hinweis Janus: -- `bootstrap-server` ist Pflicht vor `install-opensim`, `compile-janus`, `configure-janus` und `install-janus`. +- Startreihenfolge: `prepare-ubuntu` -> `install-opensim-deps` -> `install-dotnet8` -> `server-check`. - `configure-opensim` erzeugt fehlende Runtime-INI aus den Beispielvorlagen. - `configure-database` erzeugt MariaDB Datenbanken fuer `robust` und gefundene `sim*` Verzeichnisse sowie Benutzer/Grants. - Datenbankbasis ist MariaDB; `server-check` prueft `mysqldump` als Pflichttool fuer Backups. @@ -127,16 +131,16 @@ Hinweis Janus: ## **📋 Inhaltsverzeichnis** 1. [OpenSim starten/stoppen](#-opensim-starten-stoppen-und-neustarten) -2. [OpenSim-Grid erstellen/aktualisieren](#-opensim-grid-erstellen-oder-aktualisieren) +2. OpenSim-Grid erstellen/aktualisieren 3. [Diverse Git-Downloads](#-diverse-git-downloads) -4. [Konfiguration](#-konfiguration) -5. [INI-Operationen](#-ini-operationen) -6. [XML-Operationen](#-xml-operationen) -7. [Standalone-Modus](#-standalone-modus) +4. Konfiguration +5. INI-Operationen +6. XML-Operationen +7. Standalone-Modus 8. [OpenSim bereinigen](#-opensim-grid-bereinigen) -9. [Systembefehle](#-systembefehle) +9. Systembefehle 10. [Hilfen](#-hilfen) -11. [OpenSimulator-crontabs](#-OpenSimulator-crontabs) +11. [OpenSimulator-crontabs](#-opensimulator-crontabs) --- @@ -254,14 +258,14 @@ Hinweis Janus: | Befehl | Beschreibung | Status | | ------------------ | ------------------------------------------------------------ | ------------------------ | -| `dataclean` | Alte Dateien löschen (⚡ Neuinstallation erforderlich!) | Test | -| `pathclean` | Alte Verzeichnisse löschen (⚡ Neuinstallation erforderlich!) | Test | +| `dataclean` | Alte Dateien löschen (⚡ Neuinstallation erforderlich!) | Test | +| `pathclean` | Alte Verzeichnisse löschen (⚡ Neuinstallation erforderlich!)| Test | | `cacheclean` | Cache bereinigen. | Stabil | | `logclean` | Logs löschen. | Stabil | | `mapclean` | Maptiles löschen. | Stabil | -| `autoallclean` | Komplettbereinigung (⚡ Neuinstallation erforderlich!) | Test | +| `autoallclean` | Komplettbereinigung (⚡ Neuinstallation erforderlich!) | Test | | `regionsclean` | Alle Regionen löschen. | Test | -| `cleanall` | Alles bereinigen (⚡ Neuinstallation erforderlich!) | Test | +| `cleanall` | Alles bereinigen (⚡ Neuinstallation erforderlich!) | Test | | `renamefiles` | Umbenennung aller \*.example Dateien. | Test | | `clean_linux_logs` | Linux-Systemlogs bereinigen. | Test | | `delete_opensim` | Entfernt OpenSimulator komplett inkl. Verzeichnissen. | Test | @@ -278,14 +282,13 @@ Hinweis Janus: ## **📂 Backup** -| Befehl | Beschreibung | Status | -|---------------------|------------------------------------------------------------------------------|--------------------------| -| `loadiar` | Lädt ein Inventar-Archiv (IAR) zu einem Avatar hoch | Test | -| `saveiar` | Speichert das Inventar eines Avatars als IAR-Datei | Test | -| `loadoar` | Lädt ein vollständiges Regionen-Backup (OAR) in eine Region | Test | -| `saveoar` | Erstellt ein vollständiges Backup (OAR) einer Region | Test | -| `autoregionbackup` | Führt automatisierte Backups aller Regionen aus | Test | - +|Befehl|Beschreibung|Status| +|---|---|---| +|`loadiar`|Lädt ein Inventar-Archiv (IAR) zu einem Avatar hoch|Test| +|`saveiar`|Speichert das Inventar eines Avatars als IAR-Datei|Test| +|`loadoar`|Lädt ein vollständiges Regionen-Backup (OAR) in eine Region|Test| +|`saveoar`|Erstellt ein vollständiges Backup (OAR) einer Region|Test| +|`autoregionbackup`|Führt automatisierte Backups aller Regionen aus|Test| --- @@ -302,12 +305,19 @@ Hinweis Janus: ## **❓ OpenSimulator-crontabs** -### List crontabs: - crontab -l +### List crontabs -### Edit crontabs: - crontab -e +```bash +crontab -l ``` + +### Edit crontabs + +```bash +crontab -e +``` + +```text # * * * * * Befehl_der_ausgefuehrt_werden_soll # │ │ │ │ │ # │ │ │ │ ─── Wochentag (0-7) (0 und 7 = Sonntag) @@ -331,11 +341,19 @@ Hinweis Janus: # Restart icecast every morning at 7:15 15 7 * * * /etc/init.d/icecast2 restart ``` + ### Save crontabs - ctrl O - Enter + +```text +ctrl O +Enter +``` + ### Exit editor - ctrl X + +```text +ctrl X +``` --- @@ -355,25 +373,25 @@ bash osmtool_backup.sh [weitere Parameter] ### Wichtige Kommandos -| Kommando | Beschreibung | -|----------------------------------|-------------| -| `regionsiniteilen ` | Teilt die Regions.ini einer Region in einzelne INI-Dateien auf. | -| `autoregionsiniteilen` | Teilt alle Regions.ini-Dateien automatisch auf. | -| `createregionlist` | Erstellt eine Liste aller Regionen. | -| `regionbackup ` | Backup einer bestimmten Region inkl. OAR, Terrain und Konfiguration. | -| `autoregionbackup` | Automatisches Backup aller Regionen nacheinander. | -| `backup_config` | Sichert Konfigurationsdateien aus robust/bin und sim-Verzeichnissen. | -| `restore_config` | Stellt Konfigurationsdateien aus dem Backup wieder her. | -| `autoallclean` | Löscht Log- und Binärdateien für eine saubere Neuinstallation. | -| `datenbanktabellen ` | Zählt Tabellen & Asset-Typen in einer Datenbank. | -| `backuptabelle_noassets ` | Sichert alle Tabellen (außer assets) als ZIP. | -| `asset_backup ` | Sichert alle Asset-Typen einzeln. | -| `db_restoretabelle_noassets ` | Stellt alle Tabellen (außer assets) aus Backup wieder her. | -| `asset_restore ` | Stellt die Asset-Typen aus Backup wieder her. | -| `sichere_wordweb_und_money ` | Sichert die Datenbanken `wordweb` und `money`. | -| `restore_wordweb_und_money ` | Stellt die Datenbanken `wordweb` und `money` wieder her. | +|Kommando|Beschreibung| +|---|---| +|`regionsiniteilen `|Teilt die Regions.ini einer Region in einzelne INI-Dateien auf.| +|`autoregionsiniteilen`|Teilt alle Regions.ini-Dateien automatisch auf.| +|`createregionlist`|Erstellt eine Liste aller Regionen.| +|`regionbackup `|Backup einer bestimmten Region inkl. OAR, Terrain und Konfiguration.| +|`autoregionbackup`|Automatisches Backup aller Regionen nacheinander.| +|`backup_config`|Sichert Konfigurationsdateien aus robust/bin und sim-Verzeichnissen.| +|`restore_config`|Stellt Konfigurationsdateien aus dem Backup wieder her.| +|`autoallclean`|Löscht Log- und Binärdateien für eine saubere Neuinstallation.| +|`datenbanktabellen `|Zählt Tabellen und Asset-Typen in einer Datenbank.| +|`backuptabelle_noassets `|Sichert alle Tabellen (außer assets) als ZIP.| +|`asset_backup `|Sichert alle Asset-Typen einzeln.| +|`db_restoretabelle_noassets `|Stellt alle Tabellen (außer assets) aus Backup wieder her.| +|`asset_restore `|Stellt die Asset-Typen aus Backup wieder her.| +|`sichere_wordweb_und_money `|Sichert die Datenbanken `wordweb` und `money`.| +|`restore_wordweb_und_money `|Stellt die Datenbanken `wordweb` und `money` wieder her.| -## Beispiele +## Beispiele osmtool_backup.sh **Backup einer Region:** @@ -414,7 +432,7 @@ bash osmtool_backup.sh datenbanktabellen mein_benutzer geheim123 meine_datenbank Ein schlankes Skript zum Neustart des Servers und zur Überprüfung, ob alle Komponenten ordnungsgemäß laufen. -### Verhalten bei Ausfällen: +### Verhalten bei Ausfällen - Wenn der **RobustServer** nicht läuft, wird das **gesamte Grid neu gestartet**. - Wenn der **MoneyServer** nicht läuft, wird das **gesamte Grid neu gestartet**. @@ -425,12 +443,9 @@ Ein schlankes Skript zum Neustart des Servers und zur Überprüfung, ob alle Kom ## **📜 Lizenz & Nutzung** -* **Skriptname**: `osmtool.sh` -* **Version**: *V25.5.109.442* -* **Autor**: *Manfred Aabye* -* **Lizenz**: *MIT* +- **Skriptname**: `osmtool.sh` +- **Version**: *V25.5.109.442* +- **Autor**: *Manfred Aabye* +- **Lizenz**: *MIT* --- - - - diff --git a/REGIONSSERVER.md b/REGIONSSERVER.md new file mode 100644 index 0000000..2269427 --- /dev/null +++ b/REGIONSSERVER.md @@ -0,0 +1,86 @@ +# Handbuch: Regionsserver mit Hypergrid + +Dieses Handbuch beschreibt einen separaten Regionsserver, der an einen zentralen Robust-Grid-Server angebunden ist. + +## 1. Zweck und Rolle + +Ein Regionsserver hostet nur Regionen (sim1, sim2, ...) und nutzt zentrale Dienste vom Grid-Server. + +## 2. Voraussetzungen + +- Grid-Server mit laufendem Robust vorhanden +- Ubuntu Server 18.04 bis 24.04 mit bash +- Root/Sudo-Rechte auf dem Server +- Projekt unter /opt/opensimMULTITOOLS-II + +Wichtig: + +- Die technische Server-Vorbereitung erfolgt ueber die Install-Aktionen (prepare-ubuntu, install-opensim-deps, install-dotnet8). +- Es wird keine vorinstallierte Firewall vorausgesetzt. + +Manuelle Eingaben durch den Betreiber: + +- DNS/FQDN bzw. oeffentliche Host/IP-Werte +- Endpunkte auf den zentralen Robust-Server + +## 3. Installation auf dem Regionsserver + +```bash +cd /opt/opensimMULTITOOLS-II +chmod +x osmtool_main.sh modular/*.sh + +bash osmtool_main.sh --profile grid-sim --module install --action prepare-ubuntu --workdir /opt +bash osmtool_main.sh --profile grid-sim --module install --action install-opensim-deps --workdir /opt +bash osmtool_main.sh --profile grid-sim --module install --action install-dotnet8 --workdir /opt +bash osmtool_main.sh --profile grid-sim --module install --action server-check --workdir /opt +bash osmtool_main.sh --profile grid-sim --module install --action install-opensim --workdir /opt +bash osmtool_main.sh --profile grid-sim --module install --action configure-opensim --workdir /opt +``` + +## 4. Hypergrid- und Grid-Anbindung + +Datei pruefen/anpassen: + +- /opt/sim1/bin/OpenSim.ini (analog fuer weitere sim*) + +Wichtige Punkte: + +- Grid-/Robust-Endpunkte auf zentralen Robust-FQDN setzen +- Hypergrid/Gatekeeper-Abschnitte aktiv +- Keine lokalen Testwerte fuer externe URI + +## 5. Betrieb nur fuer Regionen + +### 5.1 Region starten + +```bash +bash osmtool_main.sh --profile grid-sim --module startstop --target sim1 --action start --workdir /opt +``` + +### 5.2 Region neustarten/stoppen + +```bash +bash osmtool_main.sh --profile grid-sim --module startstop --target sim1 --action restart --workdir /opt +bash osmtool_main.sh --profile grid-sim --module startstop --target sim1 --action stop --workdir /opt +``` + +### 5.3 Monitoring + +```bash +bash osmtool_main.sh --profile grid-sim --module health --action run --workdir /opt +bash osmtool_main.sh --profile grid-sim --module report --action generate --workdir /opt +``` + +## 6. Typische Fehler + +- "Target not allowed for this profile": Profil auf grid-sim stellen. +- Region startet, aber kein HG-Travel: FQDN/URI und NAT pruefen. +- Kein Login ins Grid: Robust-Endpunkte in OpenSim.ini verifizieren. + +## 7. Abnahmecheckliste + +- [ ] Region startet sauber +- [ ] Region verbindet sich mit zentralem Robust +- [ ] Hypergrid-Endpunkte extern erreichbar +- [ ] report/health ohne kritische Fehler +- [ ] HG-Reise in beide Richtungen getestet diff --git a/STANDALONE.md b/STANDALONE.md new file mode 100644 index 0000000..1302645 --- /dev/null +++ b/STANDALONE.md @@ -0,0 +1,94 @@ +# Handbuch: OpenSim Standalone mit Hypergrid + +Dieses Handbuch beschreibt den Betrieb einer OpenSim-Standalone-Instanz mit aktivierter Hypergrid-Funktion. + +## 1. Zweck und Rolle + +Standalone bedeutet: Alle Dienste auf einem Host, geeignet fuer Test, Entwicklung oder kleine produktive Setups. + +## 2. Voraussetzungen + +- Ubuntu Server 18.04 bis 24.04 mit bash +- Root/Sudo-Rechte auf dem Server +- Projekt unter /opt/opensimMULTITOOLS-II + +Wichtig: + +- Die technische Server-Vorbereitung erfolgt ueber die Install-Aktionen (prepare-ubuntu, install-opensim-deps, install-dotnet8). +- Es wird keine vorinstallierte Firewall vorausgesetzt. +- Paketinstallation und Basis-Setup werden vom Tool ausgefuehrt. + +Manuelle Eingaben durch den Betreiber: + +- Oeffentlicher FQDN/IP fuer Hypergrid +- Datenbank-Zugangsdaten (falls verwendet) + +## 3. Installation + +```bash +cd /opt/opensimMULTITOOLS-II +chmod +x osmtool_main.sh modular/*.sh + +bash osmtool_main.sh --profile standalone --module install --action prepare-ubuntu --workdir /opt +bash osmtool_main.sh --profile standalone --module install --action install-opensim-deps --workdir /opt +bash osmtool_main.sh --profile standalone --module install --action install-dotnet8 --workdir /opt +bash osmtool_main.sh --profile standalone --module install --action server-check --workdir /opt +bash osmtool_main.sh --profile standalone --module install --action install-opensim --workdir /opt +bash osmtool_main.sh --profile standalone --module install --action configure-opensim --workdir /opt +``` + +Optional Datenbanksetup: + +```bash +bash osmtool_main.sh --profile standalone --module install --action configure-database --workdir /opt --db-user opensim --db-pass 'DEIN_PASSWORT' +``` + +## 4. Hypergrid-Konfiguration + +Datei pruefen/anpassen: + +- /opt/standalone/bin/OpenSim.ini + +Wichtige Punkte: + +- Hypergrid-Abschnitte aktivieren +- Externe URI/FQDN korrekt setzen +- Keine localhost/127.0.0.1 in extern relevanten URI + +## 5. Betrieb + +### 5.1 Start/Stop/Restart + +```bash +bash osmtool_main.sh --profile standalone --module startstop --action start --workdir /opt +bash osmtool_main.sh --profile standalone --module startstop --action restart --workdir /opt +bash osmtool_main.sh --profile standalone --module startstop --action stop --workdir /opt +``` + +### 5.2 Monitoring + +```bash +bash osmtool_main.sh --profile standalone --module smoke --action run --workdir /opt +bash osmtool_main.sh --profile standalone --module health --action run --workdir /opt +bash osmtool_main.sh --profile standalone --module report --action generate --workdir /opt +``` + +## 6. Cron-Einrichtung + +```bash +bash osmtool_main.sh --profile standalone --module cron --action install --workdir /opt --db-user opensim --db-pass 'DEIN_PASSWORT' --db-name opensim --region sim1 --session sim1 +bash osmtool_main.sh --profile standalone --module cron --action list --workdir /opt +``` + +## 7. Typische Fehler + +- Instanz laeuft lokal, aber kein HG-Travel: externe URI und NAT fehlen. +- Startfehler nach Update: mit report/health und Logs pruefen. +- Unstabiler Betrieb: smoke/report cron aktivieren. + +## 8. Abnahmecheckliste + +- [ ] Standalone startet sauber +- [ ] Hypergrid-Endpunkte extern erreichbar +- [ ] smoke/health/report erfolgreich +- [ ] HG-Reise zu externem Grid erfolgreich diff --git a/modular/osmtool_cleanup.sh b/modular/osmtool_cleanup.sh index 51ac331..adb3e2f 100644 --- a/modular/osmtool_cleanup.sh +++ b/modular/osmtool_cleanup.sh @@ -2,7 +2,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_config.sh b/modular/osmtool_config.sh index 05f5ece..3a0eb89 100644 --- a/modular/osmtool_config.sh +++ b/modular/osmtool_config.sh @@ -2,7 +2,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_core.sh b/modular/osmtool_core.sh index c77fc16..86d2e9c 100644 --- a/modular/osmtool_core.sh +++ b/modular/osmtool_core.sh @@ -48,7 +48,7 @@ profile_action_allowed() { case "$module:$profile" in install:grid-sim|install:robust|install:standalone) - case "$action" in bootstrap-server|server-check|prepare-ubuntu|install-opensim-deps|install-dotnet8|install-opensim|configure-opensim|configure-database|compile-janus|configure-janus|install-janus) return 0 ;; esac + case "$action" in server-check|prepare-ubuntu|install-opensim-deps|install-dotnet8|install-opensim|configure-opensim|configure-database|compile-janus|configure-janus|install-janus) return 0 ;; esac ;; startstop:grid-sim|startstop:robust|startstop:standalone) case "$action" in start|stop|restart) return 0 ;; esac diff --git a/modular/osmtool_cron.sh b/modular/osmtool_cron.sh index b4f00bc..da23194 100644 --- a/modular/osmtool_cron.sh +++ b/modular/osmtool_cron.sh @@ -3,7 +3,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_data.sh b/modular/osmtool_data.sh index 68c7e68..030b063 100644 --- a/modular/osmtool_data.sh +++ b/modular/osmtool_data.sh @@ -2,7 +2,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_health.sh b/modular/osmtool_health.sh index c03bd0b..e1d89ad 100644 --- a/modular/osmtool_health.sh +++ b/modular/osmtool_health.sh @@ -3,7 +3,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_install.sh b/modular/osmtool_install.sh index 1577485..2a0f4ef 100644 --- a/modular/osmtool_install.sh +++ b/modular/osmtool_install.sh @@ -2,13 +2,13 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { cat <<'EOF' Usage: - osmtool_install.sh [--workdir ] --action + osmtool_install.sh [--workdir ] --action [--opensim-dir ] [--opensim-repo ] [--opensim-branch ] [--repo-mode ] [--tsassets-dir ] [--currency-dir ] [--data-backup-dir ] [--deploy-binaries ] [--legacy-patch-dir ] @@ -18,7 +18,6 @@ Usage: [--api-secret ] [--admin-secret ] Actions: - bootstrap-server Server zentral vorbereiten (Pflicht vor Build/Install) server-check Validate server readiness and required dependencies prepare-ubuntu Basic apt update/upgrade and base packages install-opensim-deps Install OpenSim runtime dependencies @@ -31,7 +30,7 @@ Actions: install-janus Compile + configure Janus in one run Examples: - osmtool_install.sh --action bootstrap-server --workdir /opt + osmtool_install.sh --action server-check --workdir /opt osmtool_install.sh --action configure-opensim --profile grid-sim --workdir /opt osmtool_install.sh --action configure-database --workdir /opt --db-user opensim --db-pass secret EOF @@ -264,7 +263,8 @@ install_dotnet8() { if ! apt-cache policy dotnet-sdk-8.0 | grep -q "Candidate:"; then local version_id pkg_url pkg_file - version_id="$(. /etc/os-release && echo "${VERSION_ID}")" + version_id="$(awk -F= '/^VERSION_ID=/{gsub(/\"/,"",$2); print $2; exit}' /etc/os-release 2>/dev/null || true)" + [[ -n "$version_id" ]] || die "Could not detect VERSION_ID from /etc/os-release" pkg_url="https://packages.microsoft.com/config/ubuntu/${version_id}/packages-microsoft-prod.deb" pkg_file="/tmp/packages-microsoft-prod.deb" @@ -351,17 +351,6 @@ ensure_mariadb_service() { log INFO "No controllable MariaDB service unit detected; skipping service activation" } -bootstrap_server() { - log INFO "Starting central server bootstrap" - prepare_ubuntu - install_opensim_deps - install_dotnet8 - ensure_mariadb_service - server_check - mark_server_prepared - log INFO "Central server bootstrap completed" -} - copy_ini_if_missing() { local bin_dir="$1" local src_name="$2" @@ -617,10 +606,12 @@ server_check() { log INFO "Running server readiness check" if [[ -f /etc/os-release ]]; then - # shellcheck disable=SC1091 - source /etc/os-release - os_id="${ID:-unknown}" - log INFO "Detected OS: ${PRETTY_NAME:-unknown}" + os_id="$(awk -F= '/^ID=/{gsub(/\"/,"",$2); print $2; exit}' /etc/os-release 2>/dev/null || true)" + [[ -n "$os_id" ]] || os_id="unknown" + local os_pretty + os_pretty="$(awk -F= '/^PRETTY_NAME=/{gsub(/\"/,"",$2); print $2; exit}' /etc/os-release 2>/dev/null || true)" + [[ -n "$os_pretty" ]] || os_pretty="unknown" + log INFO "Detected OS: $os_pretty" fi if [[ "$os_id" != "ubuntu" && "$os_id" != "debian" ]]; then @@ -729,29 +720,6 @@ generate_alnum_token() { tr -dc 'A-Za-z0-9' /dev/null || sudo mkdir -p "$WORKDIR" - cat </dev/null -PREPARED_AT=$(date '+%Y-%m-%d %H:%M:%S') -WORKDIR=$WORKDIR -PROFILE=$PROFILE -DOTNET_REQUIRED=8.0 -EOF - log INFO "Server bootstrap marker created: $marker" -} - -ensure_server_prepared() { - local marker - marker="$(server_prep_marker)" - [[ -f "$marker" ]] || die "Server preinstallation missing. Run install action bootstrap-server first." -} - compile_janus() { need_cmd apt-get need_cmd git @@ -994,12 +962,6 @@ case "$DEPLOY_BINARIES" in *) die "--deploy-binaries must be true or false" ;; esac -case "$ACTION" in - install-opensim|configure-opensim|configure-database|compile-janus|configure-janus|install-janus) - ensure_server_prepared - ;; -esac - log INFO "Using workdir: $WORKDIR" log INFO "Using profile: $PROFILE" log INFO "Repo mode: $REPO_MODE" @@ -1007,7 +969,6 @@ log INFO "OpenSim dir: $OPENSIM_DIR" log INFO "Janus prefix: $JANUS_PREFIX" case "$ACTION" in - bootstrap-server) bootstrap_server ;; server-check) server_check ;; prepare-ubuntu) prepare_ubuntu ;; install-opensim-deps) install_opensim_deps ;; diff --git a/modular/osmtool_report.sh b/modular/osmtool_report.sh index 01265a0..afbe7b1 100644 --- a/modular/osmtool_report.sh +++ b/modular/osmtool_report.sh @@ -3,7 +3,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_restore.sh b/modular/osmtool_restore.sh index a1ddbc4..845e371 100644 --- a/modular/osmtool_restore.sh +++ b/modular/osmtool_restore.sh @@ -2,7 +2,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_smoke.sh b/modular/osmtool_smoke.sh index 321f7fb..ef0f28a 100644 --- a/modular/osmtool_smoke.sh +++ b/modular/osmtool_smoke.sh @@ -3,7 +3,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_startstop.sh b/modular/osmtool_startstop.sh index bcc4e49..dbde8e5 100644 --- a/modular/osmtool_startstop.sh +++ b/modular/osmtool_startstop.sh @@ -2,7 +2,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/modular/osmtool_update.sh b/modular/osmtool_update.sh index 6ebee54..eff702b 100644 --- a/modular/osmtool_update.sh +++ b/modular/osmtool_update.sh @@ -2,7 +2,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=./osmtool_core.sh +# shellcheck source=/dev/null source "$SCRIPT_DIR/osmtool_core.sh" usage() { diff --git a/osmtool_backup.sh b/osmtool_backup.sh index 1f2719a..fae6cb8 100644 --- a/osmtool_backup.sh +++ b/osmtool_backup.sh @@ -7,6 +7,7 @@ ROBUSTVERZEICHNIS="Robust" # Robust Verzeichnis REGIONSDATEI="osmregionlist.ini" # Regionsdatei SIMDATEI="osmsimlist.ini" # Simulationsdatei BACKUPWARTEZEIT=60 # Wartezeit in Sekunden zwischen den Backups +DATUM=$(date '+%Y-%m-%d_%H-%M-%S') # Zeitstempel fuer Backupdateien KOMMANDO=$1 @@ -526,7 +527,7 @@ function db_restoretabelle_noassets() { echo "📦 Starte Wiederherstellung aus: $restorepath" | tee -a "$logfile" restored=0 - total=$(grep -v "^assets$" liste.txt | wc -l) + total=$(grep -cv "^assets$" liste.txt) echo "🔍 Tabellen zur Wiederherstellung (ohne 'assets'): $total" | tee -a "$logfile" while IFS= read -r tabellenname; do @@ -586,14 +587,14 @@ function sichere_wordweb_und_money() { # WORDWEB sichern echo "💾 Sichere Datenbank: wordweb" | tee -a "$logfile" - mysqldump -u"$username" -p"$password" wordweb | zip > /$STARTVERZEICHNIS/backup/wordweb/wordweb_${datum}.sql.zip - size_wordweb=$(du -sh /$STARTVERZEICHNIS/backup/wordweb/wordweb_${datum}.sql.zip | cut -f1) + mysqldump -u"$username" -p"$password" wordweb | zip > "/$STARTVERZEICHNIS/backup/wordweb/wordweb_${datum}.sql.zip" + size_wordweb=$(du -sh "/$STARTVERZEICHNIS/backup/wordweb/wordweb_${datum}.sql.zip" | cut -f1) echo "✅ wordweb gesichert → Größe: $size_wordweb" | tee -a "$logfile" # MONEY sichern echo "💾 Sichere Datenbank: money" | tee -a "$logfile" - mysqldump -u"$username" -p"$password" money | zip > /$STARTVERZEICHNIS/backup/money/money_${datum}.sql.zip - size_money=$(du -sh /$STARTVERZEICHNIS/backup/money/money_${datum}.sql.zip | cut -f1) + mysqldump -u"$username" -p"$password" money | zip > "/$STARTVERZEICHNIS/backup/money/money_${datum}.sql.zip" + size_money=$(du -sh "/$STARTVERZEICHNIS/backup/money/money_${datum}.sql.zip" | cut -f1) echo "✅ money gesichert → Größe: $size_money" | tee -a "$logfile" echo "📦 Sicherung abgeschlossen: $(date '+%Y-%m-%d %H:%M:%S')" | tee -a "$logfile" @@ -604,7 +605,7 @@ function restore_wordweb_und_money() { password=$2 for dbname in wordweb money; do restorepath="/$STARTVERZEICHNIS/backup/${dbname}" - latestfile=$(ls -t "$restorepath"/*.sql.zip | head -n 1) + latestfile=$(find "$restorepath" -maxdepth 1 -type f -name "*.sql.zip" -printf '%T@ %p\n' | sort -nr | head -n 1 | cut -d' ' -f2-) if [[ -f "$latestfile" ]]; then echo "🔄 Wiederherstellung: $dbname aus $latestfile" unzip -p "$latestfile" | mysql -u"$username" -p"$password" "$dbname" @@ -628,7 +629,7 @@ function backup_config() { dest_dir="${backup_root}/${src_dir}" echo "${SYM_OK} ${COLOR_START}Sichere ${COLOR_DIR}${src_dir}${COLOR_RESET} nach ${COLOR_DIR}${dest_dir}${COLOR_RESET}" find "$src_dir" -type f -name "*.ini" | while read -r file; do - rel_path="${file#$src_dir/}" # relativer Pfad + rel_path="${file#"$src_dir"/}" # relativer Pfad mkdir -p "${dest_dir}/$(dirname "$rel_path")" cp "$file" "${dest_dir}/$rel_path" done @@ -643,7 +644,7 @@ function backup_config() { dest_dir="${backup_root}/${sim_dir}" echo "${SYM_OK} ${COLOR_START}Sichere ${COLOR_DIR}${sim_dir}${COLOR_RESET} nach ${COLOR_DIR}${dest_dir}${COLOR_RESET}" find "$sim_dir" -type f -name "*.ini" | while read -r file; do - rel_path="${file#$sim_dir/}" + rel_path="${file#"$sim_dir"/}" mkdir -p "${dest_dir}/$(dirname "$rel_path")" cp "$file" "${dest_dir}/$rel_path" done @@ -668,7 +669,7 @@ function restore_config() { if [[ -d "$src_dir" ]]; then echo "${SYM_OK} ${COLOR_START}Stelle ${COLOR_DIR}${dest_dir}${COLOR_RESET} aus ${COLOR_DIR}${src_dir}${COLOR_RESET} wieder her" find "$src_dir" -type f -name "*.ini" | while read -r file; do - rel_path="${file#$src_dir/}" + rel_path="${file#"$src_dir"/}" mkdir -p "${dest_dir}/$(dirname "$rel_path")" cp "$file" "${dest_dir}/$rel_path" done @@ -683,7 +684,7 @@ function restore_config() { if [[ -d "$src_dir" ]]; then echo "${SYM_OK} ${COLOR_START}Stelle ${COLOR_DIR}${dest_dir}${COLOR_RESET} aus ${COLOR_DIR}${src_dir}${COLOR_RESET} wieder her" find "$src_dir" -type f -name "*.ini" | while read -r file; do - rel_path="${file#$src_dir/}" + rel_path="${file#"$src_dir"/}" mkdir -p "${dest_dir}/$(dirname "$rel_path")" cp "$file" "${dest_dir}/$rel_path" done diff --git a/osmtool_main.sh b/osmtool_main.sh index 136a781..5f3bcd5 100644 --- a/osmtool_main.sh +++ b/osmtool_main.sh @@ -4,7 +4,7 @@ set -euo pipefail BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" MOD_DIR="$BASE_DIR/modular" -# shellcheck source=./modular/osmtool_core.sh +# shellcheck source=/dev/null source "$MOD_DIR/osmtool_core.sh" init_i18n @@ -12,8 +12,14 @@ usage() { cat <<'EOF' Usage: osmtool_main.sh [--mode ] [--lang ] [--profile ] --module [module-options] + osmtool_main.sh server_install + osmtool_main.sh Examples: + osmtool_main.sh server_install + osmtool_main.sh opensimstart + osmtool_main.sh opensimrestart + osmtool_main.sh croninstall osmtool_main.sh --module install --action prepare-ubuntu osmtool_main.sh --module startstop --target grid --action restart --workdir /opt osmtool_main.sh --module cleanup --action log-clean --workdir /opt @@ -118,7 +124,6 @@ ui_flow() { case "$module" in install) action="$(show_menu "$(msg MENU_INSTALL)" "$(msg MENU_CHOOSE_ACTION)" \ - "bootstrap-server" "bootstrap-server" \ "server-check" "server-check" \ "prepare-ubuntu" "prepare-ubuntu" \ "install-opensim-deps" "install-opensim-deps" \ @@ -226,8 +231,113 @@ LANG_OVERRIDE="${OSM_LANG:-de}" PROFILE="grid-sim" if [[ $# -eq 0 ]]; then + MODE="ui" + ui_flow + exit 0 +fi + +if [[ "${1:-}" == "h" || "${1:-}" == "help" ]]; then usage - exit 1 + exit 0 +fi + +if [[ "${1:-}" == "server_install" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + + log INFO "Running server_install shortcut (prepare-ubuntu -> install-opensim-deps -> install-dotnet8 -> server-check -> install-opensim -> configure-opensim)" + dispatch_module install --action prepare-ubuntu --workdir /opt + dispatch_module install --action install-opensim-deps --workdir /opt + dispatch_module install --action install-dotnet8 --workdir /opt + dispatch_module install --action server-check --workdir /opt + dispatch_module install --action install-opensim --workdir /opt + dispatch_module install --action configure-opensim --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "opensimstart" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module startstop --target "$(default_target_for_profile "$PROFILE")" --action start --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "opensimstop" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module startstop --target "$(default_target_for_profile "$PROFILE")" --action stop --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "opensimrestart" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module startstop --target "$(default_target_for_profile "$PROFILE")" --action restart --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "healthcheck" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module health --action run --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "smoketest" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module smoke --action run --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "dailyreport" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module report --action generate --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "croninstall" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module cron --action install --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "cronlist" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module cron --action list --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "janusinstall" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module install --action install-janus --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "janusrestart" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + dispatch_module startstop --target janus --action restart --workdir /opt + exit 0 +fi + +if [[ "${1:-}" == "dbsetup" ]]; then + set_language "$LANG_OVERRIDE" + validate_profile "$PROFILE" + + DB_USER_SHORT="${OSM_DB_USER:-opensim}" + DB_PASS_SHORT="${OSM_DB_PASS:-}" + DB_ROOT_USER_SHORT="${OSM_DB_ROOT_USER:-root}" + DB_ROOT_PASS_SHORT="${OSM_DB_ROOT_PASS:-}" + + [[ -n "$DB_PASS_SHORT" ]] || die "dbsetup requires OSM_DB_PASS environment variable" + + dispatch_module install --action configure-database --workdir /opt --db-user "$DB_USER_SHORT" --db-pass "$DB_PASS_SHORT" --db-root-user "$DB_ROOT_USER_SHORT" --db-root-pass "$DB_ROOT_PASS_SHORT" + exit 0 fi while [[ $# -gt 0 ]]; do