2
This commit is contained in:
@@ -20,6 +20,8 @@ source "$BOOTSTRAP_ROOT/core/runtime.sh"
|
||||
source "$BOOTSTRAP_ROOT/core/registry.sh"
|
||||
# shellcheck source=core/dispatcher.sh
|
||||
source "$BOOTSTRAP_ROOT/core/dispatcher.sh"
|
||||
# shellcheck source=core/test_runner.sh
|
||||
source "$BOOTSTRAP_ROOT/core/test_runner.sh"
|
||||
# shellcheck source=menus/main.sh
|
||||
source "$BOOTSTRAP_ROOT/menus/main.sh"
|
||||
|
||||
|
||||
@@ -40,6 +40,17 @@ dispatcher_prompt_and_run_module() {
|
||||
local nfs_mount_now=""
|
||||
local nfs_server_mode=""
|
||||
local samba_mode=""
|
||||
local grub_default_mode=""
|
||||
local grub_save_default=""
|
||||
local grub_timeout=""
|
||||
local grub_timeout_style=""
|
||||
local grub_os_prober=""
|
||||
local grub_gfxmode=""
|
||||
local grub_cmdline=""
|
||||
local grub_extra_cmdline=""
|
||||
local grub_keep_extra=""
|
||||
local grub_selection=""
|
||||
local grub_index=1
|
||||
|
||||
case "$module_id" in
|
||||
system/user-sudo)
|
||||
@@ -120,12 +131,18 @@ dispatcher_prompt_and_run_module() {
|
||||
fi
|
||||
;;
|
||||
network/nfs-server)
|
||||
nfs_server_mode="$(prompt_select_from_list "Mode de synchronisation NFS serveur" "add-only" "strict")"
|
||||
nfs_server_mode="$(prompt_select_described_from_list \
|
||||
"Mode de synchronisation NFS serveur" \
|
||||
"add-only|Ajoute seulement les exports absents sans retirer les autres." \
|
||||
"strict|Remplace la zone geree pour refléter exactement le YAML du repo.")"
|
||||
ui_info "Synchronisation des exports NFS depuis le fichier YAML du repo"
|
||||
dispatcher_run_module "$module_id" "$nfs_server_mode"
|
||||
;;
|
||||
network/samba-share)
|
||||
samba_mode="$(prompt_select_from_list "Mode de synchronisation Samba" "add-only" "strict")"
|
||||
samba_mode="$(prompt_select_described_from_list \
|
||||
"Mode de synchronisation Samba" \
|
||||
"add-only|Ajoute seulement les partages absents sans ecraser le reste." \
|
||||
"strict|Regénère la zone geree pour correspondre exactement au YAML du repo.")"
|
||||
ui_info "Synchronisation des partages Samba depuis le fichier YAML du repo"
|
||||
dispatcher_run_module "$module_id" "$samba_mode"
|
||||
;;
|
||||
@@ -140,8 +157,51 @@ dispatcher_prompt_and_run_module() {
|
||||
ui_warn "Aucune archive de theme GRUB disponible"
|
||||
return 1
|
||||
fi
|
||||
archive_name="$(prompt_select_from_list "Selectionner une archive de theme" "${grub_archives[@]}")"
|
||||
dispatcher_run_module "$module_id" "$archive_name"
|
||||
ui_section "Themes GRUB disponibles"
|
||||
grub_index=1
|
||||
for archive_name in "${grub_archives[@]}"; do
|
||||
printf ' %d. %s (%s)\n' "$grub_index" "$(module_grub_theme_archive_label "$archive_name")" "$archive_name"
|
||||
grub_index=$((grub_index + 1))
|
||||
done
|
||||
grub_selection="$(prompt_select_number "Selectionner une archive de theme" 1 "${#grub_archives[@]}")"
|
||||
archive_name="${grub_archives[$((grub_selection - 1))]}"
|
||||
grub_default_mode="$(prompt_select_described_from_list \
|
||||
"Mode de demarrage par defaut" \
|
||||
"dernier choix|Redemarre sur le dernier systeme choisi au menu GRUB." \
|
||||
"toujours Debian|Demarre toujours sur la premiere entree GRUB, en general Debian.")"
|
||||
if [[ "$grub_default_mode" == "dernier choix" ]]; then
|
||||
grub_default_mode="saved"
|
||||
elif [[ "$grub_default_mode" == "toujours Debian" ]]; then
|
||||
grub_default_mode="0"
|
||||
fi
|
||||
grub_save_default="$(prompt_confirm_default "Memoriser le dernier OS choisi au boot" "yes")"
|
||||
grub_timeout="$(prompt_read_default "Temps d'attente du menu GRUB" "5")"
|
||||
grub_timeout_style="$(prompt_select_described_from_list \
|
||||
"Style du menu GRUB" \
|
||||
"menu visible|Affiche toujours le menu GRUB pendant le delai choisi." \
|
||||
"menu cache|Cache le menu au demarrage sauf cas particulier.")"
|
||||
if [[ "$grub_timeout_style" == "menu visible" ]]; then
|
||||
grub_timeout_style="menu"
|
||||
elif [[ "$grub_timeout_style" == "menu cache" ]]; then
|
||||
grub_timeout_style="hidden"
|
||||
fi
|
||||
grub_os_prober="$(prompt_confirm_default "Activer la detection Windows et autres OS" "yes")"
|
||||
if [[ "$grub_os_prober" == "yes" ]]; then
|
||||
grub_os_prober="false"
|
||||
else
|
||||
grub_os_prober="true"
|
||||
fi
|
||||
grub_gfxmode="$(prompt_read_default "Resolution GRUB (auto, 1920x1080, 2560x1440...)" "auto")"
|
||||
grub_cmdline="$(prompt_read_default "Parametres noyau Linux par defaut" "quiet splash")"
|
||||
grub_extra_cmdline="$(module_grub_theme_extra_cmdline_options "$grub_cmdline")"
|
||||
if [[ -n "$grub_extra_cmdline" ]]; then
|
||||
ui_info "Options noyau detectees sur la machine mais absentes de la config saisie : $grub_extra_cmdline"
|
||||
grub_keep_extra="$(prompt_confirm_default "Conserver ces options supplementaires" "yes")"
|
||||
if [[ "$grub_keep_extra" == "yes" ]]; then
|
||||
grub_cmdline="$(module_grub_theme_merge_cmdline_options "$grub_cmdline" "$grub_extra_cmdline")"
|
||||
fi
|
||||
fi
|
||||
dispatcher_run_module "$module_id" "$archive_name" "$grub_default_mode" "$grub_save_default" "$grub_timeout" "$grub_timeout_style" "$grub_os_prober" "$grub_gfxmode" "$grub_cmdline"
|
||||
;;
|
||||
containers/docker-engine)
|
||||
target_user="$(prompt_read_default "Utilisateur a ajouter au groupe docker" "${POSTINSTALL_DOCKER_TARGET_USER:-gilles}")"
|
||||
|
||||
@@ -40,3 +40,15 @@ registry_module_path() {
|
||||
local module_id="$1"
|
||||
printf '%s\n' "${REGISTRY_MODULE_PATHS[$module_id]:-}"
|
||||
}
|
||||
|
||||
registry_module_test_path() {
|
||||
local module_id="$1"
|
||||
local module_path=""
|
||||
|
||||
module_path="${REGISTRY_MODULE_PATHS[$module_id]:-}"
|
||||
if [[ -z "$module_path" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf '%s\n' "${module_path%/module.sh}/tests.sh"
|
||||
}
|
||||
|
||||
38
core/test_runner.sh
Normal file
38
core/test_runner.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
test_runner_smoke() {
|
||||
ui_section "Smoke test"
|
||||
bash "$RUNTIME_PROJECT_ROOT/tests/smoke.sh"
|
||||
}
|
||||
|
||||
test_runner_module() {
|
||||
local module_id="$1"
|
||||
local test_path=""
|
||||
|
||||
test_path="$(registry_module_test_path "$module_id")"
|
||||
if [[ -z "$test_path" || ! -f "$test_path" ]]; then
|
||||
ui_warn "Aucun test disponible pour $module_id"
|
||||
return 1
|
||||
fi
|
||||
|
||||
ui_section "Test du module $module_id"
|
||||
bash "$test_path"
|
||||
}
|
||||
|
||||
test_runner_all_modules() {
|
||||
local module_id=""
|
||||
local failures=0
|
||||
|
||||
while IFS= read -r module_id; do
|
||||
[[ -n "$module_id" ]] || continue
|
||||
if ! test_runner_module "$module_id"; then
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
done < <(registry_list)
|
||||
|
||||
if [[ "$failures" -eq 0 ]]; then
|
||||
ui_success "Tous les tests modules se sont termines sans echec"
|
||||
else
|
||||
ui_warn "$failures test(s) module(s) ont retourne un echec"
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user