diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2022-08-13 08:00:09 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2022-08-16 08:12:58 -0400 |
commit | 9e768131a7ae55066ad027908af304952abd2be9 (patch) | |
tree | 9cddcdc4f6b4dd2717f697d2d576e0e2b851b8b3 | |
parent | 1195a1630f9711d43d7db27da736eb899841241f (diff) |
add 'READY' state-var as signal for unattended install
-rwxr-xr-x | install.sh | 39 | ||||
-rw-r--r-- | translations.sh.inc | 6 |
2 files changed, 34 insertions, 11 deletions
@@ -56,6 +56,10 @@ readonly GRUB_THEME_SED_CMD='s|^#GRUB_THEME=.*|GRUB_THEME=/boot/grub/themes/para NoticeIntro() { + # checks to skip this notice per preset config + # NOTE: 'READY' is the signal for unattended install, per a preset config. + # This program will not set the 'READY' state var. + [[ -n "$(GetStateVar 'READY')" ]] || WizardDlg "${TR[dlg_intro-${Lang}]}" --msgbox "${TR[notice_intro-${Lang}]}" 0 0 } @@ -63,9 +67,14 @@ Init() { # MOCK_INIT ; return 0 ; + # check for and validate a complete unattended-install config state + if AreConfiguredStateVars 'READY' + then AreConfiguredStateVars ${STATEVARS_PRESET[*]} && + [[ "$(GetStateVar 'PART_METHOD')" == 'auto' ]] || + ExitFail "${TR[insane_preset-${Lang}]}\n${STATEVARS_PRESET[@]/#/\\n\\t* }" + # check for prior state-vars, and offer to reset them or to resume instead - # TODO: add CLI option to bypass all prompts, and a complete config state check here - if grep -vE '(LANG|TR_KEY|XKBMAP|SESSION)' "${THIS_DIR}"/.session_state &> /dev/null && + elif grep -vE '(LANG|TR_KEY|XKBMAP|SESSION)' "${THIS_DIR}"/.session_state &> /dev/null && ! (( $( WizardDlg "${TR[dlg_preconfig-${Lang}]}" \ --yesno "${TR[preconfig-${Lang}]}" 0 0 ) )) then truncate --size=0 "${THIS_DIR}"/.session_state @@ -235,6 +244,7 @@ SelectBase() NoticeOptional() { + [[ -n "$(GetStateVar 'READY')" ]] || WizardDlg "${TR[dlg_optional-${Lang}]}" --msgbox "${TR[notice_optional-${Lang}]}" 0 0 } @@ -388,6 +398,16 @@ SelectPartition() [[ -z "$(GetStateVar 'DEVICE' )" ]] || [[ -z "$(GetStateVar 'PART_METHOD')" ]] || return 0 + # NOTE: The user must select all partitioning options, + # if the 'READY' state-var is not set, even upon a resumed run. + if [[ -z "$(GetStateVar 'READY')" ]] + then # reset partitioning state (unnecessary, but pedantic) + SetStateVar 'DEVICE' ; SetStateVar 'ROOT_PART' ; + SetStateVar 'DEVICE_N' ; SetStateVar 'BOOT_PART' ; + SetStateVar 'PART_METHOD' ; SetStateVar 'HOME_PART' ; + else return 0 + fi + # query disk device information PopulateDisksOptions # populates DlgParams (( ${#DlgParams[@]} )) || ExitFail "${TR[device_none-${Lang}]}" @@ -410,13 +430,16 @@ SelectPartition() NoticeReady() { + # checks to skip this stage per preset config + ! AreConfiguredStateVars 'READY' || return 0 + local ready_msg="${TR[notice_ready-${Lang}]}" if [[ "$(GetStateVar 'PART_METHOD')" == 'auto' ]] then ready_msg+="\n\n\Z1${TR[ready_warn-${Lang}]}\Zn\n\n * $(GetStateVar 'DEVICE')" fi - (( $( WizardDlg "${TR[dlg_ready-${Lang}]}" --yesno "${ready_msg}" 0 0 ) )) || exit + (( $( WizardDlg "${TR[dlg_ready-${Lang}]}" --yesno "${ready_msg}" 8 56 ) )) || exit } _PartitionAuto() @@ -425,7 +448,7 @@ _PartitionAuto() [[ -n "$(GetStateVar 'DEVICE')" ]] # checks to skip this stage per preset config - # NOTE: this is the only path for preset configurations + # NOTE: this is the only path for preset unattended-install configurations # it currently supports only a single disk (root and swap partitions) if [[ -n "$(GetStateVar 'ROOT_PART')" ]] then SetStateVar 'BOOT_PART' '' @@ -543,13 +566,7 @@ Partition() mkfs.ext4 ${partition} > /dev/null || true # final validation - if ! blkid ${partition} | grep ' TYPE="' &> /dev/null - then # reset partitioning state (forces SelectPartition() upon resumed run) - SetStateVar 'DEVICE' ; SetStateVar 'ROOT_PART' ; - SetStateVar 'DEVICE_N' ; SetStateVar 'BOOT_PART' ; - SetStateVar 'PART_METHOD' ; SetStateVar 'HOME_PART' ; - ExitFail "${TR[abort-${Lang}]}" - fi + blkid ${partition} | grep ' TYPE="' &> /dev/null || ExitFail "${TR[abort-${Lang}]}" done # mount partitions diff --git a/translations.sh.inc b/translations.sh.inc index 7224b55..443a15b 100644 --- a/translations.sh.inc +++ b/translations.sh.inc @@ -91,6 +91,12 @@ declare -r -A TR=( ## install.sh::Init() ## + [insane_preset-en]="The special 'READY' key was detected in the configuration file; but the configuration is incomplete. Either delete the 'READY' entry, or ensure that all of the following keys are set properly:" + [insane_preset-eo]="La speciala 'READY' ŝlosilo detektiĝis en la agorda dosiero; sed la konfiguro estas malplena. Aŭ forigu la 'READY' enigo, aŭ certigu ke ĉiuj el la sekvaj ŝlosiloj estas agordita dece:" + [insane_preset-es]="La tecla 'READY' especial se detectó en el archivo de configuración; Pero la configuración está incompleta. Elimine la entrada 'READY' o asegúrese de que todas las siguientes claves se establezcan correctamente:" + [insane_preset-gl]="Detectouse a clave 'READY' especial no ficheiro de configuración; Pero a configuración está incompleta. Elimina a entrada 'READY' ou asegúrese de que todas as seguintes teclas estean configuradas correctamente:" + [insane_preset-pt]="A tecla 'READY' especial foi detectada no arquivo de configuração; Mas a configuração está incompleta. Exclua a entrada 'READY' ou verifique se todas as seguintes teclas estão definidas corretamente:" + [dlg_preconfig-en]="Existing Configuration Found" [dlg_preconfig-eo]="Ekzistanta Konfiguro Troviĝis" [dlg_preconfig-es]="Configuración Existente Encontrada" |