diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2022-08-11 09:18:16 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2022-08-16 08:12:57 -0400 |
commit | 39a2a870c021fa0a9a7d27cbb8c0e70d86608d0d (patch) | |
tree | bc8195868d974389648d9e763ee76befeb1c9fea | |
parent | 4144972d19ae369e34b04c1245e089a06e5a0931 (diff) |
allow resume and otherwise prepared configurations
-rw-r--r-- | chroot-login.sh | 4 | ||||
-rwxr-xr-x | install.sh | 65 | ||||
-rw-r--r-- | translations.sh.inc | 12 |
3 files changed, 69 insertions, 12 deletions
diff --git a/chroot-login.sh b/chroot-login.sh index 20c3a47..f925047 100644 --- a/chroot-login.sh +++ b/chroot-login.sh @@ -44,6 +44,10 @@ GsettingsSet() # (kvp) ## main entry ## +# check for the signal to bypass user creation +[[ "$(GetStateVar 'USER_LOGIN')" != 'NONE' ]] && +[[ "$(GetStateVar 'USER_PASS' )" != 'NONE' ]] || exit 0 + # register unprivileged user Login=$(GetStateVar 'USER_LOGIN') Pass=$(openssl passwd "$(GetStateVar 'USER_PASS')") @@ -63,6 +63,14 @@ Init() { # MOCK_INIT ; return 0 ; + # 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 && + ! (( $( WizardDlg "${TR[dlg_preconfig-${Lang}]}" \ + --yesno "${TR[preconfig-${Lang}]}" 0 0 ) )) + then truncate --size=0 "${THIS_DIR}"/.session_state + fi + # sanity checks while [[ -z "$(GetStateVar 'LANG' )" || -z "$(GetStateVar 'TR_KEY' )" || @@ -105,6 +113,15 @@ SelectDefaults() # MOCK_SELECTDEFAULTS ; return 0 ; # bypass SelectBase, SelectWmde, SelectEnv # MOCK_SELECTDEFAULTS_NO ; return 0 ; # exercise SelectBase, SelectWmde, SelectEnv + # checks to skip this stage per preset or partial config + [[ -z "$(GetStateVar 'BASE' )" ]] || + [[ -z "$(GetStateVar 'INIT' )" ]] || + [[ -z "$(GetStateVar 'WMDE' )" ]] || + [[ -z "$(GetStateVar 'HOSTNAME')" ]] || + [[ -z "$(GetStateVar 'TIMEZONE')" ]] || + [[ -z "$(GetStateVar 'KEYMAP' )" ]] || + [[ -z "$(GetStateVar 'LOCALES' )" ]] || return 0 + # prompt to select the default installation configuration # (bypasses many other prompts) if (( $( WizardDlg "${TR[dlg_defaults-${Lang}]}" \ @@ -147,6 +164,11 @@ SelectLogins() { # MOCK_SELECTLOGINS ; return 0 ; + # checks to skip this stage per preset or partial config + ! ValidateId "$(GetStateVar 'ROOT_PASS' )" || + ! ValidateId "$(GetStateVar 'USER_LOGIN')" || + ! ValidateId "$(GetStateVar 'USER_PASS' )" || return 0 + # prompt for root user password local pass _SetPass "${TR[dlg_root-${Lang}]}" "${TR[root_pass-${Lang}]}" "${TR[root_pass2-${Lang}]}" @@ -156,7 +178,11 @@ SelectLogins() # prompt to create an unprivileged user login local dlg_title="${TR[dlg_user-${Lang}]}" - (( $( WizardDlg "${dlg_title}" --yesno "${TR[user-${Lang}]}" 8 56 ) )) || return 0 + if ! (( $( WizardDlg "${dlg_title}" --yesno "${TR[user-${Lang}]}" 8 56 ) )) + then SetStateVar 'USER_LOGIN' 'NONE' # signal no user creation + SetStateVar 'USER_PASS' 'NONE' # signal no user creation + return 0 + fi # prompt for unprivileged user login local login='' @@ -177,8 +203,9 @@ SelectBase() { # MOCK_SELECTBASE ; return 0 ; - # checks to skip this stage per SelectDefaults() - [[ -z "$(GetStateVar 'BASE')" || -z "$(GetStateVar 'INIT')" ]] || return 0 + # checks to skip this stage per preset config, partial config, or SelectDefaults() + [[ -z "$(GetStateVar 'BASE')" ]] || + [[ -z "$(GetStateVar 'INIT')" ]] || return 0 # prompt for local vs remote package repos, if possible local install=$( [[ "$(GetStateVar 'INSTALL')" != 'prompt' ]] && \ @@ -215,6 +242,9 @@ SelectBoot() { # MOCK_SELECTBOOT ; return 0 ; + # checks to skip this stage per preset or partial config + [[ -z "$(GetStateVar 'BOOT')" ]] || return 0 + # prompt to install GRUB (( $( WizardDlg "${TR[dlg_boot-${Lang}]}" \ --yesno "${TR[grub-${Lang}]}" 8 56 ) )) && \ @@ -226,7 +256,7 @@ SelectWmde() { # MOCK_SELECTWMDE ; return 0 ; - # checks to skip this stage per SelectDefaults() + # checks to skip this stage per preset config, partial config, or SelectDefaults() [[ -z "$(GetStateVar 'WMDE')" ]] || return 0 # prompt to install a graphical environment @@ -249,8 +279,8 @@ SelectEnv() { # MOCK_SELECTENV ; return 0 ; - # checks to skip this stage per SelectDefaults() - [[ -z "$(GetStateVar 'HOSTNAME')" || -z "$(GetStateVar 'TIMEZONE')" ]] || \ + # checks to skip this stage per preset config, partial config, or SelectDefaults() + [[ -z "$(GetStateVar 'HOSTNAME')" || -z "$(GetStateVar 'TIMEZONE')" ]] || [[ -z "$(GetStateVar 'KEYMAP' )" || -z "$(GetStateVar 'LOCALES' )" ]] || return 0 local curr_msg="${TR[option_current-${Lang}]}" @@ -351,6 +381,11 @@ SelectPartition() # prepare for partition probe umount /mnt &> /dev/null || true + # checks to skip this stage per preset config + [[ -z "$(GetStateVar 'DEVICE_N' )" ]] || + [[ -z "$(GetStateVar 'DEVICE' )" ]] || + [[ -z "$(GetStateVar 'PART_METHOD')" ]] || return 0 + # query disk device information PopulateDisksOptions # populates DlgParams (( ${#DlgParams[@]} )) || ExitFail "${TR[device_none-${Lang}]}" @@ -387,6 +422,15 @@ _PartitionAuto() # sanity checks [[ -n "$(GetStateVar 'DEVICE')" ]] + # checks to skip this stage per preset config + # NOTE: this is the only path for preset configurations + # it currently supports only a single disk (root and swap partitions) + if [[ -n "$(GetStateVar 'ROOT_PART')" ]] + then SetStateVar 'BOOT_PART' '' + SetStateVar 'HOME_PART' '' + return 0 + fi + # automatic partitioning local device=$(GetStateVar 'DEVICE') local offset_mb=1 @@ -494,13 +538,10 @@ Partition() # final validation if ! blkid ${partition} | grep ' TYPE="' &> /dev/null - then SetStateVar 'DEVICE' ; SetStateVar 'ROOT_PART' ; - SetStateVar 'DEVICE_N' ; SetStateVar 'ROOT_PART' ; + 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' ; - # TODO: allow the installer to check if all prior state-vars - # are present in .session_state; and offer to reset them - # or to resume at SelectPartition() instead. - # change 'abort-' message to indicate that possibility. ExitFail "${TR[abort-${Lang}]}" fi done diff --git a/translations.sh.inc b/translations.sh.inc index 98449e8..00268b1 100644 --- a/translations.sh.inc +++ b/translations.sh.inc @@ -91,6 +91,18 @@ declare -r -A TR=( ## install.sh::Init() ## + [dlg_preconfig-en]="Existing Configuration Found" + [dlg_preconfig-eo]="Ekzistanta Konfiguro Troviĝis" + [dlg_preconfig-es]="Configuración Existente Encontrada" + [dlg_preconfig-gl]="Configuración Existente Atopada" + [dlg_preconfig-pt]="Configuração Existente Encontrada" + + [preconfig-en]="An existing non-default configuration file has been detected. This could be a preset \"auto-install\" configuration; or it could be a continuation from a previously aborted install. Would you like continue, using the existing configuration, or reset it to the defaults, and start over?\n\nSelect \"Yes\" to continue.\nSelect \"No\" to reset." + [preconfig-eo]="Ekzistanta nedefaŭlta agorda dosiero detektiĝis. Ĉi tio eblus antaŭagorda \"aŭtomata-instalu\" konfiguro; aŭ ĝin eblus daŭrigo per antaŭe ĉesita instalado. Ĉu vi volas daŭri, per la ekzistanta konfiguro, aŭ rekomencigas ĝin laŭ la defaŭltoj?\n\nElektu \"Jes\", daŭri.\nElektu \"Ne\", rekomencigi." + [preconfig-es]="Se ha detectado un archivo de configuración no predeterminado existente. Esta podría ser una configuración preestablecida de \"autoinstalación automática\"; O podría ser una continuación de una instalación previamente abortada. ¿Le gustaría continuar, usar la configuración existente o restablecerla a los valores predeterminados y comenzar de nuevo? Seleccione \"Sí\" para continuar. Seleccione \"No\" para reiniciar." + [preconfig-gl]="Detectouse un ficheiro de configuración non predeterminado existente. Esta podería ser unha configuración de \"instalación automática\" preestablecida; Ou podería ser unha continuación dunha instalación anteriormente abortada. ¿Quere continuar, usando a configuración existente ou restablecela aos valores predeterminados e comezar de novo? Seleccione \"Si\" para continuar. Selecciona \"Non\" para restablecer." + [preconfig-pt]="Um arquivo de configuração não padrão existente foi detectado. Isso pode ser uma configuração predefinida \"instalação automática\"; ou pode ser uma continuação de uma instalação previamente abortada. Você gostaria de continuar, usando a configuração existente ou redefini -la para os padrões e começar de novo? Selecione \"Sim\" para continuar. Selecione \"Não\" para redefinir." + [online-en]="Detecting Internet connection" [online-eo]="Detktado de retkonekto" [online-es]="Detectando conexión a Internet" |