5 ucf_register_templates
() {
6 for template
in /etc
/pmg
/templates
/*; do
7 [ -e "$template" ] ||
continue;
8 template_base
=$
(basename "${template}")
9 if echo "${template_base}" |
grep -q '\.ucf-'; then
12 if [ -e "/var/lib/pmg/templates/${template_base}" ]; then
13 ucf
"/var/lib/pmg/templates/${template_base}" "${template}"
14 ucfr pmg-api
"${template}"
16 echo "template '${template}' not shipped by pmg-api."
21 migrate_apt_auth_conf
() {
27 if echo "$l" |
grep -q "^machine enterprise.proxmox.com/debian/pmg"; then
29 elif echo "$l" |
grep -q "machine"; then
33 if test "$match" = "1"; then
34 removed
="$removed\n$l"
38 done < /etc
/apt
/auth.conf
40 if test -n "$removed"; then
41 if test ! -e /etc
/apt
/auth.conf.d
/pmg.conf
; then
42 echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pmg.conf .."
43 echo "$removed" > /etc
/apt
/auth.conf.d
/pmg.conf
45 echo "Removing stale APT auth config from /etc/apt/auth.conf"
47 echo "$output" > /etc
/apt
/auth.conf
54 test -e /proxmox_install_mode
&& exit 0;
56 # Note: reload-or-try-restart fails if service is not active
57 for service
in pmgdaemon pmgproxy pmg-smtp-filter pmgpolicy pmgtunnel pmgmirror
; do
58 if systemctl
--quiet is-active
$service.service
; then
59 deb-systemd-invoke reload-or-try-restart
$service.service
>/dev
/null || true
68 if test ! -e /proxmox_install_mode
; then
70 pmgconf
="/etc/pmg/pmg.conf"
71 if test -n "$2" && dpkg
--compare-versions "$2" 'lt' '8.0.2'; then
72 # on upgrade add pre 8.0 default values for advfilter, use_awl and use_bayes
73 # TODO: remove with 9.0
74 if test ! -e $pmgconf ; then
75 # if the config does not exist at all, fill with previous default configs
76 printf "section: admin\n\tadvfilter 1\n" > $pmgconf
77 printf "\nsection: spam\n\tuse_bayes 1\n\tuse_awl 1\n" >> $pmgconf
79 if ! grep -qP '\s+advfilter' $pmgconf ; then
80 echo "hard-code old default for 'advfilter'"
81 if ! grep -q '^section: admin$' $pmgconf ; then
82 printf "\nsection: admin" >> $pmgconf
84 sed -i '/^section: admin$/a\\tadvfilter 1' $pmgconf
87 if ! grep -q '^section: spam$' $pmgconf ; then
88 printf "\nsection: spam" >> $pmgconf
90 if ! grep -qP '^\s+use_bayes\s' $pmgconf ; then
91 echo "hard-code old default for 'use_bayes'"
92 sed -i '/^section: spam$/a\\tuse_bayes 1' $pmgconf
94 if ! grep -qP '^\s+use_awl\s' $pmgconf ; then
95 echo "hard-code old default for 'use_awl'"
96 sed -i '/^section: spam$/a\\tuse_awl 1' $pmgconf
101 pmgconfig init || true
104 ucf_register_templates
105 pmgconfig sync
--restart || true
108 if systemctl
--quiet is-active pmgpolicy.service
; then
109 deb-systemd-invoke reload-or-try-restart postgresql.service
>/dev
/null || true
111 deb-systemd-invoke restart postfix.service
>/dev
/null || true
114 pmgdb update
>/dev
/null
2>&1 &
116 update-mime-database
/usr
/share
/mime
123 if test ! -e /proxmox_install_mode
&& test -n "$2" && dpkg
--compare-versions "$2" 'lt' '7.1-7~'; then
124 if test -e /etc
/apt
/auth.conf
; then
125 migrate_apt_auth_conf
131 ucf_register_templates
134 abort-remove|abort-deconfigure
)
138 echo "postinst called with unknown argument \`$1'" >&2
143 # dh_installdeb will replace this with shell code automatically
144 # generated by other debhelper scripts.
148 if test ! -e /proxmox_install_mode
; then
149 for service
in pmgdaemon pmgproxy
; do
151 # Note: reload-or-try-restart fails if service is not active
152 if systemctl
--quiet is-active
$service.service
; then
153 deb-systemd-invoke reload-or-try-restart
$service.service
>/dev
/null || true
156 deb-systemd-invoke start
$service.service
> /dev
/null || true