From dd243e47f8b162432c4f03d37025aadda16a7e95 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sun, 16 Dec 2018 23:50:48 -0800 Subject: [PATCH] Fix: lvm group size parsing issue --- src/archlabs-installer | 2 +- src/lib/lvm.sh | 63 ++++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/archlabs-installer b/src/archlabs-installer index 2f6a3ed..35226e3 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -10,7 +10,7 @@ # immutable globals -readonly VER="1.7.47" # Installer version +readonly VER="1.7.48" # Installer version readonly DIST="ArchLabs" # Linux distributor readonly MNT="/mnt" # Install mountpoint readonly ERR="/tmp/errlog" # Built-in error log diff --git a/src/lib/lvm.sh b/src/lib/lvm.sh index 3076503..99ecea0 100644 --- a/src/lib/lvm.sh +++ b/src/lib/lvm.sh @@ -12,6 +12,32 @@ declare -g LVM="" declare -g GROUP_PARTS="" declare -g VOL_GROUP_MB=0 +lvm_menu() +{ + lvm_detect + tput civis + + local choice + choice="$(menubox "$_PrepLVM" "$_LvmMenu" 0 0 0 \ + "$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \ + "$_LvmDelVG" "vgremove -f" \ + "$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \ + "$_Back" "-")" + + case $choice in + "$_LvmCreateVG") + lvm_create + retval=$? + [[ $retval != 1 ]] && return $retval + ;; + "$_LvmDelVG") lvm_del_vg ;; + "$_LvMDelAll") lvm_del_all ;; + *) return 0 + esac + + lvm_menu +} + lvm_detect() { PHYSICAL_VOLUMES="$(pvs -o pv_name --noheading 2>/dev/null)" @@ -213,11 +239,14 @@ lvm_create_group() vgcreate -f "$VOLUME_GROUP" "$GROUP_PARTS" >/dev/null 2>$ERR echeck "vgcreate -f $VOLUME_GROUP $GROUP_PARTS" - GROUP_SIZE=$(vgdisplay "$VOLUME_GROUP" | - awk '/VG Size/ {print int($3)}') + GROUP_SIZE=$(vgdisplay "$VOLUME_GROUP" | awk '/VG Size/ { + gsub(/[^0-9.]/, "") + print int($0) + }') - GROUP_SIZE_TYPE="$(vgdisplay "$VOLUME_GROUP" | - awk '/VG Size/ {print substr($NF, 0, 1)}')" + GROUP_SIZE_TYPE="$(vgdisplay "$VOLUME_GROUP" | awk '/VG Size/ { + print substr($NF, 0, 1) + }')" if [[ $GROUP_SIZE_TYPE == 'G' ]]; then VOL_GROUP_MB=$((GROUP_SIZE * 1000)) @@ -288,29 +317,3 @@ lvm_del_all() return 0 } - -lvm_menu() -{ - lvm_detect - tput civis - - local choice - choice="$(menubox "$_PrepLVM" "$_LvmMenu" 0 0 0 \ - "$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \ - "$_LvmDelVG" "vgremove -f" \ - "$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \ - "$_Back" "-")" - - case $choice in - "$_LvmCreateVG") - lvm_create - retval=$? - [[ $retval != 1 ]] && return $retval - ;; - "$_LvmDelVG") lvm_del_vg ;; - "$_LvMDelAll") lvm_del_all ;; - *) return 0 - esac - - lvm_menu -}