set -e
-
ucf_register_templates() {
for template in /etc/pmg/templates/*; do
- [ -e "$template" ] || continue;
- 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
+ [ -e "$template" ] || continue;
+ 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
}
match=0
while read -r l; do
- if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pmg"; then
- match=1
- elif echo "$l" | grep -q "machine"; then
- match=0
- fi
-
- if test "$match" = "1"; then
- removed="$removed\n$l"
- else
- output="$output\n$l"
- fi
+ if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pmg"; then
+ match=1
+ elif echo "$l" | grep -q "machine"; then
+ match=0
+ fi
+
+ if test "$match" = "1"; then
+ removed="$removed\n$l"
+ else
+ output="$output\n$l"
+ fi
done < /etc/apt/auth.conf
if test -n "$removed"; then
- if test ! -e /etc/apt/auth.conf.d/pmg.conf; then
- echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pmg.conf .."
- echo "$removed" > /etc/apt/auth.conf.d/pmg.conf
- else
- echo "Removing stale APT auth config from /etc/apt/auth.conf"
- fi
- echo "$output" > /etc/apt/auth.conf
+ if test ! -e /etc/apt/auth.conf.d/pmg.conf; then
+ echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pmg.conf .."
+ echo "$removed" > /etc/apt/auth.conf.d/pmg.conf
+ else
+ echo "Removing stale APT auth config from /etc/apt/auth.conf"
+ fi
+ echo "$output" > /etc/apt/auth.conf
fi
}
case "$1" in
triggered)
- test -e /proxmox_install_mode && exit 0;
+ test -e /proxmox_install_mode && exit 0;
- # Note: reload-or-try-restart fails if service is not active
- 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
+ # Note: reload-or-try-restart fails if service is not active
+ 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
+ exit 0
;;
configure)
- # FIXME: remove in PMG 8.0
- if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.0-2~'; then
- # PMG 5 ISOs had a bug and did not generated a unique machine-id. below is a list of
- # all machine-ids from all ISOs (released, tests & internal) possibly affected
- if grep -q \
- -e e378bde63ac54872a85af23a8e4dac73 \
- -e 932b668d1fad4709b4976d54152d223c \
- -e 931a8410cd034202a26b0e19d56e157a \
- -e 9a1f3c5284e1423c9b0e0ee5819db6c9 \
- -e 5472a49c6436426fbebd7881f7b7f13b \
- /etc/machine-id
- then
- echo "found static machine-id bug from Proxmox Mail Gateway ISO installer <= 5.4, regenerating machine-id"
- systemd-id128 new | tee /etc/machine-id.new /var/lib/dbus/machine-id.new
- # atomically replace
- mv /etc/machine-id.new /etc/machine-id
- mv /var/lib/dbus/machine-id.new /var/lib/dbus/machine-id
- echo "new machine-id generated, a reboot is recommended"
- else
- echo "machine-id check OK"
- fi
- fi
-
- if test ! -e /proxmox_install_mode ; then
-
- pmgconfig init
- pmgdb init
-
- ucf_register_templates
- pmgconfig sync --restart
-
- 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
-
- if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.1-7~'; then
- if test -e /etc/apt/auth.conf ; then
- migrate_apt_auth_conf
- fi
- fi
+ # FIXME: remove in PMG 8.0
+ if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.0-2~'; then
+ # PMG 5 ISOs had a bug and did not generated a unique machine-id. below is a list of
+ # all machine-ids from all ISOs (released, tests & internal) possibly affected
+ if grep -q \
+ -e e378bde63ac54872a85af23a8e4dac73 \
+ -e 932b668d1fad4709b4976d54152d223c \
+ -e 931a8410cd034202a26b0e19d56e157a \
+ -e 9a1f3c5284e1423c9b0e0ee5819db6c9 \
+ -e 5472a49c6436426fbebd7881f7b7f13b \
+ /etc/machine-id
+ then
+ echo "found static machine-id bug from Proxmox Mail Gateway ISO installer <= 5.4, regenerating machine-id"
+ systemd-id128 new | tee /etc/machine-id.new /var/lib/dbus/machine-id.new
+ # atomically replace
+ mv /etc/machine-id.new /etc/machine-id
+ mv /var/lib/dbus/machine-id.new /var/lib/dbus/machine-id
+ echo "new machine-id generated, a reboot is recommended"
+ else
+ echo "machine-id check OK"
+ fi
+ fi
+
+ if test ! -e /proxmox_install_mode ; then
+
+ pmgconfig init
+ pmgdb init
+
+ ucf_register_templates
+ pmgconfig sync --restart
+
+ 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
+
+ if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.1-7~'; then
+ if test -e /etc/apt/auth.conf ; then
+ migrate_apt_auth_conf
+ fi
+ fi
;;
abort-upgrade)
- ucf_register_templates
+ ucf_register_templates
;;
abort-remove|abort-deconfigure)
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
+ 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