30_runtime_blueprint.sh calls POST /templates/{id}/resolve with the
device_id from the server handshake and the template_id from the
Bereitstellungsvorlage selection, storing the resulting Runtime
Blueprint under /run/tuxflotte/runtime/.
40_backend.sh dispatches to backends/${backend_id}/backend.sh based on
the resolved backend_id and drives the backend_init/validate/
generate_config/launch/postinstall lifecycle from 06-backend-api.md.
backends/fedora/backend.sh implements that lifecycle for Fedora:
backend_generate_config() renders kickstart.tpl via envsubst using the
Runtime Blueprint's installation_directives and the device hostname,
embedding the resolved Merkmal blueprints as JSON for the (not yet
implemented) Provisioning Agent to apply later. Replaces the old
git-clone-based %post bootstrap. backend_launch()/backend_postinstall()
are Phase 1 stubs pending the live-ISO boot integration (see
platform-docs ADR-0003).
71 lines
1.8 KiB
Bash
71 lines
1.8 KiB
Bash
#!/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 "$@"
|