[pkg-bacula-commits] [bacula] 01/01: Handle the main configuration files with ucf, addresses part of #880529

Carsten Leonhardt leo at moszumanska.debian.org
Wed Nov 1 22:53:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

leo pushed a commit to branch master
in repository bacula.

commit b9bf0857e3b6ec1d4fc12d744e89eab47e9cc9ff
Author: Carsten Leonhardt <leo at debian.org>
Date:   Wed Nov 1 23:52:49 2017 +0100

    Handle the main configuration files with ucf, addresses part of #880529
---
 debian/bacula-console-qt.autopostrm |  2 +-
 debian/bacula-console-qt.postinst   | 29 +++++++------
 debian/bacula-console.autopostrm    |  2 +-
 debian/bacula-console.postinst      | 29 +++++++------
 debian/bacula-director.autopostrm   |  3 +-
 debian/bacula-director.postinst     | 85 +++++++++++++++++++------------------
 debian/bacula-fd.autopostrm         |  3 +-
 debian/bacula-fd.postinst           | 34 ++++++++-------
 debian/bacula-sd.autopostrm         |  3 +-
 debian/bacula-sd.postinst           | 40 ++++++++++-------
 debian/changelog                    |  6 +++
 11 files changed, 132 insertions(+), 104 deletions(-)

diff --git a/debian/bacula-console-qt.autopostrm b/debian/bacula-console-qt.autopostrm
index 134ffec..5e011d5 100644
--- a/debian/bacula-console-qt.autopostrm
+++ b/debian/bacula-console-qt.autopostrm
@@ -1,2 +1,2 @@
 # this file is handled by debian/scripts/autopostrm
-CONFFILES=/etc/bacula/bat.conf
+UCF_CONFFILES=/etc/bacula/bat.conf
diff --git a/debian/bacula-console-qt.postinst b/debian/bacula-console-qt.postinst
index 7cf00ba..1f48094 100644
--- a/debian/bacula-console-qt.postinst
+++ b/debian/bacula-console-qt.postinst
@@ -2,22 +2,27 @@
 
 set -e
 
-SRCDIR="/usr/share/bacula-common/defconfig"
-DSTDIR="/etc/bacula"
+PKG_NAME="bacula-console-qt"
 CONFIG="bat.conf"
-TARGET=$DSTDIR/$CONFIG
-
-. /usr/share/bacula-common/common-functions.dpkg
-readOrCreatePasswords
+TEMPLATE="/usr/share/bacula-common/defconfig/$CONFIG"
+TARGET="/etc/bacula/$CONFIG"
 
 case "$1" in
     configure)
-	if [ ! -f $TARGET ]; then
-	    install -m 640 -o root -g bacula $SRCDIR/$CONFIG $TARGET
-	    sed -e s~@debian_hostname@~`hostname`~ \
-		-e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
-		-i $TARGET
-	fi
+	. /usr/share/bacula-common/common-functions.dpkg
+	readOrCreatePasswords
+
+	# create new bacula-fd.conf using the template
+	TMP_CONFIG="$(mktemp $PKG_NAME.conf.ucftmp-XXXXXXXXXX)"
+	chmod 640 $TMP_CONFIG
+	chown root.bacula $TMP_CONFIG
+
+	sed -e s~@debian_hostname@~`hostname`~ \
+	    -e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
+	    $TEMPLATE > $TMP_CONFIG
+	# let ucf handle the conffile and register it
+	ucf --debconf-ok --three-way $TMP_CONFIG $TARGET
+	ucfr $PKG_NAME $TARGET
     ;;
 esac
 
diff --git a/debian/bacula-console.autopostrm b/debian/bacula-console.autopostrm
index 6c21458..1e80395 100644
--- a/debian/bacula-console.autopostrm
+++ b/debian/bacula-console.autopostrm
@@ -1,2 +1,2 @@
 # this file is handled by debian/scripts/autopostrm
