[Fusionforge-commits] FusionForge branch master updated. 35713bc9318ea6f84bbf3f922cec4fd78fe1036d

Sylvain Beucler beuc-inria at fusionforge.org
Wed Nov 12 18:04:06 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  35713bc9318ea6f84bbf3f922cec4fd78fe1036d (commit)
      from  0d70be1f7bf2cc0fdbfb205bdd0b75fb958c6d83 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 35713bc9318ea6f84bbf3f922cec4fd78fe1036d
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Wed Nov 12 18:03:02 2014 +0100

    install: common: better configuration files support + uninstall support

diff --git a/src/debian/changelog b/src/debian/changelog
index e754aaa..27821f3 100644
--- a/src/debian/changelog
+++ b/src/debian/changelog
@@ -1,6 +1,6 @@
 fusionforge (5.3.50-1) unstable; urgency=medium
 
-  * New upstream release
+  * New upstream release (closes: #769098)
   * Adapt packaging to new build system
 
  -- Sylvain Beucler <beuc at debian.org>  Mon, 22 Sep 2014 14:58:47 +0200
diff --git a/src/debian/fusionforge-common.postinst b/src/debian/fusionforge-common.postinst
index 3959636..c2402da 100644
--- a/src/debian/fusionforge-common.postinst
+++ b/src/debian/fusionforge-common.postinst
@@ -20,7 +20,13 @@ set -e
 
 case "$1" in
     configure)
-        $(forge_get_config source_path)/post-install.d/common/common.sh
+	DESTDIR=$(mktemp -d)
+        $(forge_get_config source_path)/post-install.d/common/common.sh configure $DESTDIR
+	for i in $(find $DESTDIR -type f); do
+	    ucf $i ${i#$DESTDIR}
+	    ucfr -f fusionforge-common ${i#$DESTDIR}
+	done
+	rm -rf $DESTDIR/
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
diff --git a/src/debian/fusionforge-web.postrm b/src/debian/fusionforge-common.postrm
similarity index 90%
copy from src/debian/fusionforge-web.postrm
copy to src/debian/fusionforge-common.postrm
index 4583fd3..0cbb8db 100644
--- a/src/debian/fusionforge-web.postrm
+++ b/src/debian/fusionforge-common.postrm
@@ -21,13 +21,14 @@ set -e
 
 case "$1" in
     purge)
-	ucfq fusionforge-web --with-colons \
+	ucfq fusionforge-common --with-colons \
 	    | while IFS=: read i ignored; do
 	    rm -f $i $i.ucf-*
 	    ucf --purge $i
-	    ucfr --purge fusionforge-web $i
+	    ucfr --purge fusionforge-common $i
 	done
-    ;;
+	userdel fusionforge
+	;;
 
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
 	;;
diff --git a/src/debian/fusionforge-web.postrm b/src/debian/fusionforge-web.postrm
index 4583fd3..402fd61 100644
--- a/src/debian/fusionforge-web.postrm
+++ b/src/debian/fusionforge-web.postrm
@@ -27,7 +27,7 @@ case "$1" in
 	    ucf --purge $i
 	    ucfr --purge fusionforge-web $i
 	done
-    ;;
+	;;
 
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
 	;;
diff --git a/src/post-install.d/common/common.sh b/src/post-install.d/common/common.sh
index 5dc6b19..08f605f 100755
--- a/src/post-install.d/common/common.sh
+++ b/src/post-install.d/common/common.sh
@@ -20,5 +20,5 @@
 
 source_path=$(forge_get_config source_path)
 
-$source_path/post-install.d/common/ini.sh
-$source_path/post-install.d/common/user.sh
+$source_path/post-install.d/common/ini.sh $1 $2
+$source_path/post-install.d/common/user.sh $1 $2
diff --git a/src/post-install.d/common/ini.sh b/src/post-install.d/common/ini.sh
index 4293f56..49a7084 100755
--- a/src/post-install.d/common/ini.sh
+++ b/src/post-install.d/common/ini.sh
@@ -22,79 +22,98 @@
 source_path=$(forge_get_config source_path)
 config_path=$(forge_get_config config_path)
 
-# TODO: support 'db_get @PACKAGE@/shared/web_host' ?
-hostname=$(hostname -f || hostname)
-if [ ! -e $config_path/config.ini.d/post-install.ini ]; then \
-	sed $source_path/templates/post-install.ini \
+case "$1" in
+    configure)
+	# Distros may want to install new conffiles using tools such as ucf(1)
+	DESTDIR=$2
+	mkdir -m 755 -p $DESTDIR$config_path/config.ini.d/
+
+	# TODO: support 'db_get @PACKAGE@/shared/web_host' ?
+	hostname=$(hostname -f || hostname)
+	if [ ! -e $DESTDIR$config_path/config.ini.d/post-install.ini ]; then \
+	    sed $source_path/templates/post-install.ini \
 		-e "s, at web_host@,$hostname," \
