Initial public import of the proven Bash installer (installer/) and the production Rust workspace (installer-rs/). The reference ISO, build output and local agent transcripts are gitignored. Verified: installer/tests/run_tests.sh and cargo test --workspace both pass.
162 lines
4.7 KiB
Bash
162 lines
4.7 KiB
Bash
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
#
|
|
# Main menu and review/install flow.
|
|
|
|
# _status_line - short right-hand column value for menu entries
|
|
_menu_items() {
|
|
printf '%s\n' \
|
|
keyboard "Keyboard [$(config_get KEYMAP)]" \
|
|
network "Network [$(network_online && echo online || echo offline)]" \
|
|
source "Source [$(config_get STAGE3_URL)]" \
|
|
hostname "Hostname [$(config_get HOSTNAME)]" \
|
|
locale "Locale [$(config_get LOCALE)]" \
|
|
timezone "Timezone [$(config_get TIMEZONE)]" \
|
|
user "User [$(config_get USERNAME)]" \
|
|
disk "Disk [$(config_get TARGET_DISK)]" \
|
|
filesystem "Filesystem[$(config_get FILESYSTEM)/$(config_get ENCRYPTION)]" \
|
|
boot "Boot [$(config_get BOOTLOADER)]" \
|
|
kernel "Kernel [$(config_get KERNEL_PROFILE)]" \
|
|
packages "Packages [$(config_get PACKAGE_POLICY)]" \
|
|
desktop "Desktop [$(config_get DESKTOP_PROFILE)]" \
|
|
ai "AI [$(opencode_available && echo ready || echo not-installed)]" \
|
|
review "Review configuration" \
|
|
install "Install" \
|
|
exit "Exit"
|
|
}
|
|
|
|
# menu_review - show the full plan and validation status
|
|
menu_review() {
|
|
local tmp rc
|
|
plan_generate
|
|
tmp="$(mktemp)"
|
|
{
|
|
plan_render
|
|
printf '\n\nValidation\n==========\n'
|
|
local problems
|
|
problems="$(validate_config)"
|
|
if [[ -z "$problems" ]]; then
|
|
printf 'Configuration looks complete.\n'
|
|
else
|
|
printf '%s\n' "$problems" | sed 's/^/- /'
|
|
fi
|
|
printf '\n\nPackage policy examples\n=======================\n'
|
|
pkgpolicy_report
|
|
} >"$tmp"
|
|
ui_textbox "Review configuration" "$tmp"
|
|
rc=$?
|
|
rm -f "$tmp"
|
|
if ui_yesno "Review configuration" "Save this configuration to a file?"; then
|
|
local dest="/root/phoebus-install.conf"
|
|
config_save_file "$dest" && ui_msgbox "Saved" "Configuration saved to $dest"
|
|
fi
|
|
return $rc
|
|
}
|
|
|
|
# menu_install - the guarded, destructive path
|
|
menu_install() {
|
|
local problems preview
|
|
problems="$(validate_config)"
|
|
if [[ -n "$problems" ]]; then
|
|
ui_error "Configuration is incomplete:
|
|
|
|
$problems"
|
|
return 1
|
|
fi
|
|
|
|
plan_generate
|
|
local tmp
|
|
tmp="$(mktemp)"
|
|
plan_render >"$tmp"
|
|
ui_textbox "Installation plan" "$tmp"
|
|
rm -f "$tmp"
|
|
|
|
if config_bool DRY_RUN; then
|
|
ui_msgbox "Dry run" "Dry-run mode is enabled.
|
|
|
|
No disk will be modified. Commands are only logged."
|
|
fi
|
|
|
|
preview="$(plan_destructive_preview)"
|
|
if ! confirm_erase "$preview"; then
|
|
log_info "installation cancelled at ERASE confirmation"
|
|
ui_msgbox "Cancelled" "Installation cancelled. No changes were made."
|
|
return 1
|
|
fi
|
|
if ! confirm_action "Start the installation now? This can take a long time."; then
|
|
log_info "installation cancelled at final confirmation"
|
|
ui_msgbox "Cancelled" "Installation cancelled. No changes were made."
|
|
return 1
|
|
fi
|
|
|
|
destructive_grant
|
|
(ui_infobox "Installing" "Installation in progress. Please wait...") 2>/dev/null || true
|
|
local rc=0
|
|
install_run || rc=$?
|
|
destructive_revoke
|
|
|
|
if ((rc == 0)); then
|
|
if config_bool DRY_RUN; then
|
|
ui_msgbox "Dry run complete" "The plan executed in dry-run mode.
|
|
|
|
Log: $PHOEBUS_LOG_FILE"
|
|
else
|
|
ui_msgbox "Installation complete" "Installation finished successfully.
|
|
|
|
Log: $PHOEBUS_LOG_FILE
|
|
|
|
You can now reboot into $(config_get DISTRO_NAME)."
|
|
fi
|
|
return 0
|
|
fi
|
|
|
|
ui_error "Installation failed during stage: ${INSTALL_FAILED_STAGE:-unknown}"
|
|
if ui_yesno "Installation failed" "Show the last 60 log lines?"; then
|
|
tmp="$(mktemp)"
|
|
log_tail 60 >"$tmp"
|
|
ui_textbox "Installer log" "$tmp"
|
|
rm -f "$tmp"
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
# menu_main - the top-level loop
|
|
menu_main() {
|
|
local choice
|
|
while true; do
|
|
local -a items=()
|
|
mapfile -t items < <(_menu_items)
|
|
if ! ui_menu "Main menu" "Configure the installation, then choose Install.
|
|
|
|
Settings can be revisited at any time before installing." \
|
|
24 78 17 "${items[@]}"; then
|
|
if ui_yesno "Exit" "Exit the installer?"; then
|
|
return 0
|
|
fi
|
|
continue
|
|
fi
|
|
choice="$UI_RESULT"
|
|
case "$choice" in
|
|
keyboard) screen_keyboard ;;
|
|
network) screen_network ;;
|
|
source) screen_source ;;
|
|
hostname) screen_hostname ;;
|
|
locale) screen_locale ;;
|
|
timezone) screen_timezone ;;
|
|
user) screen_user ;;
|
|
disk) screen_disk ;;
|
|
filesystem) screen_filesystem ;;
|
|
boot) screen_boot ;;
|
|
kernel) screen_kernel ;;
|
|
packages) screen_packages ;;
|
|
desktop) screen_desktop ;;
|
|
ai) screen_ai ;;
|
|
review) menu_review ;;
|
|
install) menu_install ;;
|
|
exit)
|
|
if ui_yesno "Exit" "Exit the installer?"; then
|
|
return 0
|
|
fi ;;
|
|
esac
|
|
done
|
|
}
|