Make sure /etc/init.d/amavis diversion is preserved.
authorValentin Vidic <Valentin.Vidic@CARNet.hr>
Tue, 22 Jul 2008 09:54:59 +0000 (11:54 +0200)
committerValentin Vidic <Valentin.Vidic@CARNet.hr>
Tue, 22 Jul 2008 09:54:59 +0000 (11:54 +0200)
src/functions.sh

index 56d8a9e..0ddd941 100644 (file)
@@ -678,10 +678,12 @@ upgrade_apache2 () {
 upgrade_amavis () {
   local conf
 
-  # remove init script diversion
-  if [ -L /etc/init.d/amavis -a -f /etc/init.d/amavis.amavisd-new ]; then
-    rm -vf /etc/init.d/amavis
-    dpkg-divert --quiet --remove /etc/init.d/amavis
+  # remove init script diversion before upgrade
+  if pkg amavisd-cn lt 3:2.4.2-4; then 
+    if [ -L /etc/init.d/amavis -a -f /etc/init.d/amavis.amavisd-new ]; then
+      rm -vf /etc/init.d/amavis
+      dpkg-divert --remove /etc/init.d/amavis
+    fi
   fi
 
   # move old config aside
@@ -699,6 +701,11 @@ upgrade_amavis () {
                 's/^\(clamd.*\)5.clamav.log$/\14\tsocket/g' \
                 /etc/init.d/amavisd-cn || true
 
+  # check if link got lost
+  if pkg amavisd-cn && [ ! -L /etc/init.d/amavis ]; then
+    apt-get install --reinstall --yes amavisd-cn
+  fi
+
   # start new packages
   /etc/init.d/amavis restart
 }