From 30304306b0cc40ade234470b56daa262d4252123 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 28 Oct 2022 09:40:29 +0200 Subject: d/postinst: Don't fail in container without apt Closes: #1020895 --- debian/postinst | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/debian/postinst b/debian/postinst index 8a56265..cc9b9dd 100644 --- a/debian/postinst +++ b/debian/postinst @@ -12,10 +12,17 @@ case "$1" in db_get whatmaps/enable_service_restarts || true DBVAL="$RET" - # Configuration file doesn't exist but user wants updates enabled so - # recreate it: - if [ ! -f $APT_CONF ] && [ $DBVAL = "true" ]; then - cat << EOF > $APT_CONF + if [ -f $APT_CONF ]; then + case $DBVAL in + "true") VAL=1;; + *) VAL=0;; + esac + sed -i -e "s,^\(\s*Whatmaps::Enable-Restart\s\+\"\)\S\+\(\"\s*;\),\1${VAL}\2," $APT_CONF + else + # Configuration file doesn't exist but user wants updates enabled so + # recreate it: + if [ $DBVAL = "true" ]; then + cat << EOF > $APT_CONF // Set to 1 or true to enable service restarts on security updates Whatmaps::Enable-Restart "1"; @@ -25,12 +32,7 @@ Whatmaps::Security-Update-Origins { "\${distro_id} \${distro_codename}-security"; }; EOF - else - case $DBVAL in - "true") VAL=1;; - *) VAL=0;; - esac - sed -i -e "s,^\(\s*Whatmaps::Enable-Restart\s\+\"\)\S\+\(\"\s*;\),\1${VAL}\2," $APT_CONF + fi fi ;; abort-upgrade|abort-remove|abort-deconfigure) -- cgit v1.2.3