[pkg-bacula-commits] [bacula] 01/09: Add functions for install config files 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 6124d1040933a2a614a96f2e605a7dde1d5b50b2
Author: Alexander Golovko <alexandro at ankalagon.ru>
Date: Tue Jun 5 19:10:02 2012 +0400
Add functions for install config files with ucf
---
debian/additions/common-functions.dpkg | 63 +++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/debian/additions/common-functions.dpkg b/debian/additions/common-functions.dpkg
index 44a17d5..7f98253 100644
--- a/debian/additions/common-functions.dpkg
+++ b/debian/additions/common-functions.dpkg
@@ -44,9 +44,70 @@ EOF
}
+
+#
+# Function for substitute variables into template
+# Usage: substitute <template> <output>
+#
+# will replace all occurance of XXX_var_XXX to value of environment variable `var'
+#
+
+substitute() {
+ local TEMPLATE DEST HOSTNAME SUBST_VARIABLES SEDCMD
+ TEMPLATE="$1"
+ DEST="$2"
+
+ HOSTNAME="${HOSTNAME:-`hostname --fqdn 2>/dev/null || hostname`}"
+
+ if [ -z "$SUBST_VARIABLES" ]; then
+ SUBST_VARIABLES="HOSTNAME DBNAME DBUSER DBPASS DIRPASSWD DIRMPASSWD \
+ SDPASSWD SDMPASSWD FDPASSWD FDMPASSWD"
+ fi
+
+ SEDCMD="sed"
+ for var in $SUBST_VARIABLES; do
+ value=$(eval echo "\$$var" |sed -e 's/[\/&]/\\&/g')
+ SEDCMD="$SEDCMD -e s/XXX_${var}_XXX/$value/g"
+ done
+
+ $SEDCMD "$TEMPLATE" >"$DEST"
+}
+
+
+# Function for install config file from template
+# Usage: install_config <package> <config name> <package most recent configured version>
+#
+# will use substitute() for generate config and then install it with ucf
+#
+
+install_config() {
+ local PACKAGE CONFIG OLD_VERSION TEMPLATE
+ PACKAGE="$1"
+ CONFIG="$2"
+ OLD_VERSION="$3"
+ TEMPLATE="/usr/share/bacula-common/defconfig/$(basename "$CONFIG")"
+ tempfile=`tempfile`
+
+ substitute "$TEMPLATE" "$tempfile"
+
+ # TODO: add check for unchanged configs
+ #if test -n "$OLD_VERSION" \
+ # && dpkg --compare-versions "$OLD_VERSION" lt "5.2.6+dfsg-1" \
+ # && UNCHANGED
+ #then
+ # cp "$tempfile" "$CONFIG"
+ #fi
+
+ ucf --debconf-ok --three-way "$tempfile" "$CONFIG"
+ ucfr "$PACKAGE" "$CONFIG"
+
+ rm -f "$tempfile"
+}
+
+
#
# Function for setup /etc/default/*
-# Usage: call from postins script "setup_etc_default <package> $@"
+# Usage: call from postinst script "setup_etc_default <package> $@"
#
# if there is fresh install, generate default /etc/default/* file
# if there is upgrade from old version, then set ENABLED=no if /etc/bacula/do_not_run present
--
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