-CONFFILES=/etc/bacula/bconsole.conf
+UCF_CONFFILES=/etc/bacula/bconsole.conf
diff --git a/debian/bacula-console.postinst b/debian/bacula-console.postinst
index 4a3e10e..e5f99e5 100644
--- a/debian/bacula-console.postinst
+++ b/debian/bacula-console.postinst
@@ -2,22 +2,27 @@
 
 set -e
 
-SRCDIR="/usr/share/bacula-common/defconfig"
-DSTDIR="/etc/bacula"
+PKG_NAME="bacula-console"
 CONFIG="bconsole.conf"
-TARGET=$DSTDIR/$CONFIG
-
-. /usr/share/bacula-common/common-functions.dpkg
-readOrCreatePasswords
+TEMPLATE="/usr/share/bacula-common/defconfig/$CONFIG"
+TARGET="/etc/bacula/$CONFIG"
 
 case "$1" in
     configure)
-	if [ ! -f $TARGET ]; then
-	    install -m 640 -o root -g bacula $SRCDIR/$CONFIG $TARGET
-	    sed -e s~@debian_hostname@~`hostname`~ \
-		-e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
-		-i $TARGET
-	fi
+	. /usr/share/bacula-common/common-functions.dpkg
+	readOrCreatePasswords
+
+	# create new bacula-fd.conf using the template
+	TMP_CONFIG="$(mktemp $PKG_NAME.conf.ucftmp-XXXXXXXXXX)"
+	chmod 640 $TMP_CONFIG
+	chown root.bacula $TMP_CONFIG
+
+	sed -e s~@debian_hostname@~`hostname`~ \
+	    -e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
+	    $TEMPLATE > $TMP_CONFIG
+	# let ucf handle the conffile and register it
+	ucf --debconf-ok --three-way $TMP_CONFIG $TARGET
+	ucfr $PKG_NAME $TARGET
     ;;
 esac
 
diff --git a/debian/bacula-director.autopostrm b/debian/bacula-director.autopostrm
index 3a27000..25a5736 100644
--- a/debian/bacula-director.autopostrm
+++ b/debian/bacula-director.autopostrm
@@ -1,3 +1,2 @@
 # this file is handled by debian/scripts/autopostrm
-CONFFILES=/etc/bacula/bacula-dir.conf
-UCF_CONFFILES="/etc/bacula/scripts/delete_catalog_backup /etc/bacula/scripts/make_catalog_backup /etc/default/bacula-dir"
+UCF_CONFFILES="/etc/bacula/bacula-dir.conf /etc/bacula/scripts/delete_catalog_backup /etc/bacula/scripts/make_catalog_backup /etc/default/bacula-dir"
diff --git a/debian/bacula-director.postinst b/debian/bacula-director.postinst
index 8fc9bef..56339e4 100644
--- a/debian/bacula-director.postinst
+++ b/debian/bacula-director.postinst
@@ -2,59 +2,62 @@
 
 set -e
 
+PKG_NAME="bacula-director"
 TEMPLATES="/usr/share/bacula-common/defconfig"
 DSTDIR="/etc/bacula"
 CONFIG="bacula-dir.conf"
-TARGET=$DSTDIR/$CONFIG
+TARGET="$DSTDIR/$CONFIG"
+CONFTEMPLATE="/usr/share/bacula-common/defconfig/$CONFIG"
 
 case "$1" in
     configure)
 	. /usr/share/bacula-common/common-functions.dpkg
+	readOrCreatePasswords
 
 	## handle /etc/default/bacula-dir
 
 	# take over ownership of /etc/default/bacula-dir
 	# (also if previous version is empty)
 	if dpkg --compare-versions "$3" lt "7.4.3+dfsg-5"; then
-	    ucfr -f bacula-director /etc/default/bacula-dir
+	    ucfr -f $PKG_NAME /etc/default/bacula-dir
         fi
-	setup_etc_default bacula-director $@
+	setup_etc_default $PKG_NAME $@
 
 	## handle /etc/bacula/bacula-dir.conf
-
-	readOrCreatePasswords
-	if [ ! -f $TARGET ]; then
-	    echo -n "No $CONFIG found, creating a new one..."
-	    install -m 640 -o root -g bacula $TEMPLATES/$CONFIG $TARGET
-
-	    sed -e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
-		-e s~XXX_MONDIRPASSWORD_XXX~$DIRMPASSWD~ \
-		-e s~XXX_SDPASSWORD_XXX~$SDPASSWD~ \
-		-e s~XXX_FDPASSWORD_XXX~$FDPASSWD~ \
-		-e "s~@debian_hostname@~`hostname`~" \
-		-i $TARGET
-
-            . /usr/share/bacula-common/dbc_database.conf
-            if [ "$dbc_install" = "true" ] ; then
-		case "$dbc_dbtype" in
-		    mysql | pgsql)
-			sed -e "s/dbname = \"XXX_DBNAME_XXX\";/dbname = \"$dbc_dbname\"; DB Address = \"$dbc_dbserver\";/" \
-			    -e "s~/XXX_DBNAME_XXX~/$dbc_dbname~" \
-			    -e "s/XXX_DBUSER_XXX/$dbc_dbuser/" -e "s/XXX_DBPASSWORD_XXX/$dbc_dbpass/" \
-			    -i $TARGET
-			;;
-		    sqlite3)
-			BACULADBNAME=`echo "$dbc_dbname" | sed 's/.db$//'`
-			sed -e "s~/XXX_DBNAME_XXX~/$BACULADBNAME~" \
-			    -e "s~\"XXX_DBNAME_XXX~\"$BACULADBNAME~" \
-			    -e s~XXX_DBUSER_XXX~~ \
-			    -e s~XXX_DBPASSWORD_XXX~~ \
-			    -i  $TARGET
-			;;
-		esac
-            fi
-	    echo "Ok."
-	fi
+	# create new bacula-dir.conf using the template
+	TMP_CONFIG="$(mktemp $PKG_NAME.conf.ucftmp-XXXXXXXXXX)"
+	chmod 640 $TMP_CONFIG
+	chown root.bacula $TMP_CONFIG
+
+	sed -e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
+	    -e s~XXX_MONDIRPASSWORD_XXX~$DIRMPASSWD~ \
+	    -e s~XXX_SDPASSWORD_XXX~$SDPASSWD~ \
+	    -e s~XXX_FDPASSWORD_XXX~$FDPASSWD~ \
+	    -e "s~@debian_hostname@~`hostname`~" \
+	    $CONFTEMPLATE > $TMP_CONFIG
+
+        . /usr/share/bacula-common/dbc_database.conf
+        if [ "$dbc_install" = "true" ] ; then
+	    case "$dbc_dbtype" in
+		mysql | pgsql)
+		    sed -e "s/dbname = \"XXX_DBNAME_XXX\";/dbname = \"$dbc_dbname\"; DB Address = \"$dbc_dbserver\";/" \
+			-e "s~/XXX_DBNAME_XXX~/$dbc_dbname~" \
+			-e "s/XXX_DBUSER_XXX/$dbc_dbuser/" -e "s/XXX_DBPASSWORD_XXX/$dbc_dbpass/" \
+			-i $TMP_CONFIG
+		;;
+		sqlite3)
+		    BACULADBNAME=`echo "$dbc_dbname" | sed 's/.db$//'`
+		    sed -e "s~/XXX_DBNAME_XXX~/$BACULADBNAME~" \
+			-e "s~\"XXX_DBNAME_XXX~\"$BACULADBNAME~" \
+			-e s~XXX_DBUSER_XXX~~ \
+			-e s~XXX_DBPASSWORD_XXX~~ \
+			-i  $TMP_CONFIG
+		;;
+	    esac
+        fi
+	# let ucf handle the conffile and register it
+	ucf --debconf-ok --three-way $TMP_CONFIG $TARGET
+	ucfr $PKG_NAME $TARGET
 
 	## handle /etc/bacula/scripts/delete_catalog_backup
 
