Fix bugs and improve messages

This commit is contained in:
Joshua Boniface 2023-09-01 15:41:55 -04:00
parent 73c6434f68
commit ee98ed1fe7
1 changed files with 14 additions and 5 deletions

View File

@ -47,7 +47,10 @@ while [[ -z ${target_hostname} ]]; do
done done
disks="$( disks="$(
for disk in /dev/sd?; do for disk in /dev/sd? /dev/nvme?n?; do
if [[ ! -b ${disk} ]]; then
continue
fi
disk_data="$( fdisk -l ${disk} 2>/dev/null )" disk_data="$( fdisk -l ${disk} 2>/dev/null )"
echo -n "${disk}" echo -n "${disk}"
echo -en "\t$( grep "^Disk model:" <<<"${disk_data}" | awk '{ $1=""; print $0 }' )" echo -en "\t$( grep "^Disk model:" <<<"${disk_data}" | awk '{ $1=""; print $0 }' )"
@ -78,6 +81,7 @@ while [[ ! -b ${target_disk} ]]; do
fi fi
blockdev_size="$(( $( blockdev --getsize64 ${target_disk} ) / 1024 / 1024 / 1024 - 1))" blockdev_size="$(( $( blockdev --getsize64 ${target_disk} ) / 1024 / 1024 / 1024 - 1))"
if [[ ${blockdev_size} -lt 30 ]]; then if [[ ${blockdev_size} -lt 30 ]]; then
target_disk=""
echo echo
echo "The specified disk is too small (<30 GB) to use as a PVC system disk." echo "The specified disk is too small (<30 GB) to use as a PVC system disk."
echo "Please choose an alternative disk." echo "Please choose an alternative disk."
@ -104,10 +108,15 @@ while [[ -z ${target_interface} ]]; do
echo echo
echo -n "> " echo -n "> "
read target_interface read target_interface
if ! grep -qw "${target_interface}" <<<"${interfaces[@]}"; then if [[ -z ${target_interface} ]]; then
echo echo
echo "Please enter a valid interface." echo "Please enter a valid interface."
continue
fi
if ! grep -qw "${target_interface}" <<<"${interfaces[@]}"; then
target_interface="" target_interface=""
echo
echo "Please enter a valid interface."
continue continue
fi fi
echo echo
@ -209,14 +218,14 @@ echo
echo "4a) Please enter an alternate Debian release codename for the system if desired." echo "4a) Please enter an alternate Debian release codename for the system if desired."
echo " Supported: ${supported_debrelease}" echo " Supported: ${supported_debrelease}"
echo " Default: ${default_debrelease}" echo " Default: ${default_debrelease}"
while [[ -z ${target_hostname} ]]; do while [[ -z ${debrelease} ]]; do
echo echo
echo -n "> " echo -n "> "
read debrelease read debrelease
if [[ -z ${debrelease} ]]; then if [[ -z ${debrelease} ]]; then
debrelease="${default_debrelease}" debrelease="${default_debrelease}"
fi fi
if ! grep "${debrelease}" <<<"${supported_debrelease}" if ! grep "${debrelease}" <<<"${supported_debrelease}"; then
debrelease="" debrelease=""
echo echo
echo "Please enter a valid release." echo "Please enter a valid release."
@ -234,7 +243,7 @@ while [[ -z ${debmirror} ]]; do
if [[ -z ${debmirror} ]]; then if [[ -z ${debmirror} ]]; then
debmirror="${default_debmirror}" debmirror="${default_debmirror}"
fi fi
if ! wget -O /dev/null ${debmirror}/${debrelease}/Release &>/dev/null; then if ! wget -O /dev/null ${debmirror}/dists/${debrelease}/Release &>/dev/null; then
echo echo
echo "Please enter a valid Debian mirror URL." echo "Please enter a valid Debian mirror URL."
continue continue