]> git.proxmox.com Git - pve-manager.git/commitdiff
d/postinst: set_lvm_conf: early return to avoid indentation level
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Sep 2022 08:48:53 +0000 (10:48 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Sep 2022 08:48:53 +0000 (10:48 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
debian/postinst

index 596814bbb87c7559aba982b693edca435571c78d..7980ef98b5e23651eff83c7bbec61c24efd345d6 100755 (executable)
@@ -11,54 +11,55 @@ set -e
 set_lvm_conf() {
     LVM_CONF_MARKER="# added by pve-manager to avoid scanning"
 
-    # only do these changes once
     # keep user changes afterwards provided marker is still there..
-    if grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then
-        OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)"
-        NEW_VALUE='global_filter=["r|/dev/zd.*|"]'
+    if grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then
+        return 0 # only do these changes once
+    fi
 
-        export LVM_SUPPRESS_FD_WARNINGS=1
+    OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)"
+    NEW_VALUE='global_filter=["r|/dev/zd.*|"]'
 
-        # check global_filter
-        # keep previous setting from our custom packaging if it is still there
-        if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then
-            SET_FILTER=1
-            BACKUP=1
-        fi
-        # should be the default since bullseye
-        if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then
-            SET_SCAN_LVS=1
-            BACKUP=1
-        fi
-        if test -n "$BACKUP"; then
-            echo "Backing up lvm.conf before setting pve-manager specific settings.."
-            cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak
-        fi
-        if test -n "$SET_FILTER"; then
-            echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:"
-            echo "$OLD_VALUE => $NEW_VALUE"
-            # comment out existing setting
-            sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
-            # add new section with our setting
-            cat >> /etc/lvm/lvm.conf <<EOF
+    export LVM_SUPPRESS_FD_WARNINGS=1
+
+    # check global_filter
+    # keep previous setting from our custom packaging if it is still there
+    if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then
+        SET_FILTER=1
+        BACKUP=1
+    fi
+    # should be the default since bullseye
+    if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then
+        SET_SCAN_LVS=1
+        BACKUP=1
+    fi
+    if test -n "$BACKUP"; then
+        echo "Backing up lvm.conf before setting pve-manager specific settings.."
+        cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak
+    fi
+    if test -n "$SET_FILTER"; then
+        echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:"
+        echo "$OLD_VALUE => $NEW_VALUE"
+        # comment out existing setting
+        sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
+        # add new section with our setting
+        cat >> /etc/lvm/lvm.conf <<EOF
 devices {
      $LVM_CONF_MARKER ZFS zvols
      $NEW_VALUE
  }
 EOF
-        fi
-        if test -n "$SET_SCAN_LVS"; then
-            echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned."
-            # comment out existing setting
-            sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
-            # add new section with our setting
-            cat >> /etc/lvm/lvm.conf <<EOF
+    fi
+    if test -n "$SET_SCAN_LVS"; then
+        echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned."
+        # comment out existing setting
+        sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
+        # add new section with our setting
+        cat >> /etc/lvm/lvm.conf <<EOF
 devices {
      $LVM_CONF_MARKER LVM volumes
      scan_lvs=0
  }
 EOF
-        fi
     fi
 }