From f5773eb2d7384f666c6ea33e34e92396d5fdf5e4 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:41:57 -0400 Subject: [PATCH] Remove respawn and promote skip_blockcheck 1. Remove the respawning and replace with a restart, since it never worked properly. Also add a "DONE" flag to prevent repeated triggering during cleanup. 2. Promote the skip_blockcheck to a requested configuration item and a fully-featured key in the tftp preseed file. --- templates/install.sh | 56 ++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/templates/install.sh b/templates/install.sh index e9b2eb0..45d0637 100755 --- a/templates/install.sh +++ b/templates/install.sh @@ -66,12 +66,6 @@ suppkglist="firmware-linux,firmware-linux-nonfree,firmware-bnx2,firmware-bnx2x,n # roles will overwrite it by default during configuration. root_password="hCb1y2PF" -# Respawn function -respawn() ( - echo "Respawning..." - $0 & disown -) - # Checkin function seed_checkin() ( case ${1} in @@ -189,7 +183,7 @@ interactive_config() { done )" - echo "2) Please enter the disk to install the PVC base system to. This disk will be" + echo "2a) Please enter the disk to install the PVC base system to. This disk will be" echo "wiped, an LVM PV created on it, and the system installed to this LVM." echo "* NOTE: PVC requires a disk of at least 30GB to be installed to, and 100GB is the" echo "recommended minimum size for optimal production partition sizes." @@ -220,6 +214,16 @@ interactive_config() { echo done + echo "2b) Skip disk zeroing? Only recommended for slow, low-endurance, or known-" + echo -n "zeroed block devices. [y/N] " + read skip_blockcheck + if [[ ${skip_blockcheck} == 'y' || ${skip_blockcheck} == 'Y' ]]; then + skip_blockcheck="y" + else + skip_blockcheck="" + fi + echo + for interface in $( ip address | grep '^[0-9]' | grep 'eno\|enp\|ens\|wlp' | awk '{ print $2 }' | tr -d ':' ); do ip link set ${interface} up done @@ -489,15 +493,19 @@ cleanup() { echo "done." echo - case ${install_option} in - on) - respawn - ;; - *) - # noop - true - ;; - esac + if [[ -n ${DONE} ]]; then + case ${install_option} in + on) + echo "A fatal error occurred; rebooting in 10 seconds." + sleep 10 + reboot + ;; + *) + # noop + true + ;; + esac + fi } trap cleanup EXIT @@ -525,8 +533,8 @@ vgchange -an >&2 || true echo "done." blockcheck() { - # Use for testing only - if [[ -n ${SKIP_BLOCKCHECK} ]]; then + # Skip checking if the key is set + if [[ -n ${skip_blockcheck} ]]; then return fi @@ -833,19 +841,15 @@ chroot ${target} grub-install --force --target=${bios_target} ${target_disk} >&2 chroot ${target} grub-mkconfig -o /boot/grub/grub.cfg >&2 echo "done." +DONE="y" + seed_postinst() { cleanup echo "Temporary root password: ${root_password}" seed_checkin end - echo -n "Rebooting in 10 seconds..." - i=10 - while [[ ${i} -gt 0 ]]; do - sleep 1 - i=$(( ${1} - 1 )) - echo -n "." - done - echo + echo "Rebooting in 10 seconds." + sleep 10 reboot }