From fd9ad6bdf603cc1e920944bb815e493e2c26c364 Mon Sep 17 00:00:00 2001 From: nemo Date: Sun, 8 Sep 2019 15:13:30 +0200 Subject: [PATCH] Add support of unknown default VG and default root LV names (use find and awk instead) --- deploy_vm.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/deploy_vm.sh b/deploy_vm.sh index 01a584c..9daaf52 100755 --- a/deploy_vm.sh +++ b/deploy_vm.sh @@ -442,9 +442,16 @@ if [ "${VM_DISK_EXTEND}" -ne 0 ]; then exit 1 fi - echo "INFO : Add new PV to VG default_vg... (vgextend default_vg /dev/vda3)" + DEFAULT_VG=$(vgs | awk '/vg/ {print $1}') - ssh ${SSH_OPT} ${SSH_HOST} "vgextend default_vg /dev/vda3" &> /dev/null + if [ $? -ne 0 ]; then + echo 'ERROR : problem during get the name of the default VG' + exit 1 + fi + + echo "INFO : Add new PV to VG ${DEFAULT_VG}... (vgextend ${DEFAULT_VG} /dev/vda3)" + + ssh ${SSH_OPT} ${SSH_HOST} "vgextend ${DEFAULT_VG} /dev/vda3" &> /dev/null if [ $? -ne 0 ]; then echo 'ERROR : problem during add new PV in VG, please finish manually the deploy OR delete VM and IPAM information' @@ -452,8 +459,15 @@ if [ "${VM_DISK_EXTEND}" -ne 0 ]; then fi echo "INFO : Resize LV on disk... (RESIZE VM LV)" + + DEFAULT_LV_ROOT=$(find /dev/mapper -name '*root*') - ssh ${SSH_OPT} ${SSH_HOST} "lvextend -l +100%FREE /dev/mapper/default_vg-root_1" &> /dev/null + if [ $? -ne 0 ]; then + echo 'ERROR : problem during get the name of the default root LV' + exit 1 + fi + + ssh ${SSH_OPT} ${SSH_HOST} "lvextend -l +100%FREE ${DEFAULT_LV_ROOT}" &> /dev/null if [ $? -ne 0 ]; then echo 'ERROR : problem during resizing LV, please finish manually the deploy OR delete VM and IPAM information' @@ -462,7 +476,7 @@ if [ "${VM_DISK_EXTEND}" -ne 0 ]; then echo "INFO : resize2fs the LV... (RESIZE VM LV FS)" - ssh ${SSH_OPT} ${SSH_HOST} "resize2fs /dev/mapper/default_vg-root_1" &> /dev/null + ssh ${SSH_OPT} ${SSH_HOST} "resize2fs ${DEFAULT_LV_ROOT}" &> /dev/null if [ $? -ne 0 ]; then echo 'ERROR : problem during resize2fs, please finish manually the deploy OR delete VM and IPAM information'