scripts/ (installer.sh, lib/*, modules/00-99) und backends/mint-image/ (inkl. echtem postinstall.sh statt Symlink auf backends/mint/) werden ueber config/includes.chroot/opt/tuxflotte/ ins Image kopiert - bewusst nur die zur Laufzeit benoetigten Dateien, nicht die Build-Host-Werkzeuge (build_customer_iso.sh, build_golden_image.sh, package_golden_image.sh, lib/initrd.sh etc. bleiben aussen vor). 00_preflight.sh und backend_init() (backends/mint-image/backend.sh) verlieren ihre Laufzeit-apt-get-Nachinstallation (jq, parted, dosfstools, e2fsprogs, zstd, btrfs-progs, gettext-base, curl) - alles bereits in Phase 0 vorinstalliert. Werden durch reine Assertions ersetzt, die frueh und klar melden, falls die Paketliste doch mal luecken sollte. backends/mint/postinstall.sh nach backends/mint-image/postinstall.sh als echte Datei verschoben (war Symlink) - noetig, weil backends/mint/ in Phase 4 komplett entfernt wird. Live verifiziert in der enterprise-QEMU-VM: installer.sh von Hand gestartet, Module 00/05/10/12/15/17 liefen sauber durch, inkl. echtem Server-Kontakt zu anode und echter Geraeteregistrierung (Liebherr-Org), Commit-Gate erschien interaktiv wie erwartet, kontrollierter Abbruch ohne jede destruktive Aktion.
71 lines
1.8 KiB
Bash
Executable File
71 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")"
|
|
readonly SCRIPT_NAME
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
readonly SCRIPT_DIR
|
|
BACKENDS_DIR="$(cd "${SCRIPT_DIR}/../../backends" && pwd)"
|
|
readonly BACKENDS_DIR
|
|
|
|
readonly ORCHESTRATOR_BLUEPRINT_FILE="/run/tuxflotte/runtime/runtime_blueprint.json"
|
|
|
|
log() {
|
|
printf '[%s] %s\n' "${SCRIPT_NAME}" "$*" >&2
|
|
}
|
|
|
|
fatal() {
|
|
printf '[%s] FEHLER: %s\n' "${SCRIPT_NAME}" "$*" >&2
|
|
exit 1
|
|
}
|
|
|
|
require_root() {
|
|
if [[ "${EUID}" -ne 0 ]]; then
|
|
fatal "Das Backend-Modul muss als root ausgeführt werden."
|
|
fi
|
|
}
|
|
|
|
load_backend() {
|
|
local backend_id
|
|
local backend_script
|
|
|
|
[[ -r "${ORCHESTRATOR_BLUEPRINT_FILE}" ]] ||
|
|
fatal "Runtime Blueprint nicht gefunden: ${ORCHESTRATOR_BLUEPRINT_FILE}"
|
|
|
|
backend_id="$(jq --raw-output '.runtime_blueprint.backend_id // empty' "${ORCHESTRATOR_BLUEPRINT_FILE}")"
|
|
[[ -n "${backend_id}" ]] ||
|
|
fatal "Runtime Blueprint enthält keine gültige Backend-ID."
|
|
|
|
backend_script="${BACKENDS_DIR}/${backend_id}/backend.sh"
|
|
[[ -r "${backend_script}" ]] ||
|
|
fatal "Kein Backend für '${backend_id}' gefunden: ${backend_script}"
|
|
|
|
log "Lade Backend '${backend_id}' aus ${backend_script}"
|
|
|
|
# shellcheck disable=SC1090
|
|
source "${backend_script}"
|
|
}
|
|
|
|
run_lifecycle() {
|
|
local step
|
|
|
|
for step in backend_init backend_validate backend_generate_config backend_launch backend_postinstall; do
|
|
declare -f "${step}" >/dev/null ||
|
|
fatal "Backend implementiert erforderliche Funktion nicht: ${step}"
|
|
|
|
log "Führe ${step}() aus."
|
|
|
|
"${step}" ||
|
|
fatal "${step}() ist fehlgeschlagen."
|
|
done
|
|
}
|
|
|
|
main() {
|
|
require_root
|
|
load_backend
|
|
run_lifecycle
|
|
}
|
|
|
|
main "$@"
|