Refactor installer into modular orchestration framework
This commit is contained in:
parent
c7b660df9a
commit
b1f35a5ef4
0
config/installer.conf
Normal file
0
config/installer.conf
Normal file
@ -82,6 +82,24 @@ verify_workdir() {
|
||||
echo "GRUB verification passed."
|
||||
}
|
||||
|
||||
create_iso() {
|
||||
echo "Creating Tuxflotte ISO..."
|
||||
|
||||
local output_iso="$OUTPUT_DIR/tuxflotte-provisioning-0.1.iso"
|
||||
|
||||
rm -f "$output_iso"
|
||||
|
||||
xorriso \
|
||||
-indev "$SOURCE_ISO" \
|
||||
-outdev "$output_iso" \
|
||||
-compliance no_emul_toc \
|
||||
-map "$REPO_DIR/grub/EFI-BOOT-grub.cfg" /EFI/BOOT/grub.cfg \
|
||||
-map "$REPO_DIR/grub/boot-grub2-grub.cfg" /boot/grub2/grub.cfg \
|
||||
-boot_image any replay
|
||||
|
||||
echo "ISO created: $output_iso"
|
||||
}
|
||||
|
||||
main() {
|
||||
check_input
|
||||
check_dependencies
|
||||
@ -89,6 +107,7 @@ main() {
|
||||
extract_iso
|
||||
patch_grub
|
||||
verify_workdir
|
||||
create_iso
|
||||
|
||||
echo
|
||||
echo "Build preparation complete."
|
||||
|
||||
33
scripts/installer.sh
Executable file
33
scripts/installer.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
INSTALLER_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
source "$SCRIPT_DIR/lib/logging.sh"
|
||||
source "$SCRIPT_DIR/lib/errors.sh"
|
||||
source "$SCRIPT_DIR/lib/utils.sh"
|
||||
source "$SCRIPT_DIR/lib/checks.sh"
|
||||
|
||||
DRY_RUN=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run) DRY_RUN=true ;;
|
||||
*) error_exit "Unbekannter Parameter: $arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
load_config "$INSTALLER_ROOT/config/installer.conf"
|
||||
|
||||
log_info "Tuxflotte Installer gestartet"
|
||||
log_info "Installer Root: $INSTALLER_ROOT"
|
||||
|
||||
[[ "$DRY_RUN" == true ]] && log_warn "Dry-Run aktiv"
|
||||
|
||||
run_module "$SCRIPT_DIR/modules/00_preflight.sh" "always"
|
||||
run_module "$SCRIPT_DIR/modules/10_hardware.sh" "always"
|
||||
run_module "$SCRIPT_DIR/modules/20_storage.sh" "dry-run-safe"
|
||||
run_module "$SCRIPT_DIR/modules/99_finish.sh" "always"
|
||||
|
||||
log_success "Tuxflotte Installer abgeschlossen"
|
||||
17
scripts/lib/checks.sh
Normal file
17
scripts/lib/checks.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
detect_uefi() {
|
||||
if [[ -d /sys/firmware/efi ]]; then
|
||||
echo "uefi"
|
||||
else
|
||||
echo "bios"
|
||||
fi
|
||||
}
|
||||
|
||||
check_network() {
|
||||
ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1
|
||||
}
|
||||
|
||||
list_install_disks() {
|
||||
lsblk -dpno NAME,SIZE,MODEL,TRAN,TYPE | awk '$5 == "disk" && $4 != "usb" {print}'
|
||||
}
|
||||
8
scripts/lib/errors.sh
Normal file
8
scripts/lib/errors.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
error_exit() {
|
||||
log_error "$1"
|
||||
exit "${2:-1}"
|
||||
}
|
||||
|
||||
trap 'error_exit "Unerwarteter Fehler in Zeile $LINENO."' ERR
|
||||
17
scripts/lib/logging.sh
Normal file
17
scripts/lib/logging.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
log_info() {
|
||||
echo "[INFO ] $*"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo "[WARN ] $*" >&2
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo "[ERROR] $*" >&2
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo "[ OK ] $*"
|
||||
}
|
||||
40
scripts/lib/utils.sh
Normal file
40
scripts/lib/utils.sh
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
load_config() {
|
||||
local config_file="$1"
|
||||
|
||||
if [[ -f "$config_file" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$config_file"
|
||||
log_info "Konfiguration geladen: $config_file"
|
||||
else
|
||||
log_warn "Keine Konfiguration gefunden: $config_file"
|
||||
fi
|
||||
}
|
||||
|
||||
run_module() {
|
||||
local module="$1"
|
||||
local mode="${2:-normal}"
|
||||
|
||||
[[ -f "$module" ]] || error_exit "Modul nicht gefunden: $module"
|
||||
|
||||
log_info "Starte Modul: $(basename "$module")"
|
||||
|
||||
if [[ "${DRY_RUN:-false}" == true && "$mode" != "always" ]]; then
|
||||
log_warn "Dry-Run: Modul übersprungen: $module"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$module"
|
||||
|
||||
log_success "Modul abgeschlossen: $(basename "$module")"
|
||||
}
|
||||
|
||||
require_root() {
|
||||
[[ "$EUID" -eq 0 ]] || error_exit "Installer muss als root ausgeführt werden."
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
0
scripts/modules/00_preflight.sh
Executable file
0
scripts/modules/00_preflight.sh
Executable file
0
scripts/modules/10_hardware.sh
Executable file
0
scripts/modules/10_hardware.sh
Executable file
14
scripts/modules/20_storage.sh
Executable file
14
scripts/modules/20_storage.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
log_info "Datenträger werden erkannt..."
|
||||
|
||||
DISKS="$(list_install_disks || true)"
|
||||
|
||||
if [[ -z "$DISKS" ]]; then
|
||||
error_exit "Keine geeigneten Datenträger erkannt."
|
||||
fi
|
||||
|
||||
echo "$DISKS"
|
||||
|
||||
log_warn "Phase 1: Datenträger werden nur angezeigt, nicht verändert."
|
||||
log_warn "Partitionierung ist noch deaktiviert."
|
||||
0
scripts/modules/99_finish.sh
Executable file
0
scripts/modules/99_finish.sh
Executable file
Loading…
x
Reference in New Issue
Block a user