[Fusionforge-commits] FusionForge branch GUM updated. e7b773850176812fdb33bba18a665c1f168262ca

Sylvain Beucler beuc-inria at fusionforge.org
Mon Aug 11 17:56:02 CEST 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, GUM has been updated
       via  e7b773850176812fdb33bba18a665c1f168262ca (commit)
       via  a14fc0c1c5980dd864398807b0124582820e1d34 (commit)
      from  9d7f730d176d61e0b00bdbf25edae11fc6f9019a (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 e7b773850176812fdb33bba18a665c1f168262ca
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Mon Aug 11 17:55:55 2014 +0200

    install: configure postgresql; externalize post-install for reuse in packaging

diff --git a/src/GNUmakefile b/src/GNUmakefile
index 848d15c..0840440 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -23,8 +23,8 @@ database_host=127.0.0.1
 database_port=5432
 database_name=fusionforge
 database_user=fusionforge
-database_password:=$(shell (head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -b-32)
-session_key:=$(shell (head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -b-32)
+database_password:=$(shell (head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
+session_key:=$(shell (head -c100 /dev/urandom; date +"%s:%N") | md5sum | cut -d' ' -f1)
 
 install-config: install-base-dirs
 #	Install initial configuration without overwriting
@@ -47,17 +47,16 @@ install-config: install-base-dirs
 			-e 's, at session_key@,$(session_key),' \
 			> $(DESTDIR)$(config_path)/config.ini.d/secrets.ini; \
 	fi
-#	TODO: httpd.conf.d
 
 install-core: install-base-dirs install-config
-	cp -a VERSION bin common cronjobs db lib templates vendor www $(DESTDIR)$(pkgdatadir)/
+	cp -a VERSION bin common cronjobs db post-install.d templates vendor www lib $(DESTDIR)$(pkgdatadir)/
 	install -d -m 755 $(DESTDIR)$(pkgdatadir)/www/plugins/
 	$(MAKE) -C locale DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) install
 	ln -nfs $(pkgdatadir)/bin/forge_get_config $(DESTDIR)$(prefix)/bin/forge_get_config
 	ln -nfs $(pkgdatadir)/bin/forge_run_jon $(DESTDIR)$(prefix)/bin/forge_run_job
 	ln -nfs $(pkgdatadir)/bin/forge_run_plugin_job $(DESTDIR)$(prefix)/bin/forge_run_plugin_job
 
-PLUGINS:=$(shell utils/list-enabled-plugins.sh)
+PLUGINS:=$(shell bin/list-enabled-plugins.sh)
 PLUGINS_INSTALL_TARGETS=$(addprefix install-plugin-,$(PLUGINS))
 install-plugins: $(PLUGINS_INSTALL_TARGETS)
 
@@ -86,30 +85,16 @@ uninstall:
 
 
 ## Step 3: configure & update system
-post-install: post-install-user post-install-db post-install-plugins
-post-install-user:
-	if ! getent passwd $(user) >/dev/null; then useradd $(user) -s /bin/false -d $(data_path); fi
-post-install-db:
-	post-install.d/db-configure.sh
-	post-install.d/db-populate.sh
-	$(pkgdatadir)/bin/upgrade-db.php
+post-install: post-install-core post-install-plugins
+post-install-core:
+	$(pkgdatadir)/post-install.d/core.sh
 
 PLUGINS_POST_INSTALL_TARGETS=$(addprefix post-install-plugin-,$(PLUGINS))
 # TODO: some plugins require others to be installed first
 # e.g. admssw <- doaprdf
 post-install-plugins: $(PLUGINS_POST_INSTALL_TARGETS)
 post-install-plugin-%:
-#	Run plugin-specific DB install/upgrade
-	$(pkgdatadir)/bin/upgrade-db.php $*
-#	Restart apache if there is some change in config
-#	TODO: manage this with manage-apache-config.sh
-	if [ -f $(config_path)/httpd.conf.d/plugin-$*.inc ]; then \
-	    service $(httpd_service) reload; \
-	fi
-#	Run plugin-specific install
-	if [ -f $(pkgdatadir)/plugins/bin/install.sh ]; then \
-	    $(pkgdatadir)/plugins/bin/install.sh configure; \
-	fi
+	$(pkgdatadir)/post-install.d/plugin.sh $*
 
 clean:
 	$(MAKE) -C locale/ clean
diff --git a/src/GNUmakefile.defaults b/src/GNUmakefile.defaults
index e138792..c054be8 100644
--- a/src/GNUmakefile.defaults
+++ b/src/GNUmakefile.defaults
@@ -21,7 +21,4 @@ config_path=$(sysconfdir)/fusionforge
 data_path=$(localstatedir)/lib/fusionforge
 log_path=$(localstatedir)/log/fusionforge
 
-# No way to detect Apache's distro integration, so let's hard-code:
-httpd_service:=$(shell if [ -e /etc/redhat-release ]; then echo 'httpd'; else echo 'apache2'; fi)
-
 user=fusionforge
diff --git a/src/utils/list-enabled-plugins.sh b/src/bin/list-enabled-plugins.sh
similarity index 100%
rename from src/utils/list-enabled-plugins.sh
rename to src/bin/list-enabled-plugins.sh
diff --git a/src/post-install.d/core.sh b/src/post-install.d/core.sh
new file mode 100755
index 0000000..34505e9
--- /dev/null
+++ b/src/post-install.d/core.sh
@@ -0,0 +1,10 @@
+#!/bin/bash -x
+source_path=$(forge_get_config source_path)
+data_path=$(forge_get_config data_path)
+
+user=gforge  # FIXME: make this a configuration option, or ditch the user
+if ! getent passwd $user >/dev/null; then useradd $user -s /bin/false -d $data_path; fi
+$source_path/post-install.d/db-configure.sh
+$source_path/post-install.d/db-populate.sh
+$source_path/bin/upgrade-db.php
+#	TODO: httpd.conf.d
diff --git a/src/post-install.d/db-configure.sh b/src/post-install.d/db-configure.sh
index 357d12b..3109e69 100755
--- a/src/post-install.d/db-configure.sh
+++ b/src/post-install.d/db-configure.sh
@@ -1,19 +1,53 @@
 #!/bin/bash
 # Configure PostgreSQL
 
-pg_hba=$(ls /etc/postgresql/*/*/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf 2>/dev/null | head -1)
+database_name=$(forge_get_config database_name)
+database_user=$(forge_get_config database_user)
 
-if [ -z "$pg_hba" ]; then
-    echo "Cannot find pg_hba.conf"
-    return 1
-fi
 
+# Create default configuration files if needed
 if [ -e /etc/redhat-release ]; then
     service postgresql initdb >/dev/null
     chkconfig postgresql on
 fi
+
+pg_hba=$(ls /etc/postgresql/*/*/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf 2>/dev/null | tail -1)
+pg_conf=$(ls /etc/postgresql/*/*/postgresql.conf /var/lib/pgsql/data/postgresql.conf 2>/dev/null | tail -1)
+
+if [ -z "$pg_hba" ]; then
+    echo "Cannot find pg_hba.conf"
+    exit 1
+fi
+
+
+# Configure connection
+# Preprend configuration block
+if ! grep -q '^### BEGIN GFORGE BLOCK' $pg_hba; then
+    sed -i -e '1ecat' $pg_hba <<-EOF
+	### BEGIN GFORGE BLOCK -- DO NOT EDIT
+	### END GFORGE BLOCK -- DO NOT EDIT
+	EOF
+fi
+# Replace configuration block
+sed -i -e '/^### BEGIN GFORGE BLOCK/,/^### END GFORGE BLOCK/ { ' -e 'ecat' -e 'd }' $pg_hba <<EOF
+### BEGIN GFORGE BLOCK -- DO NOT EDIT
+# user which is used by libnss to access the DB (see /etc/nss-pgsql.conf)
+local $database_name ${database_user}_nss trust
+local $database_name list ident
+local $database_name ${database_user}_mta md5
+# multi-host configuration
+host  $database_name ${database_user}_nss 0.0.0.0/0 trust
+host  $database_name all 0.0.0.0/0 md5
+### END GFORGE BLOCK -- DO NOT EDIT
+EOF
+
+# Multi-host connection
+if ! grep -q '^listen_addresses\b' $pg_conf; then
+    echo "listen_addresses='0.0.0.0'" >> $pg_conf
+fi
+
 if ! service postgresql status >/dev/null; then
     service postgresql start
+else
+    service postgresql reload
 fi
-
-# TODO: configure pg_hba.conf
diff --git a/src/post-install.d/plugin.sh b/src/post-install.d/plugin.sh
new file mode 100755
index 0000000..ca6afdf
--- /dev/null
+++ b/src/post-install.d/plugin.sh
@@ -0,0 +1,25 @@
+#!/bin/bash -e
+source_path=$(forge_get_config source_path)
+config_path=$(forge_get_config config_path)
+# No way to detect Apache's distro integration, so let's hard-code:
+httpd_service=$(if [ -e /etc/redhat-release ]; then echo 'httpd'; else echo 'apache2'; fi)
+
+if [ -z "$1" ]; then
+    print "Usage: $0 plugin_name"
+    exit 1
+fi
+
+# Run plugin-specific DB install/upgrade
+$source_path/bin/upgrade-db.php $1
+
+# Restart apache if there is some change in config
+# TODO: manage this with manage-apache-config.sh
+if [ -f $config_path/httpd.conf.d/plugin-$1.inc ]; then
+    service $httpd_service reload
+fi
+
+# Run plugin-specific install
+if [ -x $source_path/plugins/$1/bin/install.sh ]; then
+    echo "Running $source_path/plugins/$1/bin/install.sh configure"
+    $source_path/plugins/$1/bin/install.sh configure
+fi

commit a14fc0c1c5980dd864398807b0124582820e1d34
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Mon Aug 11 16:16:37 2014 +0200

    admssw: fail safe when doaprdf is not available yet

diff --git a/src/plugins/admssw/include/admsswPlugin.class.php b/src/plugins/admssw/include/admsswPlugin.class.php
index 94aa45c..662e729 100644
--- a/src/plugins/admssw/include/admsswPlugin.class.php
+++ b/src/plugins/admssw/include/admsswPlugin.class.php
@@ -70,6 +70,13 @@ class admsswPlugin extends Plugin {
 
 		// Add the doaprdf plugin's namespaces
 		$doaprdfplugin = plugin_get_object ("doaprdf");
+		if ($doaprdfplugin == NULL)
+		{
+			// FIXME: constructor use of plugin_get_object
+			// requires 'doaprdf' to be listed before
+			// 'admssw' _in the plugins DB table_.
+			return;
+		}
 		$ns = $doaprdfplugin->doapNameSpaces();
 		foreach($ns as $s => $u)
 		{

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

Summary of changes:
 src/GNUmakefile                                   |   31 ++++---------
 src/GNUmakefile.defaults                          |    3 --
 src/{utils => bin}/list-enabled-plugins.sh        |    0
 src/plugins/admssw/include/admsswPlugin.class.php |    7 +++
 src/post-install.d/core.sh                        |   10 +++++
 src/post-install.d/db-configure.sh                |   48 ++++++++++++++++++---
 src/post-install.d/plugin.sh                      |   25 +++++++++++
 7 files changed, 91 insertions(+), 33 deletions(-)
 rename src/{utils => bin}/list-enabled-plugins.sh (100%)
 create mode 100755 src/post-install.d/core.sh
 create mode 100755 src/post-install.d/plugin.sh


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list