@@ -64,7 +67,7 @@ case "$1" in
 	# take over ownership of delete_catalog_backup
 	# (also if previous version is empty)
 	if dpkg --compare-versions "$3" lt "7.4.3+dfsg-4"; then
-	    ucfr -f bacula-director $DSTDIR/scripts/delete_catalog_backup
+	    ucfr -f $PKG_NAME $DSTDIR/scripts/delete_catalog_backup
         fi
 
 	# execute only if dbconfig is in use
@@ -83,7 +86,7 @@ case "$1" in
 		    ;;
 	    esac
 	    install_config \
-		bacula-director \
+		$PKG_NAME \
 		$TEMPLATES/scripts/delete_catalog_backup \
 		$DSTDIR/scripts/delete_catalog_backup
 	    chmod 755 $DSTDIR/scripts/delete_catalog_backup
@@ -94,7 +97,7 @@ case "$1" in
 	# take over ownership of make_catalog_backup
 	# (also if previous version is empty)
 	if dpkg --compare-versions "$3" lt "7.4.3+dfsg-7"; then
-	    ucfr -f bacula-director $DSTDIR/scripts/make_catalog_backup
+	    ucfr -f $PKG_NAME $DSTDIR/scripts/make_catalog_backup
         fi
 
 	tempfile=`tempfile -p "conf-"`
@@ -110,7 +113,7 @@ case "$1" in
 	fi
 
 	ucf --debconf-ok --three-way $tempfile $DSTDIR/scripts/make_catalog_backup
-	ucfr bacula-director $DSTDIR/scripts/make_catalog_backup
+	ucfr $PKG_NAME $DSTDIR/scripts/make_catalog_backup
 	rm -f $tempfile $tempfile.md5sum
     ;;
 
diff --git a/debian/bacula-fd.autopostrm b/debian/bacula-fd.autopostrm
index 440dbea..9dad81c 100644
--- a/debian/bacula-fd.autopostrm
+++ b/debian/bacula-fd.autopostrm
@@ -1,3 +1,2 @@
 # this file is handled by debian/scripts/autopostrm
-CONFFILES=/etc/bacula/bacula-fd.conf
-UCF_CONFFILES=/etc/default/bacula-fd
+UCF_CONFFILES="/etc/bacula/bacula-fd.conf /etc/default/bacula-fd"
diff --git a/debian/bacula-fd.postinst b/debian/bacula-fd.postinst
index 3edfc64..3418d7f 100644
--- a/debian/bacula-fd.postinst
+++ b/debian/bacula-fd.postinst
@@ -2,24 +2,28 @@
 
 set -e
 
-SRCDIR="/usr/share/bacula-common/defconfig"
-DSTDIR="/etc/bacula"
-CONFIG="bacula-fd.conf"
-TARGET=$DSTDIR/$CONFIG
-
-. /usr/share/bacula-common/common-functions.dpkg
-readOrCreatePasswords
-setup_etc_default bacula-fd $@
+PKG_NAME="bacula-fd"
+TEMPLATE="/usr/share/bacula-common/defconfig/$PKG_NAME.conf"
+TARGET="/etc/bacula/$PKG_NAME.conf"
 
 case "$1" in
     configure)
-	if [ ! -f $TARGET ]; then
-	    install -m 640 -o root -g bacula $SRCDIR/$CONFIG $TARGET
-	    sed -e s~@debian_hostname@~`hostname`~ \
-		-e s~XXX_FDPASSWORD_XXX~$FDPASSWD~ \
-		-e s~XXX_MONFDPASSWORD_XXX~$FDMPASSWD~ \
-		-i $TARGET
-	fi
+	. /usr/share/bacula-common/common-functions.dpkg
+	readOrCreatePasswords
+	setup_etc_default $PKG_NAME $@
+
+	# create new bacula-fd.conf using the template
+	TMP_CONFIG="$(mktemp $PKG_NAME.conf.ucftmp-XXXXXXXXXX)"
+	chmod 640 $TMP_CONFIG
+	chown root.bacula $TMP_CONFIG
+
+	sed -e s~@debian_hostname@~`hostname`~ \
+	    -e s~XXX_FDPASSWORD_XXX~$FDPASSWD~ \
+	    -e s~XXX_MONFDPASSWORD_XXX~$FDMPASSWD~ \
+	    $TEMPLATE > $TMP_CONFIG
+	# let ucf handle the conffile and register it
+	ucf --debconf-ok --three-way $TMP_CONFIG $TARGET
+	ucfr $PKG_NAME $TARGET
     ;;
 esac
 
diff --git a/debian/bacula-sd.autopostrm b/debian/bacula-sd.autopostrm
index 551cf0f..2ff5f62 100644
--- a/debian/bacula-sd.autopostrm
+++ b/debian/bacula-sd.autopostrm
@@ -1,3 +1,2 @@
 # this file is handled by debian/scripts/autopostrm
-CONFFILES=/etc/bacula/bacula-sd.conf
-UCF_CONFFILES=/etc/default/bacula-sd
+UCF_CONFFILES="/etc/bacula/bacula-sd.conf /etc/default/bacula-sd"
diff --git a/debian/bacula-sd.postinst b/debian/bacula-sd.postinst
index 24ca6d2..f0f5762 100644
--- a/debian/bacula-sd.postinst
+++ b/debian/bacula-sd.postinst
@@ -2,26 +2,34 @@
 
 set -e
 
-SRCDIR="/usr/share/bacula-common/defconfig"
-DSTDIR="/etc/bacula"
-CONFIG="bacula-sd.conf"
-TARGET=$DSTDIR/$CONFIG
-
-. /usr/share/bacula-common/common-functions.dpkg
-readOrCreatePasswords
-setup_etc_default bacula-sd $@
+PKG_NAME="bacula-sd"
+TEMPLATE="/usr/share/bacula-common/defconfig/$PKG_NAME.conf"
+TARGET="/etc/bacula/$PKG_NAME.conf"
 
 case "$1" in
     configure)
-	if [ ! -f $TARGET ]; then
-	    install -m 640 -o bacula -g bacula $SRCDIR/$CONFIG $TARGET
-	    sed -e s~@debian_hostname@~`hostname`~ \
-		-e s~XXX_SDPASSWORD_XXX~$SDPASSWD~ \
-		-e s~XXX_MONSDPASSWORD_XXX~$SDMPASSWD~ \
-		-i $TARGET
-	else
+	. /usr/share/bacula-common/common-functions.dpkg
+	readOrCreatePasswords
+	setup_etc_default $PKG_NAME $@
+
+	# create new bacula-sd.conf using the template
+	TMP_CONFIG="$(mktemp $PKG_NAME.conf.ucftmp-XXXXXXXXXX)"
+	chmod 640 $TMP_CONFIG
+	chown bacula.bacula $TMP_CONFIG
+
+	sed -e s~@debian_hostname@~`hostname`~ \
+	    -e s~XXX_SDPASSWORD_XXX~$SDPASSWD~ \
+	    -e s~XXX_MONSDPASSWORD_XXX~$SDMPASSWD~ \
+	    $TEMPLATE > $TMP_CONFIG
+	# let ucf handle the conffile and register it
+	ucf --debconf-ok --three-way $TMP_CONFIG $TARGET
+	ucfr $PKG_NAME $TARGET
+
+	# for upgrades from older versions, make sure the config file
+	# is owned by the user bacula
+	if [ -f $TARGET ] && dpkg --compare-versions "$3" lt "7.4.4+dfsg-1"; then
 	    chown bacula $TARGET
-	fi
+        fi
     ;;
 esac
 
diff --git a/debian/changelog b/debian/changelog
index e4b0c14..1113c6f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+bacula (9.0.4+dfsg-4) unstable; urgency=high
+
+  * Handle the main configuration files with ucf, addresses part of #880529
+
+ --
+
 bacula (9.0.4+dfsg-3) unstable; urgency=high
 
   [Sven Hartge]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bacula/bacula.git



More information about the pkg-bacula-commits mailing list