-		> $config_path/config.ini.d/post-install.ini; \
-fi
+		> $DESTDIR$config_path/config.ini.d/post-install.ini; \
+	fi
+
+	# Get current values in case we're updating the Debian conf via ucf(1)
+	database_host=$(forge_get_config database_host)
+	database_port=$(forge_get_config database_port)
+	database_name=$(forge_get_config database_name)
+	database_user=$(forge_get_config database_user)
+	database_password=$(forge_get_config database_password)
+	database_password_mta=$(forge_get_config database_password_mta)
+	database_password_ssh_akc=$(forge_get_config database_password_ssh_akc)
+	session_key=$(forge_get_config session_key)
+	
+	if [ -z $database_host ]; then
+	    database_host=127.0.0.1
+	fi
+	if [ -z $database_port ]; then
+	    database_port=5432
+	fi
+	if [ -z $database_name ]; then
+	    database_name=fusionforge
+	fi
+	if [ -z $database_user ]; then
+	    database_user=fusionforge
+	fi
+	
+	# Don't overwrite existing config (e.g. previous or Puppet-generated)
+	if [ ! -e $DESTDIR$config_path/config.ini.d/post-install-secrets.ini ]; then
+	    if [ -z "$database_password" ]; then
+		database_password=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
+	    fi
+	    if [ -z "$database_password_mta" ]; then
+		database_password_mta=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
+	    fi
 
-database_host=$1
-database_port=$2
-database_name=$3
-database_user=$4
-database_password_file=$5
-database_password_file_mta=$6
-database_password_file_ssh_akc=$7
+	    # Generate session key here for simplificy
+	    if [ -z "$session_key" ]; then
+		session_key=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
+	    fi
 
-if [ -z $database_host ]; then
-    database_host=127.0.0.1
-fi
-if [ -z $database_port ]; then
-    database_port=5432
-fi
-if [ -z $database_name ]; then
-    database_name=fusionforge
-fi
-if [ -z $database_user ]; then
-    database_user=fusionforge
-fi
+	    # Create config file
+	    sed $source_path/templates/post-install-secrets.ini \
+		-e "s, at database_host@,$database_host," \
+		-e "s, at database_port@,$database_port," \
+		-e "s, at database_name@,$database_name," \
+		-e "s, at database_user@,$database_user," \
+		> $DESTDIR$config_path/config.ini.d/post-install-secrets.ini
+	    chmod 600 $config_path/config.ini.d/post-install-secrets.ini
+	    sed -i -e '/^@secrets@/ { ' -e 'ecat' -e 'd }' \
+		$DESTDIR$config_path/config.ini.d/post-install-secrets.ini <<-EOF
+		session_key=$session_key
+		database_password=$database_password
+		database_password_mta=$database_password_mta
+		EOF
+	fi
+	
+	# Special conf for AuthorizedKeysCommand (chown'd in post-install.d/shell/shell.sh)
+	if [ ! -e $DESTDIR$config_path/config.ini.d/post-install-secrets-ssh_akc.ini ]; then
+	    if [ -z "$database_password_ssh_akc" ]; then
+		database_password_ssh_akc=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
+	    fi
+	    cat <<-EOF > $DESTDIR$config_path/config.ini.d/post-install-secrets-ssh_akc.ini
+		[core]
+		database_host=$database_host
+		database_port=$database_port
+		database_name=$database_name
+		database_user_ssh_akc=${database_user}_ssh_akc
+		database_password_ssh_akc=$database_password_ssh_akc
+		EOF
+	    chmod 600 $DESTDIR$config_path/config.ini.d/post-install-secrets-ssh_akc.ini
+	fi
+	;;
 
