ucf(1) is a utility to track changes in config files which are not shipped in
the debian package (but e.g. get generated through the postinst script)
While the template overriding mechanism of PMG does not directly write those
config files - users who override a config-file currently need to manually
compare the templates shipped in '/var/lib/pmg/templates' on every upgrade.
By selectively registering the existing template overrides with ucf, users get
asked once upon the next upgrade regarding their changes, and then will
always get prompted when the shipped default template changes.
The alternative of unconditionally registering all templates with ucf, as done
by dh_ucf (1), would copy all templates to /etc/pmg/templates, which I deemed
less elegant.
The postrm script's check for the existance of 'ucf' only should be sufficient,
since the other ucf executables used ('ucfq' and 'ucfr' are all shipped with
the 'ucf' package)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
[ dropped some extra lines left over from v1 ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+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
+}
+
pmgconfig init
pmgdb init
pmgconfig init
pmgdb init
+
+ ucf_register_templates
pmgconfig sync --restart
if [ -z "$2" ]; then
pmgconfig sync --restart
if [ -z "$2" ]; then
pmgdb update >/dev/null 2>&1 &
update-mime-database /usr/share/mime
pmgdb update >/dev/null 2>&1 &
update-mime-database /usr/share/mime
else
# rewrite banner
pmgbanner || true
fi
;;
else
# rewrite banner
pmgbanner || true
fi
;;
- abort-upgrade|abort-remove|abort-deconfigure)
+ abort-upgrade)
+ ucf_register_templates
+ ;;
+
+ abort-remove|abort-deconfigure)
--- /dev/null
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "purge" ] && command -v ucf >/dev/null 2>&1; then
+
+ ucfq -w pmg-api | cut -d : -f 1 | while read -r cfile ; do
+ ucfr pmg-api --purge "$cfile"
+ ucf --purge "$cfile"
+ for ext in .ucf-new .ucf-old .ucf-dist ""; do
+ rm -f "${cfile}${ext}"
+ done
+ done
+fi
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#