From f8f3f4b98091bdfd99d5856c1ec10ee92a33e526 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 4 Dec 2016 02:46:32 +0100 Subject: Adding debconf handling for irc notifications. Signed-off-by: Daniel Baumann --- .../open-infrastructure-container-tools.postinst | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'debian/open-infrastructure-container-tools.postinst') diff --git a/debian/open-infrastructure-container-tools.postinst b/debian/open-infrastructure-container-tools.postinst index 3ba287e..4273247 100755 --- a/debian/open-infrastructure-container-tools.postinst +++ b/debian/open-infrastructure-container-tools.postinst @@ -2,6 +2,8 @@ set -e +CONFFILE="/etc/default/container-tools" + Install () { DEFAULT="${1}" @@ -60,6 +62,9 @@ case "${1}" in db_get open-infrastructure-container-tools/script SCRIPT="${RET:-debian}" # string (w/o empty) + db_get open-infrastructure-container-tools/irc + IRK_TARGETS="${RET}" # string (w/ empty) + db_stop Install "/var/lib/machines" "${MACHINES}" @@ -68,6 +73,31 @@ case "${1}" in Install "/var/cache/container-tools" "${CACHE}" update-alternatives --quiet --set container-tools_script "/usr/share/container-tools/scripts/${SCRIPT}" + + if [ ! -e "${CONFFILE}" ] + then + +cat > "${CONFFILE}" << EOF +# /etc/default/container-tools + +IRK_TARGETS="${IRK_TARGETS}" +EOF + + fi + + cp -a -f "${CONFFILE}" "${CONFFILE}.tmp" + + # If the admin deleted or commented some variables but then set + # them via debconf, (re-)add them to the config file. + + test -z "${IRK_TARGETS}" || \ + grep -Eq '^ *IRK_TARGETS=' "${CONFFILE}" || \ + echo "IRK_TARGETS=" >> "${CONFFILE}" + + sed -e "s|^ *IRK_TARGETS=.*|IRK_TARGETS=\"${IRK_TARGETS}\"|" \ + < "${CONFFILE}" > "${CONFFILE}.tmp" + + mv -f "${CONFFILE}.tmp" "${CONFFILE}" ;; abort-upgrade|abort-remove|abort-deconfigure) -- cgit v1.2.3