From 947182bc45e9f56b85e9617f158e394d5a5ce827 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Tue, 8 Oct 2024 13:34:08 +0200 Subject: [PATCH] Update watch_lvm.sh Signed-off-by: Kjeld Schouten --- .../lvm-disk-watcher/includes/watch_lvm.sh | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/containers/apps/lvm-disk-watcher/includes/watch_lvm.sh b/containers/apps/lvm-disk-watcher/includes/watch_lvm.sh index da11f3193bfd4..6fe2d62482bae 100755 --- a/containers/apps/lvm-disk-watcher/includes/watch_lvm.sh +++ b/containers/apps/lvm-disk-watcher/includes/watch_lvm.sh @@ -86,26 +86,25 @@ while true; do echo "Disk $disk has partitions. Skipping." fi done -# Check if the VG is already active -vg_active=$(vgdisplay "$VG_NAME" | grep "VG Status" | awk '{print $3}') - -if [ "$vg_active" == "available" ]; then - echo "Volume group $VG_NAME is already active." -else - echo "Activating volume group $VG_NAME..." - vgchange -ay "$VG_NAME" - if [ $? -eq 0 ]; then - echo "Volume group $VG_NAME has been activated." + + # Check if the VG is already active + vg_active=$(vgdisplay "$VG_NAME" | grep "VG Status" | awk '{print $3}') + + if [ "$vg_active" == "available" ]; then + echo "Volume group $VG_NAME is already active." else - echo "Failed to activate volume group $VG_NAME." + echo "Activating volume group $VG_NAME..." + vgchange -ay "$VG_NAME" || echo "Failed to activate volume group $VG_NAME." + if [ $? -eq 0 ]; then + echo "Volume group $VG_NAME has been activated." + fi fi -fi else echo "Configuration file not found. Exiting." exit 1 fi - + echo "sleeping 60 seconds" sleep 60 # Sleep for 1 minute before checking again done