all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api] debian/postinst: add old default values on upgrade to 8.x
@ 2023-06-26 13:42 Dominik Csapak
  2023-06-26 13:45 ` Dominik Csapak
  2023-06-26 20:02 ` [pmg-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2023-06-26 13:42 UTC (permalink / raw)
  To: pmg-devel

in /etc/pmg/pmg.conf for
advfilter
use_bayes
use_awl

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
we could use a little helper script, but the grep/sed lines look
harmless and easy enough to keep it here imho

 debian/postinst | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/debian/postinst b/debian/postinst
index d4d434a..6ee7a24 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -87,8 +87,37 @@ case "$1" in
             fi
         fi
 
+        # on upgrade add pre 8.0 default values for advfilter, use_awl and use_bayes
+        # TODO: remove with 9.0
         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 ! -e $pmgconf ; then
+                    # if the config does not exist at all, fill with previous default configs
+                    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 'section: admin' $pmgconf ; then
+                        printf "\nsection: admin" >> $pmgconf
+                    fi
+                    if ! grep -q 'advfilter' $pmgconf ; then
+                        sed -i '/section: admin/a\\tadvfilter 1' $pmgconf
+                    fi
+
+                    if ! grep -q 'section: spam' $pmgconf ; then
+                        printf "\nsection: spam" >> $pmgconf
+                    fi
+                    if ! grep -q 'use_bayes' $pmgconf ; then
+                        sed -i '/section: spam/a\\tuse_bayes 1' $pmgconf
+                    fi
+                    if ! grep -q 'use_awl' $pmgconf ; then
+                        sed -i '/section: spam/a\\tuse_awl 1' $pmgconf
+                    fi
+                fi
+            fi
+
             pmgconfig init || true
             pmgdb init || true
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api] debian/postinst: add old default values on upgrade to 8.x
  2023-06-26 13:42 [pmg-devel] [PATCH pmg-api] debian/postinst: add old default values on upgrade to 8.x Dominik Csapak
@ 2023-06-26 13:45 ` Dominik Csapak
  2023-06-26 20:02 ` [pmg-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2023-06-26 13:45 UTC (permalink / raw)
  To: pmg-devel

On 6/26/23 15:42, Dominik Csapak wrote:
> in /etc/pmg/pmg.conf for
> advfilter
> use_bayes
> use_awl
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> we could use a little helper script, but the grep/sed lines look
> harmless and easy enough to keep it here imho
> 
>   debian/postinst | 29 +++++++++++++++++++++++++++++
>   1 file changed, 29 insertions(+)
> 
> diff --git a/debian/postinst b/debian/postinst
> index d4d434a..6ee7a24 100644
> --- a/debian/postinst
> +++ b/debian/postinst
> @@ -87,8 +87,37 @@ case "$1" in
>               fi
>           fi
>   
> +        # on upgrade add pre 8.0 default values for advfilter, use_awl and use_bayes
> +        # TODO: remove with 9.0

meh, the comment belongs to the newly added if block below instead of here...

if wanted i can send a v2 (or i'll wait if someone has some remarks)
but if this is applied, please fix that up, thx :)


>           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 ! -e $pmgconf ; then
> +                    # if the config does not exist at all, fill with previous default configs
> +                    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 'section: admin' $pmgconf ; then
> +                        printf "\nsection: admin" >> $pmgconf
> +                    fi
> +                    if ! grep -q 'advfilter' $pmgconf ; then
> +                        sed -i '/section: admin/a\\tadvfilter 1' $pmgconf
> +                    fi
> +
> +                    if ! grep -q 'section: spam' $pmgconf ; then
> +                        printf "\nsection: spam" >> $pmgconf
> +                    fi
> +                    if ! grep -q 'use_bayes' $pmgconf ; then
> +                        sed -i '/section: spam/a\\tuse_bayes 1' $pmgconf
> +                    fi
> +                    if ! grep -q 'use_awl' $pmgconf ; then
> +                        sed -i '/section: spam/a\\tuse_awl 1' $pmgconf
> +                    fi
> +                fi
> +            fi
> +
>               pmgconfig init || true
>               pmgdb init || true
>   





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pmg-devel] applied: [PATCH pmg-api] debian/postinst: add old default values on upgrade to 8.x
  2023-06-26 13:42 [pmg-devel] [PATCH pmg-api] debian/postinst: add old default values on upgrade to 8.x Dominik Csapak
  2023-06-26 13:45 ` Dominik Csapak
@ 2023-06-26 20:02 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2023-06-26 20:02 UTC (permalink / raw)
  To: Dominik Csapak, pmg-devel

Am 26/06/2023 um 15:42 schrieb Dominik Csapak:
> in /etc/pmg/pmg.conf for
> advfilter
> use_bayes
> use_awl
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> we could use a little helper script, but the grep/sed lines look
> harmless and easy enough to keep it here imho
> 
>  debian/postinst | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
>

applied, with the comment position amended and adding lines to echo
what we try to do for transparency, like stoiko suggested, thanks to
both of you!




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-26 20:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26 13:42 [pmg-devel] [PATCH pmg-api] debian/postinst: add old default values on upgrade to 8.x Dominik Csapak
2023-06-26 13:45 ` Dominik Csapak
2023-06-26 20:02 ` [pmg-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal