]> git.proxmox.com Git - pmg-api.git/commitdiff
d/postinst: better anchor matches for section & property detection
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 28 Jun 2023 06:36:18 +0000 (08:36 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 28 Jun 2023 09:23:50 +0000 (11:23 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
debian/postinst

index 6bc4a8c72933a04841dbc76a0151d96cfddba60e..770c944d434a33f353017e68bda304a6305e9f9c 100644 (file)
@@ -68,7 +68,7 @@ case "$1" in
         if test ! -e /proxmox_install_mode ; then
 
             pmgconf="/etc/pmg/pmg.conf"
-            if test -n "$2" && dpkg --compare-versions "$2" 'lt' '8.0.0'; then
+            if test -n "$2" && dpkg --compare-versions "$2" 'lt' '8.0.2'; then
                 # on upgrade add pre 8.0 default values for advfilter, use_awl and use_bayes
                 # TODO: remove with 9.0
                 if test ! -e $pmgconf ; then
@@ -76,24 +76,24 @@ case "$1" in
                     printf "section: admin\n\tadvfilter 1\n" > $pmgconf
                     printf "\nsection: spam\n\tuse_bayes 1\n\tuse_awl 1\n" >> $pmgconf
                 else
-                    if ! grep -q 'advfilter' $pmgconf ; then
+                    if ! grep -qP '\s+advfilter' $pmgconf ; then
                         echo "hard-code old default for 'advfilter'"
-                        if ! grep -q 'section: admin' $pmgconf ; then
+                        if ! grep -q '^section: admin$' $pmgconf ; then
                             printf "\nsection: admin" >> $pmgconf
                         fi
-                        sed -i '/section: admin/a\\tadvfilter 1' $pmgconf
+                        sed -i '/^section: admin$/a\\tadvfilter 1' $pmgconf
                     fi
 
-                    if ! grep -q 'section: spam' $pmgconf ; then
+                    if ! grep -q '^section: spam$' $pmgconf ; then
                         printf "\nsection: spam" >> $pmgconf
                     fi
-                    if ! grep -q 'use_bayes' $pmgconf ; then
+                    if ! grep -qP '^\s+use_bayes\s' $pmgconf ; then
                         echo "hard-code old default for 'use_bayes'"
-                        sed -i '/section: spam/a\\tuse_bayes 1' $pmgconf
+                        sed -i '/^section: spam$/a\\tuse_bayes 1' $pmgconf
                     fi
-                    if ! grep -q 'use_awl' $pmgconf ; then
+                    if ! grep -qP '^\s+use_awl\s' $pmgconf ; then
                         echo "hard-code old default for 'use_awl'"
-                        sed -i '/section: spam/a\\tuse_awl 1' $pmgconf
+                        sed -i '/^section: spam$/a\\tuse_awl 1' $pmgconf
                     fi
                 fi
             fi