-# Don't overwrite existing config (e.g. previous or Puppet-generated)
-if [ ! -e $config_path/config.ini.d/post-install-secrets.ini ]; then
-    database_password=$(cat "$database_password_file" 2>/dev/null)
-    if [ -z "$database_password" ]; then
-	database_password=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
-    fi
-    database_password_mta=$(cat "$database_password_mta_file" 2>/dev/null)
-    if [ -z "$database_password_mta" ]; then
-	database_password_mta=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
-    fi
-    
-    # Generate session key here for simplificy
-    session_key=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
-    
-    # Create config file
-    sed $source_path/templates/post-install-secrets.ini \
-	-e "s, at database_host@,$database_host," \
-	-e "s, at database_port@,$database_port," \
-	-e "s, at database_name@,$database_name," \
-	-e "s, at database_user@,$database_user," \
-	-e "s, at session_key@,$session_key," \
-	> $config_path/config.ini.d/post-install-secrets.ini
-    chmod 600 $config_path/config.ini.d/post-install-secrets.ini
-    sed -i -e '/^@secrets@/ { ' -e 'ecat' -e 'd }' \
-	$config_path/config.ini.d/post-install-secrets.ini <<-EOF
-	session_key=$session_key
-	database_password=$database_password
-	database_password_mta=$database_password_mta
-	EOF
-fi
+    purge)
+	# note: can't be called from Debian's postrm - rely on ucfq(1)
+	cd $config_path/config.ini.d/
+	rm -f post-install.ini post-install-secrets.ini post-install-secrets-ssh_akc.ini
+	;;
 
-# Special conf for AuthorizedKeysCommand (chown'd in post-install.d/shell/shell.sh)
-if [ ! -e $config_path/config.ini.d/post-install-secrets-ssh_akc.ini ]; then
-    database_password_ssh_akc=$(cat "$database_password_ssh_akc_file" 2>/dev/null)
-    if [ -z "$database_password_ssh_akc" ]; then
-	database_password_ssh_akc=$((head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
-    fi
-    cat <<-EOF > $config_path/config.ini.d/post-install-secrets-ssh_akc.ini
-	[core]
-	database_host=$database_host
-	database_port=$database_port
-	database_name=$database_name
-	database_user_ssh_akc=${database_user}_ssh_akc
-	database_password_ssh_akc=$database_password_ssh_akc
-	EOF
-    chmod 600 $config_path/config.ini.d/post-install-secrets-ssh_akc.ini
-fi
+    *)
+	echo "Usage: $0 {configure|purge}"
+	exit 1
+	;;
+esac
diff --git a/src/post-install.d/common/user.sh b/src/post-install.d/common/user.sh
index 97985b1..9aa3cff 100755
--- a/src/post-install.d/common/user.sh
+++ b/src/post-install.d/common/user.sh
@@ -23,6 +23,17 @@
 
 system_user=$(forge_get_config system_user)
 data_path=$(forge_get_config data_path)
-if ! getent passwd $system_user >/dev/null; then
-    useradd $system_user -s /bin/false -M -d $data_path
-fi
+
+case "$1" in
+    configure)
+	if ! getent passwd $system_user >/dev/null; then
+	    useradd $system_user -s /bin/false -M -d $data_path
+	fi
+	;;
+
+    purge)
+	# note: can't be called from Debian's postrm - reproduced there
+	userdel $system_user
+	# *not* removing $data_path automatically, let's play safe
+	;;
+esac
diff --git a/src/post-install.d/web/web.sh b/src/post-install.d/web/web.sh
index 6558e38..d563ccc 100755
--- a/src/post-install.d/web/web.sh
+++ b/src/post-install.d/web/web.sh
@@ -28,6 +28,7 @@ case "$1" in
 	$0 configure-exec
 	;;
 
+    # Prepare config files for installation
     configure-conffiles)
 	# Distros may want to install new conffiles using tools such as ucf(1)
 	DESTDIR=$2
@@ -44,6 +45,7 @@ case "$1" in
 	done
 	;;
 
+    # Configure once config files are installed
     configure-exec)
 	apache_user=$(forge_get_config apache_user)
 	apache_group=$(forge_get_config apache_group)

-----------------------------------------------------------------------

Summary of changes:
 src/debian/changelog                               |    2 +-
 src/debian/fusionforge-common.postinst             |    8 +-
 ...orge-shell.postrm => fusionforge-common.postrm} |    7 +-
 src/debian/fusionforge-web.postrm                  |    2 +-
 src/post-install.d/common/common.sh                |    4 +-
 src/post-install.d/common/ini.sh                   |  161 +++++++++++---------
 src/post-install.d/common/user.sh                  |   17 ++-
 src/post-install.d/web/web.sh                      |    2 +
 8 files changed, 121 insertions(+), 82 deletions(-)
 copy src/debian/{fusionforge-shell.postrm => fusionforge-common.postrm} (90%)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list