[pkg-bacula-commits] [bacula] 05/09: manage bacula-director configs with ucf
Carsten Leonhardt
leo at moszumanska.debian.org
Wed Jul 20 10:57:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
leo pushed a commit to tag development/migrate-to-ucf-2012-06-07
in repository bacula.
commit e0e8245d0f38e9d561594a4403f2e6cb74ca6f63
Author: Alexander Golovko <alexandro at ankalagon.ru>
Date: Wed Jun 6 14:52:39 2012 +0400
manage bacula-director configs with ucf
---
debian/bacula-director-db.postinst.in | 70 ++++++++++++++++++++++
debian/bacula-director-db.postrm.in | 39 ++++++------
debian/bacula-director-mysql.postinst | 91 ----------------------------
debian/bacula-director-pgsql.postinst | 101 --------------------------------
debian/bacula-director-sqlite3.postinst | 95 ------------------------------
5 files changed, 88 insertions(+), 308 deletions(-)
diff --git a/debian/bacula-director-db.postinst.in b/debian/bacula-director-db.postinst.in
new file mode 100644
index 0000000..397a015
--- /dev/null
+++ b/debian/bacula-director-db.postinst.in
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+db_version 2.0
+
+
+THISDB=XX_DB_XX
+
+case "$THISDB" in
+ mysql)
+ dbc_first_version=1.38.9-3
+ ;;
+ pgsql)
+ dbc_first_version=1.38.9-2
+ dbc_pgsql_createdb_encoding="SQL_ASCII"
+ dbc_sql_substitutions="1"
+ ;;
+ sqlite3)
+ dbc_first_version=3.0.3-3
+ dbc_dbfile_owner=bacula:bacula
+ ;;
+esac
+
+
+# old versions have no invoke-rc.d call in prerm
+if test "$1" = "configure" -a -n "$2" && dpkg --compare-versions "$2" lt "5.2.6+dfsg-1"; then
+ invoke-rc.d bacula-director stop || true
+fi
+
+
+if [ -f /usr/share/dbconfig-common/dpkg/config.$THISDB ]; then
+ . /usr/share/dbconfig-common/dpkg/postinst.$THISDB
+ dbc_go bacula-director-$THISDB $@
+fi
+
+
+. /usr/share/bacula-common/common-functions.dpkg
+setup_etc_default bacula-director-$THISDB $@
+
+
+case "$1" in
+ configure)
+ PACKAGE="bacula-director-$THISDB"
+ CONFIG="/etc/bacula/bacula-dir.conf"
+ readOrCreatePasswords
+
+ #. /etc/dbconfig-common/bacula-director-sqlite3.conf
+ DBNAME="$dbc_dbname"
+ #BACULADBNAME=`echo "$dbc_dbname" | sed 's/.db$//'`
+ DBUSER="$dbc_dbuser"
+ DBPASS="$dbc_dbpass"
+
+ install_config "$PACKAGE" "$CONFIG" "$2"
+ chown root:bacula "$CONFIG"
+ chmod 0640 "$CONFIG"
+esac
+
+
+db_stop
+invoke-rc.d bacula-director start
+
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/bacula-director-db.postrm.in b/debian/bacula-director-db.postrm.in
index fcb3f8f..84274ff 100644
--- a/debian/bacula-director-db.postrm.in
+++ b/debian/bacula-director-db.postrm.in
@@ -3,35 +3,32 @@
set -e
-THISDB=XX_DB_XX
-CONFFILE=/etc/bacula/bacula-dir.conf
-
-
if [ -f /usr/share/debconf/confmodule ]; then
- . /usr/share/debconf/confmodule
- db_version 2.0
+ . /usr/share/debconf/confmodule
+ db_version 2.0
fi
-if [ -f /usr/share/dbconfig-common/dpkg/postrm.$THISDB ]; then
- . /usr/share/dbconfig-common/dpkg/postrm.$THISDB
- dbc_go bacula-director-$THISDB $@
+
+if [ -f /usr/share/dbconfig-common/dpkg/postrm.XX_DB_XX ]; then
+ . /usr/share/dbconfig-common/dpkg/postrm.XX_DB_XX
+ dbc_go bacula-director-XX_DB_XX $@
fi
case "$1" in
purge)
- rm -f $CONFFILE $CONFFILE.dist
-
- # purge /etc/default/bacula-dir
- rm -f /etc/default/bacula-dir /etc/default/bacula-dir.ucf-old \
- /etc/default/bacula-dir.ucf-new /etc/default/bacula-dir.ucf-dist
- if which ucf >/dev/null; then
- ucf --purge /etc/default/bacula-dir
- fi
- if which ucfr >/dev/null; then
- ucfr --purge bacula-director-$THISDB /etc/default/bacula-dir
- fi
- ;;
+ CONFIG_FILES="/etc/bacula/bacula-dir.conf /etc/default/bacula-dir"
+
+ for CONF in $CONFIG_FILES; do
+ rm -f "$CONF" "$CONF.ucf-old" "$CONF.ucf-new" "$CONF.ucf-dist"
+
+ if which ucf >/dev/null; then
+ ucf --purge "$CONF"
+ fi
+ if which ucfr >/dev/null; then
+ ucfr --purge bacula-director-XX_DB_XX "$CONF"
+ fi
+ done
esac
diff --git a/debian/bacula-director-mysql.postinst b/debian/bacula-director-mysql.postinst
deleted file mode 100644
index e4afc0f..0000000
--- a/debian/bacula-director-mysql.postinst
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/sh
-# postinst script for bacula-director-mysql
-#
-
-set -e
-
-. /usr/share/debconf/confmodule
-db_version 2.0
-
-# summary of how this script can be called:
-# * <postinst> `configure' <most-recently-configured-version>
-# * <old-postinst> `abort-upgrade' <new version>
-# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-# <new-version>
-# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-# <failed-install-package> <version> `removing'
-# <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-#
-# quoting from the policy:
-# Any necessary prompting should almost always be confined to the
-# post-installation script, and should be protected with a conditional
-# so that unnecessary prompting doesn't happen if a package's
-# installation fails and the `postinst' is called with `abort-upgrade',
-# `abort-remove' or `abort-deconfigure'.
-
-dbc_first_version=1.38.9-3
-# set in config, must not be set here: dbc_dbuser=bacula
-# set in config, must not be set here: dbc_dbname=bacula
-
-if test "$1" = "configure" -a -n "$2" && dpkg --compare-versions "$2" lt "5.2.6+dfsg-1"; then
- invoke-rc.d bacula-director stop || true
-fi
-
-# source dbconfig-common shell library, and call the hook function
-if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
- . /usr/share/dbconfig-common/dpkg/postinst.mysql
- dbc_go bacula-director-mysql $@
-fi
-
-LOGDIR="/var/log/bacula"
-POSTINST_COMMON="/usr/share/bacula-director/postinst-common"
-DEFCONFIG="/usr/share/bacula-common/defconfig"
-CFGFILE="/etc/bacula/bacula-dir.conf"
-
-
-. /usr/share/bacula-common/common-functions.dpkg
-readOrCreatePasswords
-setup_etc_default bacula-director-mysql $@
-
-case "$1" in
-configure)
- echo -n "Processing configuration..."
- . /etc/dbconfig-common/bacula-director-mysql.conf
- TARGET=$CFGFILE.dpkg-tmp
- # FIXME: should this tweak make_catalog_backup like bacula-director-pgsql.postinst does?
- 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/" \
- -e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
- -e s~XXX_MONDIRPASSWORD_XXX~$DIRMPASSWD~ \
- -e s~XXX_SDPASSWORD_XXX~$SDPASSWD~ \
- -e s~XXX_FDPASSWORD_XXX~$FDPASSWD~ \
- $DEFCONFIG/bacula-dir.conf > $TARGET
-
- sed -i -e "s/XXX_DBNAME_XXX/$dbc_dbname/" /etc/bacula/scripts/delete_catalog_backup
-
- sh $POSTINST_COMMON
-
- echo "Ok."
- ;;
-
-abort-upgrade|abort-remove|abort-deconfigure)
-
- ;;
-
-*)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
-esac
-
-# Do start daemon
-db_stop
-
-invoke-rc.d bacula-director start || exit $?-
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/bacula-director-pgsql.postinst b/debian/bacula-director-pgsql.postinst
deleted file mode 100644
index 67576b8..0000000
--- a/debian/bacula-director-pgsql.postinst
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/sh
-# postinst script for bacula-director-pgsql
-#
-
-set -e
-
-. /usr/share/debconf/confmodule
-db_version 2.0
-
-# summary of how this script can be called:
-# * <postinst> `configure' <most-recently-configured-version>
-# * <old-postinst> `abort-upgrade' <new version>
-# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-# <new-version>
-# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-# <failed-install-package> <version> `removing'
-# <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-#
-# quoting from the policy:
-# Any necessary prompting should almost always be confined to the
-# post-installation script, and should be protected with a conditional
-# so that unnecessary prompting doesn't happen if a package's
-# installation fails and the `postinst' is called with `abort-upgrade',
-# `abort-remove' or `abort-deconfigure'.
-
-dbc_first_version=1.38.9-2
-# set in config, must not be set here: dbc_dbuser=bacula
-# set in config, must not be set here: dbc_dbname=bacula
-
-if test "$1" = "configure" -a -n "$2" && dpkg --compare-versions "$2" lt "5.2.6+dfsg-1"; then
- invoke-rc.d bacula-director stop || true
-fi
-
-# source dbconfig-common shell library, and call the hook function
-if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
- . /usr/share/dbconfig-common/dpkg/postinst.pgsql
- dbc_pgsql_createdb_encoding="SQL_ASCII"
- dbc_sql_substitutions="1"
- dbc_go bacula-director-pgsql $@
-fi
-
-LOGDIR="/var/log/bacula"
-POSTINST_COMMON="/usr/share/bacula-director/postinst-common"
-DEFCONFIG="/usr/share/bacula-common/defconfig"
-CFGFILE="/etc/bacula/bacula-dir.conf"
-CATALOG=bacula
-PGSQL=/usr/bin/psql
-GRANT_SQL_PRIVS="/usr/share/bacula-director/grant_pgsql_privileges"
-AUTHFILE=`getent passwd bacula | cut -d ':' -f 6`/.pgpass
-
-
-. /usr/share/bacula-common/common-functions.dpkg
-readOrCreatePasswords
-setup_etc_default bacula-director-pgsql $@
-
-case "$1" in
-configure)
- echo -n "Processing configuration..."
- . /etc/dbconfig-common/bacula-director-pgsql.conf
- TARGET=$CFGFILE.dpkg-tmp
-
- if [ "$dbc_install" = "true" ] ; then
- sed -e "s/make_catalog_backup bacula bacula/make_catalog_backup -h '$dbc_dbserver' -U $dbc_dbuser/" \
- -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/" \
- -e s~XXX_DIRPASSWORD_XXX~$DIRPASSWD~ \
- -e s~XXX_MONDIRPASSWORD_XXX~$DIRMPASSWD~ \
- -e s~XXX_SDPASSWORD_XXX~$SDPASSWD~ \
- -e s~XXX_FDPASSWORD_XXX~$FDPASSWD~ \
- $DEFCONFIG/bacula-dir.conf > $TARGET
- fi
-
- sed -i -e "s/XXX_DBNAME_XXX/$dbc_dbname/" /etc/bacula/scripts/delete_catalog_backup
-
- sh $POSTINST_COMMON
- echo "Ok."
- ;;
-
-abort-upgrade|abort-remove|abort-deconfigure)
-
- ;;
-
-*)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
-esac
-
-
-
-# Do start daemon
-db_stop
-
-invoke-rc.d bacula-director start || exit $?-
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/bacula-director-sqlite3.postinst b/debian/bacula-director-sqlite3.postinst
deleted file mode 100644
index 61cd2f0..0000000
--- a/debian/bacula-director-sqlite3.postinst
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/sh
-# postinst script for bacula-director-sqlite3
-#
-
-set -e
-
-. /usr/share/debconf/confmodule
-db_version 2.0
-
-# summary of how this script can be called:
-# * <postinst> `configure' <most-recently-configured-version>
-# * <old-postinst> `abort-upgrade' <new version>
-# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-# <new-version>
-# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-# <failed-install-package> <version> `removing'
-# <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-#
-# quoting from the policy:
-# Any necessary prompting should almost always be confined to the
-# post-installation script, and should be protected with a conditional
-# so that unnecessary prompting doesn't happen if a package's
-# installation fails and the `postinst' is called with `abort-upgrade',
-# `abort-remove' or `abort-deconfigure'.
-
-dbc_first_version=3.0.3-3
-dbc_dbfile_owner=bacula:bacula
-# set in config, must not be set here: dbc_dbuser=bacula
-# set in config, must not be set here: dbc_dbname=bacula.db
-# set in config, must not be set here: dbc_basepath=/var/lib/bacula
-
-if test "$1" = "configure" -a -n "$2" && dpkg --compare-versions "$2" lt "5.2.6+dfsg-1"; then
- invoke-rc.d bacula-director stop || true
-fi
-
-# source dbconfig-common shell library, and call the hook function
-if [ -f /usr/share/dbconfig-common/dpkg/config.sqlite3 ]; then
- . /usr/share/dbconfig-common/dpkg/postinst.sqlite3
- dbc_go bacula-director-sqlite3 $@
-fi
-
-LOGDIR="/var/log/bacula"
-POSTINST_COMMON="/usr/share/bacula-director/postinst-common"
-DEFCONFIG="/usr/share/bacula-common/defconfig"
-CFGFILE="/etc/bacula/bacula-dir.conf"
-
-. /usr/share/bacula-common/common-functions.dpkg
-readOrCreatePasswords
-setup_etc_default bacula-director-sqlite3 $@
-
-case "$1" in
-configure)
- echo -n "Processing configuration..."
- . /etc/dbconfig-common/bacula-director-sqlite3.conf
- TARGET=$CFGFILE.dpkg-tmp
- # FIXME: should this tweak make_catalog_backup like bacula-director-pgsql.postinst does?
- BACULADBNAME=`echo "$dbc_dbname" | sed 's/.db$//'`
-
- 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~/XXX_DBNAME_XXX~/$BACULADBNAME~" \
- -e "s~\"XXX_DBNAME_XXX~\"$BACULADBNAME~" \
- -e s~XXX_DBUSER_XXX~~ \
- -e s~XXX_DBPASSWORD_XXX~~ \
- $DEFCONFIG/bacula-dir.conf > $TARGET
-
- sed -i -e "s/XXX_DBNAME_XXX/$dbc_dbname/" /etc/bacula/scripts/delete_catalog_backup
-
- sh $POSTINST_COMMON
-
- echo "Ok."
- ;;
-
-abort-upgrade|abort-remove|abort-deconfigure)
-
- ;;
-
-*)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
-esac
-
-# Do start daemon
-db_stop
-
-invoke-rc.d bacula-director start || exit $?-
-
-#DEBHELPER#
-
-exit 0
--
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