]> git.proxmox.com Git - pmg-api.git/blob - debian/postinst
buildsys: wrap-and-sort
[pmg-api.git] / debian / postinst
1 #!/bin/sh
2
3 set -e
4
5
6 ucf_register_templates() {
7 for template in /etc/pmg/templates/*; do
8 [ -e "$template" ] || continue;
9 template_base=$(basename "${template}")
10 if echo "${template_base}" | grep -q '\.ucf-'; then
11 continue
12 fi
13 if [ -e "/var/lib/pmg/templates/${template_base}" ]; then
14 ucf "/var/lib/pmg/templates/${template_base}" "${template}"
15 ucfr pmg-api "${template}"
16 else
17 echo "template '${template}' not shipped by pmg-api."
18 fi
19 done
20 }
21
22 case "$1" in
23 triggered)
24
25 test -e /proxmox_install_mode && exit 0;
26
27 # Note: reload-or-try-restart fails if service is not active
28 for service in pmgdaemon pmgproxy pmg-smtp-filter pmgpolicy pmgtunnel pmgmirror; do
29 if systemctl --quiet is-active $service.service ; then
30 deb-systemd-invoke reload-or-try-restart $service.service >/dev/null || true
31 fi
32 done
33
34 exit 0
35 ;;
36
37 configure)
38
39 if test ! -e /proxmox_install_mode ; then
40
41 pmgconfig init
42 pmgdb init
43
44 ucf_register_templates
45 pmgconfig sync --restart
46
47 if [ -z "$2" ]; then
48 if systemctl --quiet is-active pmgpolicy.service ; then
49 deb-systemd-invoke reload-or-try-restart postgresql.service >/dev/null || true
50 fi
51 deb-systemd-invoke restart postfix.service >/dev/null || true
52 fi
53
54 pmgdb update >/dev/null 2>&1 &
55
56 update-mime-database /usr/share/mime
57
58 else
59 # rewrite banner
60 pmgbanner || true
61 fi
62 ;;
63
64 abort-upgrade)
65 ucf_register_templates
66 ;;
67
68 abort-remove|abort-deconfigure)
69 ;;
70
71 *)
72 echo "postinst called with unknown argument \`$1'" >&2
73 exit 1
74 ;;
75 esac
76
77 # dh_installdeb will replace this with shell code automatically
78 # generated by other debhelper scripts.
79
80 #DEBHELPER#
81
82 if test ! -e /proxmox_install_mode ; then
83 for service in pmgdaemon pmgproxy; do
84 if [ -n "$2" ]; then
85 # Note: reload-or-try-restart fails if service is not active
86 if systemctl --quiet is-active $service.service ; then
87 deb-systemd-invoke reload-or-try-restart $service.service >/dev/null || true
88 fi
89 else
90 deb-systemd-invoke start $service.service > /dev/null || true
91 fi
92 done
93 fi
94
95 exit 0