]> git.proxmox.com Git - pmg-api.git/blobdiff - debian/postinst
Add logrotate config for pmgproxy.log
[pmg-api.git] / debian / postinst
index 98f009527699cbbf083988e5f136b1f8216990a5..d3b17cf770c7de3cfd3c902b6e37343c06a5e5ac 100644 (file)
@@ -3,53 +3,68 @@
 set -e
 
 
+ucf_register_templates() {
+    for template in /etc/pmg/templates/*; do
+       template_base=$(basename "${template}")
+       if echo "${template_base}" | grep -q '\.ucf-'; then
+               continue
+       fi
+       if [ -e "/var/lib/pmg/templates/${template_base}" ]; then
+           ucf "/var/lib/pmg/templates/${template_base}" "${template}"
+           ucfr pmg-api "${template}"
+       else
+           echo "template '${template}' not shipped by pmg-api."
+       fi
+    done
+}
+
 case "$1" in
     triggered)
 
        test -e /proxmox_install_mode && exit 0;
 
        # Note: reload-or-try-restart fails if service is not active
-       if systemctl --quiet is-active pmgdaemon.service ; then
-           deb-systemd-invoke reload-or-try-restart pmgdaemon.service
-       fi
-
-       if systemctl --quiet is-active pmgproxy.service ; then
-           deb-systemd-invoke reload-or-try-restart pmgproxy.service
-       fi
-
-       if systemctl --quiet is-active pmg-smtp-filter.service ; then
-           deb-systemd-invoke reload-or-try-restart pmg-smtp-filter.service
-       fi
-
-       if systemctl --quiet is-active pmgpolicy.service ; then
-           deb-systemd-invoke reload-or-try-restart pmgpolicy.service
-       fi
+       for service in pmgdaemon pmgproxy pmg-smtp-filter pmgpolicy pmgtunnel pmgmirror; do
+           if systemctl --quiet is-active $service.service ; then
+               deb-systemd-invoke reload-or-try-restart $service.service >/dev/null || true
+           fi
+       done
 
        exit 0
     ;;
 
     configure)
 
-       test -e /proxmox_install_mode && exit 0;
+       if test ! -e /proxmox_install_mode ; then
 
-       pmgconfig init
+           pmgconfig init
+           pmgdb init
 
-       if [ -n "$2" ]; then
-           pmgconfig sync
-       else
-           if systemctl --quiet is-active pmgpolicy.service ; then
-               deb-systemd-invoke reload-or-try-restart postgres.service
-           fi
+           ucf_register_templates
            pmgconfig sync --restart
-       fi
 
-       pmgdb init
-       pmgdb update  >/dev/null 2>&1 &
+           if [ -z "$2" ]; then
+               if systemctl --quiet is-active pmgpolicy.service ; then
+                   deb-systemd-invoke reload-or-try-restart postgresql.service >/dev/null || true
+               fi
+               deb-systemd-invoke restart postfix.service >/dev/null || true
+           fi
+
+           pmgdb update  >/dev/null 2>&1 &
+
+           update-mime-database /usr/share/mime
+
+       else
+           # rewrite banner
+           pmgbanner || true
+       fi
+    ;;
 
-       update-mime-database /usr/share/mime
+    abort-upgrade)
+       ucf_register_templates
     ;;
 
-    abort-upgrade|abort-remove|abort-deconfigure)
+    abort-remove|abort-deconfigure)
     ;;
 
     *)
@@ -63,4 +78,17 @@ esac
 
 #DEBHELPER#
 
+if test ! -e /proxmox_install_mode ; then
+    for service in pmgdaemon pmgproxy; do
+       if [ -n "$2" ]; then
+           # Note: reload-or-try-restart fails if service is not active
+           if systemctl --quiet is-active $service.service ; then
+               deb-systemd-invoke reload-or-try-restart $service.service >/dev/null || true
+           fi
+       else
+           deb-systemd-invoke start $service.service > /dev/null || true
+       fi
+    done
+fi
+
 exit 0