[Fusionforge-commits] FusionForge branch feature/reactivity updated. f7a120e6d295ef24619d6cbd65906a02263111a2

Sylvain Beucler beuc-inria at fusionforge.org
Thu Dec 18 17:54:22 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, feature/reactivity has been updated
       via  f7a120e6d295ef24619d6cbd65906a02263111a2 (commit)
      from  ddd3c87fa9e33097336ab7d1c8cf1e11ae241637 (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 f7a120e6d295ef24619d6cbd65906a02263111a2
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Thu Dec 18 17:47:33 2014 +0100

    reactivity: rename sysaction->systask; setup and systasksd; pass ScmSvn testsuite

diff --git a/src/GNUmakefile b/src/GNUmakefile
index 7ed315f..a4390bb 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -64,6 +64,7 @@ install-config: install-base-dirs
 install-common: install-config install-plugin-authbuiltin
 	$(MAKE) -C locale DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) install
 	$(CP_R) VERSION bin common templates lib $(DESTDIR)$(pkgdatadir)/
+	chmod 755 $(DESTDIR)$(pkgdatadir)/bin/ssh_akc.php
 	$(INSTALL) -d -m 00755 $(DESTDIR)$(config_path)/custom/
 	$(CP_R) cronjobs/scm $(DESTDIR)$(pkgdatadir)/cronjobs/  # no dedicated 'scm' package now
 	$(CP_R) post-install.d/common $(DESTDIR)$(pkgdatadir)/post-install.d/
@@ -74,6 +75,7 @@ install-common: install-config install-plugin-authbuiltin
 	ln -nfs $(pkgdatadir)/bin/forge_run_plugin_job $(DESTDIR)$(bindir)
 	ln -nfs $(pkgdatadir)/bin/forge_make_admin $(DESTDIR)$(bindir)
 	ln -nfs $(pkgdatadir)/bin/forge_set_password $(DESTDIR)$(bindir)
+	$(CP_R) etc/init.d/fusionforge-systasksd $(DESTDIR)$(sysconfdir)/init.d/
 	$(INSTALL) -d -m 00755 $(DESTDIR)$(log_path)/
 
 install-db-local: install-db
diff --git a/src/common/include/SysActionsQ.class.php b/src/bin/systasks_wait_until_empty.php
old mode 100644
new mode 100755
similarity index 55%
copy from src/common/include/SysActionsQ.class.php
copy to src/bin/systasks_wait_until_empty.php
index 8b89caf..cbeaf8c
--- a/src/common/include/SysActionsQ.class.php
+++ b/src/bin/systasks_wait_until_empty.php
@@ -1,9 +1,9 @@
+#!/usr/bin/php
 <?php
 /**
- * FusionForge system action queue
+ * Synchronously wait until all tasks are done - useful for testsuite
  *
  * Copyright (C) 2014  Inria (Sylvain Beucler)
- * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -21,27 +21,22 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-define('SYSACTION_CORE', null);
-define('SYSACTION_SCM_REPO', 27);
+putenv('FUSIONFORGE_NO_PLUGINS=true');
 
-class SysActionsQ extends Error {
-		function add($plugin_id, $sysaction_type_id, $group_id, $user_id=null) {
-				$res = db_query_params('INSERT INTO sysactionsq (
-				    plugin_id,
-				    sysaction_type_id,
-				    group_id,
-				    user_id,
-				    requested
-				  ) VALUES ($1, $2, $3, $4, now())',
-				  array($plugin_id, $sysaction_type_id, $group_id, $user_id));
-				if (!$res || db_affected_rows($res) < 1) {
-						$this->setError(sprintf(_('Error: Cannot create system action: %s'),
-												db_error()));
-						db_rollback();
-						return false;
-				}
-		}
-}
+require (dirname(__FILE__).'/../common/include/env.inc.php');
+require_once $gfcommon.'include/pre.php';
+
+$first = true;
+do {
+	if ($first)
+		$first = false;
+	else
+		sleep(1);
+
+	$res = db_query_params("SELECT * FROM systasks WHERE status=$1"
+	                       . " ORDER BY systask_id", array('TODO'));
+	$nb = db_numrows($res);
+} while ($nb > 0);
 
 // Local Variables:
 // mode: php
diff --git a/src/bin/light.php b/src/bin/systasksd
similarity index 74%
rename from src/bin/light.php
rename to src/bin/systasksd
index 2749132..01cc60e 100755
--- a/src/bin/light.php
+++ b/src/bin/systasksd
@@ -1,7 +1,7 @@
 #!/usr/bin/php
 <?php
 /**
- * Small and fast system action trigger
+ * Small and fast system tasks trigger
  *
  * Copyright (C) 2014  Inria (Sylvain Beucler)
  *
@@ -56,19 +56,19 @@ function usergroups_sync() {
 		}
 }
 
-function sysaction_get_script($plugin_id, $sysaction_type_id) {
+function systask_get_script($plugin_id, $systask_type_id) {
 		global $cron_arr;
 		global $pm, $plugins;
 		if ($plugin_id == null) {
-				if (isset($cron_arr[$sysaction_type_id]))
+				if (isset($cron_arr[$systask_type_id]))
 						return forge_get_config('source_path')
-								.'/cronjobs/'.$cron_arr[$sysaction_type_id];
+								.'/cronjobs/'.$cron_arr[$systask_type_id];
 		} else {
 				if (isset($plugins[$plugin_id])) {
 						$plugin = $pm->GetPluginObject($plugins[$plugin_id]);
-						if (isset($plugin->sysaction_types[$sysaction_type_id]))
+						if (isset($plugin->systask_types[$systask_type_id]))
 								return forge_get_config('plugins_path')."/".$plugin->GetName()
-										."/cronjobs/".$plugin->sysaction_types[$sysaction_type_id];
+										."/cronjobs/".$plugin->systask_types[$systask_type_id];
 				}
 		}
 		return null;
@@ -76,20 +76,19 @@ function sysaction_get_script($plugin_id, $sysaction_type_id) {
 
 
 
-$shortopts = "v";       // enable verbose mode
-$longopts = array();
+$shortopts = 'v';       // enable verbose mode
+$longopts = array('verbose');
 $options = getopt($shortopts, $longopts);
 if (count($options) != (count($argv)-1)) {  // PHP just strips invalid options
-	print "Usage: {$argv[0]} [-v]\n";
+	print "Usage: {$argv[0]} [-v|--verbose]\n";
 	exit(1);
 }
 $verbose = false;
-if (isset($options['v'])) {
+if (isset($options['v']) or isset($options['verbose'])) {
 	print "verbose mode ON\n";
 	$verbose = true;
 }
 
-
 // Proper daemon
 posix_setsid();
 chdir('/');
@@ -97,6 +96,7 @@ umask(0);
 if (!$verbose) {
 	// Hack to reopen stdin/stdout/stderr, order is important
 	// https://andytson.com/blog/2010/05/daemonising-a-php-cli-script-on-a-posix-system/
+	// (prevents PHP from exiting when printing anything)
 	fclose(STDIN);
 	fclose(STDOUT);
 	fclose(STDERR);
@@ -114,39 +114,39 @@ $plugins = $pm->GetPlugins();
 usergroups_sync();
 while (true) {
 		// Deal with pending requests
-		$res = db_query_params("SELECT * FROM sysactionsq WHERE status=$1"
-		                       . " ORDER BY sysactionsq_id LIMIT 1", array('TODO'));
+		$res = db_query_params("SELECT * FROM systasks WHERE status=$1"
+		                       . " ORDER BY systask_id", array('TODO'));
 		if (!$res && !db_connection_status())
 			db_reconnect();
 		while ($arr = db_fetch_array($res)) {
 				usergroups_sync();
-				$script = sysaction_get_script($arr['plugin_id'], $arr['sysaction_type_id']);
+				$script = systask_get_script($arr['plugin_id'], $arr['systask_type_id']);
 				if (!file_exists($script))
 						// Not installed on this node, skipping
 						continue;
 				if (!is_executable($script)) {
-						db_query_params("UPDATE sysactionsq SET status=$1, error_message=$2"
-										. " WHERE sysactionsq_id=$3",
+						db_query_params("UPDATE systasks SET status=$1, error_message=$2"
+										. " WHERE systask_id=$3",
 										array('ERROR',
-											  "Cron job {$arr['plugin_id']}/{$arr['sysaction_type_id']}"
+											  "Cron job {$arr['plugin_id']}/{$arr['systask_type_id']}"
 											  . " '$script' not executable.\n",
-											  $arr['sysactionsq_id']));
+											  $arr['systask_id']));
 						continue;
 				}
-				db_query_params("UPDATE sysactionsq SET status=$1 WHERE sysactionsq_id=$2",
-								array('WIP', $arr['sysactionsq_id']));
+				db_query_params("UPDATE systasks SET status=$1 WHERE systask_id=$2",
+								array('WIP', $arr['systask_id']));
 				AcquireReplicationLock($script);
 				$ret = null;
 				if ($verbose) print "Running: $script... ";
 				system("$script\n", $ret);
 				if ($ret == 0) {
 						if ($verbose) print "DONE\n";
-						db_query_params("UPDATE sysactionsq SET status=$1 WHERE sysactionsq_id=$2",
-										array('DONE', $arr['sysactionsq_id']));
+						db_query_params("UPDATE systasks SET status=$1 WHERE systask_id=$2",
+										array('DONE', $arr['systask_id']));
 				} else {
 						if ($verbose) print "ERROR\n";
-						db_query_params("UPDATE sysactionsq SET status=$1 WHERE sysactionsq_id=$2",
-										array('ERROR', $arr['sysactionsq_id']));
+						db_query_params("UPDATE systasks SET status=$1 WHERE systask_id=$2",
+										array('ERROR', $arr['systask_id']));
 				}
 		}
 
diff --git a/src/common/include/Group.class.php b/src/common/include/Group.class.php
index 7e47687..02fbfa6 100644
--- a/src/common/include/Group.class.php
+++ b/src/common/include/Group.class.php
@@ -1524,6 +1524,9 @@ class Group extends Error {
 							$plugin_id));
 		}
 		$this->normalizeAllRoles();
+		$hook_params = array();
+		$hook_params['group_id'] = $this->getID();
+		plugin_hook("group_plugin_use", $hook_params);
 		return $res;
 	}
 
diff --git a/src/common/include/SCMPlugin.class.php b/src/common/include/SCMPlugin.class.php
index fdb9a70..81e17b6 100644
--- a/src/common/include/SCMPlugin.class.php
+++ b/src/common/include/SCMPlugin.class.php
@@ -31,6 +31,7 @@ abstract class SCMPlugin extends Plugin {
 	 */
 	function SCMPlugin() {
 		$this->Plugin() ;
+		$this->_addHook('group_plugin_use');
 		$this->_addHook('scm_plugin');
 		$this->_addHook('scm_page');
 		$this->_addHook('scm_admin_page');
@@ -49,6 +50,11 @@ abstract class SCMPlugin extends Plugin {
 
 	function CallHook($hookname, &$params) {
 		switch ($hookname) {
+			case 'group_plugin_use': {
+				$systasksq = new SysTasksQ();
+				$systasksq->add(SYSTASK_CORE, SYSTASK_SCM_REPO, $params['group_id']);
+				break;
+			}
 			case 'scm_plugin': {
 				$scm_plugins=& $params['scm_plugins'];
 				$scm_plugins[]=$this->name;
diff --git a/src/common/include/SysActionsQ.class.php b/src/common/include/SysTasksQ.class.php
similarity index 78%
rename from src/common/include/SysActionsQ.class.php
rename to src/common/include/SysTasksQ.class.php
index 8b89caf..68836f5 100644
--- a/src/common/include/SysActionsQ.class.php
+++ b/src/common/include/SysTasksQ.class.php
@@ -21,19 +21,20 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-define('SYSACTION_CORE', null);
-define('SYSACTION_SCM_REPO', 27);
+define('SYSTASK_CORE', null);
+define('SYSTASK_HOMEDIR', 25);
+define('SYSTASK_SCM_REPO', 27);
 
-class SysActionsQ extends Error {
-		function add($plugin_id, $sysaction_type_id, $group_id, $user_id=null) {
-				$res = db_query_params('INSERT INTO sysactionsq (
+class SysTasksQ extends Error {
+		function add($plugin_id, $systask_type_id, $group_id, $user_id=null) {
+				$res = db_query_params('INSERT INTO systasks (
 				    plugin_id,
-				    sysaction_type_id,
+				    systask_type_id,
 				    group_id,
 				    user_id,
 				    requested
 				  ) VALUES ($1, $2, $3, $4, now())',
-				  array($plugin_id, $sysaction_type_id, $group_id, $user_id));
+				  array($plugin_id, $systask_type_id, $group_id, $user_id));
 				if (!$res || db_affected_rows($res) < 1) {
 						$this->setError(sprintf(_('Error: Cannot create system action: %s'),
 												db_error()));
diff --git a/src/common/include/System.class.php b/src/common/include/System.class.php
index 853fd2b..29e3746 100644
--- a/src/common/include/System.class.php
+++ b/src/common/include/System.class.php
@@ -75,6 +75,8 @@ class System extends Error {
 		if (!$user) {
 			return false;
 		} else {
+			$systasksq = new SysTasksQ();
+			$systasksq->add(SYSTASK_CORE, SYSTASK_HOMEDIR, null, $user_id);
 			return true;
 		}
 	}
diff --git a/src/common/include/cron_utils.php b/src/common/include/cron_utils.php
index f1ab33f..4f6995d 100644
--- a/src/common/include/cron_utils.php
+++ b/src/common/include/cron_utils.php
@@ -25,7 +25,7 @@
 //
 //	This key id# is important - do not change or renumber
 //
-require_once $gfcommon.'include/SysActionsQ.class.php';
+require_once $gfcommon.'include/SysTasksQ.class.php';
 $cron_arr = array();
 $cron_arr[0]='unused';
 $cron_arr[1]='db/calculate_user_metric.php';
@@ -52,9 +52,9 @@ $cron_arr[20]='db/reporting_cron.php';
 $cron_arr[22]='db/daily_task_email.php';
 #$cron_arr[23]='misc/backup_site.php';
 #$cron_arr[24]='svn-stats.php';
-$cron_arr[25]='shell/homedirs.php';
+$cron_arr[SYSTASK_HOMEDIR]='shell/homedirs.php';
 #$cron_arr[26]='update_users.php';
-$cron_arr[SYSACTION_SCM_REPO]='scm/create_scm_repos.php';
+$cron_arr[SYSTASK_SCM_REPO]='scm/create_scm_repos.php';
 $cron_arr[28]='scm/gather_scm_stats.php';
 #$cron_arr[29]='weekly.php';
 $cron_arr[30]='web-vhosts/create_vhosts.php';
diff --git a/src/common/include/system/pgsql.class.php b/src/common/include/system/pgsql.class.php
index ed773d2..fa79953 100644
--- a/src/common/include/system/pgsql.class.php
+++ b/src/common/include/system/pgsql.class.php
@@ -158,7 +158,7 @@ class pgsql extends System {
 				$this->sysGroupAddUser($pid, $user_id) ;
 			}
 		}
-		return true;
+		return parent::sysCreateUser($user_id);
 	}
 
 	/**
diff --git a/src/cronjobs/scm/create_scm_repos.php b/src/cronjobs/scm/create_scm_repos.php
index 68281e2..5e69be8 100755
--- a/src/cronjobs/scm/create_scm_repos.php
+++ b/src/cronjobs/scm/create_scm_repos.php
@@ -25,7 +25,7 @@
 require dirname(__FILE__).'/../../common/include/env.inc.php';
 require_once $gfcommon.'include/pre.php';
 require_once $gfcommon.'include/cron_utils.php';
-require_once $gfcommon.'include/SysActionsQ.class.php';
+require_once $gfcommon.'include/SysTasksQ.class.php';
 
 // Plugins subsystem
 require_once $gfcommon.'include/Plugin.class.php' ;
@@ -38,8 +38,8 @@ session_set_admin ();
 
 setup_plugin_manager();
 
-$res = db_query_params('SELECT sysactionsq_id, group_id FROM sysactionsq WHERE status=$1 AND sysaction_type_id=$2',
-					   array('WIP', SYSACTION_SCM_REPO));
+$res = db_query_params('SELECT systask_id, group_id FROM systasks WHERE status=$1 AND systask_type_id=$2',
+                       array('WIP', SYSTASK_SCM_REPO));
 if (!$res) {
 	$this->setError('Unable to get list of projects using SCM: '.db_error());
 	return false;
@@ -56,7 +56,7 @@ $hook_params = array ('output' => '') ;
 plugin_hook_by_reference ('scm_update_repolist', $hook_params) ;
 $output .= $hook_params['output'];
 
-cron_entry(SYSACTION_SCM_REPO, $output);
+cron_entry(SYSTASK_SCM_REPO, $output);
 
 // Local Variables:
 // mode: php
diff --git a/src/db/20141210-sysactionsq.sql b/src/db/20141210-sysactionsq.sql
deleted file mode 100644
index d22ed7f..0000000
--- a/src/db/20141210-sysactionsq.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-ALTER TABLE nss_usergroups ADD last_modified_date integer;
-CREATE TRIGGER nss_usergroups_update_last_modified_date
-    BEFORE INSERT OR UPDATE ON artifact
-    FOR EACH ROW
-    EXECUTE PROCEDURE update_last_modified_date();
-
--- system queue
-CREATE TYPE sysactionsq_status AS ENUM ('TODO', 'WIP', 'DONE', 'ERROR');
-CREATE TABLE sysactionsq (
-    sysactionsq_id     SERIAL PRIMARY KEY,
-    plugin_id          integer REFERENCES plugins ON DELETE CASCADE,
-    sysaction_type_id  integer NOT NULL,
-    group_id           integer REFERENCES groups ON DELETE CASCADE,
-    user_id            integer REFERENCES users ON DELETE CASCADE,
-    status             sysactionsq_status DEFAULT 'TODO' NOT NULL,
-    error_message      text,
-    requested          timestamp,
-    started            timestamp,
-    stopped            timestamp
-);
-CREATE INDEX sysactionsq_status ON sysactionsq(status);
diff --git a/src/db/20141210-systasks.sql b/src/db/20141210-systasks.sql
new file mode 100644
index 0000000..aae9b14
--- /dev/null
+++ b/src/db/20141210-systasks.sql
@@ -0,0 +1,21 @@
+ALTER TABLE nss_usergroups ADD last_modified_date integer;
+CREATE TRIGGER nss_usergroups_update_last_modified_date
+    BEFORE INSERT OR UPDATE ON artifact
+    FOR EACH ROW
+    EXECUTE PROCEDURE update_last_modified_date();
+
+-- system queue
+CREATE TYPE systask_status AS ENUM ('TODO', 'WIP', 'DONE', 'ERROR');
+CREATE TABLE systasks (
+    systask_id       SERIAL PRIMARY KEY,
+    plugin_id        integer REFERENCES plugins ON DELETE CASCADE,
+    systask_type_id  integer NOT NULL,
+    group_id         integer REFERENCES groups ON DELETE CASCADE,
+    user_id          integer REFERENCES users ON DELETE CASCADE,
+    status           systask_status DEFAULT 'TODO' NOT NULL,
+    error_message    text,
+    requested        timestamp,
+    started          timestamp,
+    stopped          timestamp
+);
+CREATE INDEX systasks_status ON systasks(status);
diff --git a/src/debian/fusionforge-common.prerm b/src/debian/fusionforge-common.prerm
new file mode 100644
index 0000000..15f4847
--- /dev/null
+++ b/src/debian/fusionforge-common.prerm
@@ -0,0 +1,42 @@
+#!/bin/sh
+# prerm script for fusionforge
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove)
+        $(forge_get_config source_path)/post-install.d/common/common.sh remove
+    ;;
+
+    upgrade|deconfigure)
+    ;;
+
+    failed-upgrade)
+    ;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/src/docs/README.Plugins b/src/docs/README.Plugins
index 4a82b16..bca282a 100644
--- a/src/docs/README.Plugins
+++ b/src/docs/README.Plugins
@@ -289,6 +289,12 @@ had been written.
   [TODO: The use of the 'group' name as a parameter is inconsistent
    with most other group plugin hooks - which use group_id.]
 
+  Hook Name  : group_plugin_use
+  Parameters : group_id - The numeric ID of the current group
+  Locations  : common/include/Group.class.php
+  Description: When a plugin is activated for a specific group, this
+               hook is called.
+
   Hook Name  : groupmenu_scm
   Parameters : DIRS - A reference to the array of tab URLs
                TITLES - A reference to the array of tab titles
diff --git a/src/etc/init.d/fusionforge-light b/src/etc/init.d/fusionforge-systasksd
similarity index 73%
rename from src/etc/init.d/fusionforge-light
rename to src/etc/init.d/fusionforge-systasksd
index 1e218f5..d1c50c6 100755
--- a/src/etc/init.d/fusionforge-light
+++ b/src/etc/init.d/fusionforge-systasksd
@@ -1,6 +1,6 @@
 #!/bin/bash
 ### BEGIN INIT INFO
-# Provides:          fusionforge-light
+# Provides:          fusionforge-systasksd
 # Required-Start:    $local_fs $remote_fs $network $syslog $named postgresql
 # Required-Stop:     $local_fs $remote_fs $network $syslog $named postgresql
 # Default-Start:     2 3 4 5
@@ -10,11 +10,11 @@
 ### END INIT INFO
 # Copyright (C) 2014  Inria (Sylvain Beucler)
 
-PIDFILE=/var/run/fusionforge-light
-DAEMON=$(forge_get_config binary_path)/light
+PIDFILE=/var/run/fusionforge-systasksd
+DAEMON=$(forge_get_config binary_path)/systasksd
 
 function check_running() {
-    if kill -0 $(cat $PIDFILE) 2>/dev/null; then
+    if kill -0 $(cat $PIDFILE 2>/dev/null) 2>/dev/null; then
 	return 0
     else
 	return 1
@@ -28,16 +28,18 @@ case $1 in
 	else
 	    $DAEMON &
 	    echo $! > $PIDFILE
-	    if !check_running; then
+	    if ! check_running; then
 		echo "Failed"
 		rm -f $PIDFILE
 		return 1
 	    fi
+	    echo "Started"
 	fi
 	;;
     stop)
-	kill $(cat $PIDFILE)
+	kill $(cat $PIDFILE 2>/dev/null)
 	rm -f $PIDFILE
+	echo "Stopped"
 	;;
     status)
 	if check_running; then
diff --git a/src/plugins/mediawiki/common/mediawikiPlugin.class.php b/src/plugins/mediawiki/common/mediawikiPlugin.class.php
index 16eee55..6f78893 100644
--- a/src/plugins/mediawiki/common/mediawikiPlugin.class.php
+++ b/src/plugins/mediawiki/common/mediawikiPlugin.class.php
@@ -32,14 +32,14 @@ forge_define_config_item('master_path', 'mediawiki', '$mediawiki/mwdata_path/mas
 forge_define_config_item('enable_uploads', 'mediawiki', false);
 forge_set_config_item_bool('enable_uploads', 'mediawiki');
 }
-require_once $gfcommon.'include/SysActionsQ.class.php';
-define('SYSACTION_MEDIAWIKI_CREATE_WIKI', 1);
-define('SYSACTION_MEDIAWIKI_CREATE_IMAGEDIR', 2);
+require_once $gfcommon.'include/SysTasksQ.class.php';
+define('SYSTASK_MEDIAWIKI_CREATE_WIKI', 1);
+define('SYSTASK_MEDIAWIKI_CREATE_IMAGEDIR', 2);
 
 class MediaWikiPlugin extends Plugin {
-	public $sysaction_types = array(
-		SYSACTION_MEDIAWIKI_CREATE_WIKI => 'create-wikis.php',
-		SYSACTION_MEDIAWIKI_CREATE_IMAGEDIR => 'create-imagedirs.php'
+	public $systask_types = array(
+		SYSTASK_MEDIAWIKI_CREATE_WIKI => 'create-wikis.php',
+		SYSTASK_MEDIAWIKI_CREATE_IMAGEDIR => 'create-imagedirs.php'
 	);
 
 	function __construct ($id=0) {
@@ -378,10 +378,10 @@ _("This plugin allows each project to embed Mediawiki under a tab.");
 			if (!parent::groupisactivecheckboxpost($params))
 					return false;
 			if (getIntFromRequest('use_mediawiki') == 1) {
-				$sysactionsq = new SysActionsQ();
+				$systasksq = new SystasksQ();
 				$group_id = $params['group'];
-				$sysactionsq->add($this->getID(), SYSACTION_MEDIAWIKI_CREATE_WIKI, $group_id);
-				$sysactionsq->add($this->getID(), SYSACTION_MEDIAWIKI_CREATE_IMAGEDIR, $group_id);
+				$systasksq->add($this->getID(), SYSTASK_MEDIAWIKI_CREATE_WIKI, $group_id);
+				$systasksq->add($this->getID(), SYSTASK_MEDIAWIKI_CREATE_IMAGEDIR, $group_id);
 			}
 			return true;
 	}
diff --git a/src/plugins/scmsvn/common/SVNPlugin.class.php b/src/plugins/scmsvn/common/SVNPlugin.class.php
index a81aed0..9178aab 100644
--- a/src/plugins/scmsvn/common/SVNPlugin.class.php
+++ b/src/plugins/scmsvn/common/SVNPlugin.class.php
@@ -301,11 +301,9 @@ some control over it to the project's administrator.");
 			if (forge_get_config('use_ssh', 'scmsvn')) {
 				$unix_group = 'scm_' . $project->getUnixName() ;
 				system ("find $repo -type d | xargs -I{} chmod g+s {}") ;
-				if ($project->enableAnonSCM()) {
-					system ("chmod -R g+rwX,o+rX-w $repo") ;
-				} else {
-					system ("chmod -R g+rwX,o-rwx $repo") ;
-				}
+				// open permissions to allow switching private/public easily
+				// see after to restrict the top-level directory
+				system ("chmod -R g+rwX,o+rX-w $repo") ;
 				system ("chgrp -R $unix_group $repo") ;
 			} else {
 				$unix_user = forge_get_config('apache_user');
diff --git a/src/post-install.d/common/common.sh b/src/post-install.d/common/common.sh
index 08f605f..9c6e479 100755
--- a/src/post-install.d/common/common.sh
+++ b/src/post-install.d/common/common.sh
@@ -22,3 +22,4 @@ source_path=$(forge_get_config source_path)
 
 $source_path/post-install.d/common/ini.sh $1 $2
 $source_path/post-install.d/common/user.sh $1 $2
+$source_path/post-install.d/common/systasksd.sh $1 $2
diff --git a/src/post-install.d/common/ini.sh b/src/post-install.d/common/ini.sh
index 1e57d76..d8d7923 100755
--- a/src/post-install.d/common/ini.sh
+++ b/src/post-install.d/common/ini.sh
@@ -108,6 +108,9 @@ case "$1" in
 	fi
 	;;
 
+    remove)
+	;;
+
     purge)
 	# note: can't be called from Debian's postrm - rely on ucfq(1)
 	cd $config_path/config.ini.d/
diff --git a/src/post-install.d/common/common.sh b/src/post-install.d/common/systasksd.sh
similarity index 64%
copy from src/post-install.d/common/common.sh
copy to src/post-install.d/common/systasksd.sh
index 08f605f..d71e2fe 100755
--- a/src/post-install.d/common/common.sh
+++ b/src/post-install.d/common/systasksd.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Call all common post-install scripts in order
+# Start systasksd on boot
 #
 # Copyright (C) 2014  Inria (Sylvain Beucler)
 #
@@ -18,7 +18,29 @@
 # with FusionForge; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-source_path=$(forge_get_config source_path)
+case "$1" in
+    configure)
+	if [ -x /sbin/chkconfig ]; then
+	    chkconfig fusionforge-systasksd on
+	else
+	    update-rc.d fusionforge-systasksd defaults
+	fi
+	service fusionforge-systasksd start
+	;;
 
-$source_path/post-install.d/common/ini.sh $1 $2
-$source_path/post-install.d/common/user.sh $1 $2
+    remove)
+	if [ -x /sbin/chkconfig ]; then
+	    chkconfig fusionforge-systasksd off
+	else
+	    update-rc.d fusionforge-systasksd remove
+	fi
+	;;
+
+    purge)
+	;;
+
+    *)
+	echo "Usage: $0 {configure|remove}"
+	exit 1
+	;;
+esac
diff --git a/src/post-install.d/common/user.sh b/src/post-install.d/common/user.sh
index 9aa3cff..4d94bd1 100755
--- a/src/post-install.d/common/user.sh
+++ b/src/post-install.d/common/user.sh
@@ -31,9 +31,17 @@ case "$1" in
 	fi
 	;;
 
+    remove)
+	;;
+
     purge)
 	# note: can't be called from Debian's postrm - reproduced there
 	userdel $system_user
 	# *not* removing $data_path automatically, let's play safe
 	;;
+
+    *)
+	echo "Usage: $0 {configure|purge}"
+	exit 1
+	;;
 esac
diff --git a/src/www/include/html.php b/src/www/include/html.php
index 90a6c56..758763b 100644
--- a/src/www/include/html.php
+++ b/src/www/include/html.php
@@ -1002,8 +1002,8 @@ function site_user_header($params) {
 	$arr_l[] = '/account/';
 	$arr_attr[] = array('title' => _('Manage your account. Change your password, select your preferences.'));
 
-	$arr_t[] = _('System actions queue');
-	$arr_l[] = '/my/sysactionsq.php';
+	$arr_t[] = _('System tasks');
+	$arr_l[] = '/my/systasks.php';
 	$arr_attr[] = array('title' => _('In-progress and past system replication'));
 
 	if (!forge_get_config('project_registration_restricted')
diff --git a/src/www/my/sysactionsq.php b/src/www/my/systasks.php
similarity index 90%
rename from src/www/my/sysactionsq.php
rename to src/www/my/systasks.php
index 03223ba..3670e4e 100644
--- a/src/www/my/sysactionsq.php
+++ b/src/www/my/systasks.php
@@ -23,7 +23,7 @@
 
 require_once '../env.inc.php';
 require_once $gfcommon.'include/pre.php';
-require_once $gfcommon.'include/SysActionsQ.class.php';
+require_once $gfcommon.'include/SysTasksQ.class.php';
 
 global $HTML; // Layout object
 
@@ -34,7 +34,7 @@ if (!session_loggedin()) {
 
 // Test
 if ($_SERVER['QUERY_STRING'] == 'create') {
-		$sa = new SysActionQ();
+		$sa = new SysTasksQ();
 		$sa->add(null, 1, 1, null);
 		if ($sa->isError()) {
 				exit_error($sa->getErrorMessage());
@@ -51,7 +51,7 @@ foreach($groups as $g)
 		$gids[] = $g->getID();
 $gids = implode(',', $gids);
 
-$res = pg_query_params("SELECT * FROM sysactionsq WHERE user_id=$1 or group_id IN ($gids)"
+$res = pg_query_params("SELECT * FROM systasks WHERE user_id=$1 or group_id IN ($gids)"
 					   . " AND requested > NOW() - interval '1 day'",
 					   array($u->getID()));
 while($row = db_fetch_array($res)) {
diff --git a/src/www/scm/admin/index.php b/src/www/scm/admin/index.php
index 3d4736b..659e4dc 100644
--- a/src/www/scm/admin/index.php
+++ b/src/www/scm/admin/index.php
@@ -26,7 +26,7 @@ require_once $gfcommon.'include/pre.php';
 require_once $gfwww.'project/admin/project_admin_utils.php';
 require_once $gfwww.'scm/include/scm_utils.php';
 require_once $gfcommon.'scm/SCMFactory.class.php';
-require_once $gfcommon.'include/SysActionsQ.class.php';
+require_once $gfcommon.'include/SysTasksQ.class.php';
 
 global $HTML;
 
@@ -51,7 +51,7 @@ if (getStringFromRequest('form_create_repo')) {
 	exit;
 }
 
-$sysactionsq = new SysActionsQ();
+$systasksq = new SysTasksQ();
 
 if (getStringFromRequest('create_repository') && getStringFromRequest('submit')) {
 	$repo_name = trim(getStringFromRequest('repo_name'));
@@ -64,13 +64,13 @@ if (getStringFromRequest('create_repository') && getStringFromRequest('submit'))
 	$hook_params['clone'] = $clone;
 	$hook_params['error_msg'] = '';
 	$hook_params['scm_enable_anonymous'] = getIntFromRequest('scm_enable_anonymous');
-	$sysactionsq->add(SYSACTION_CORE, SYSACTION_SCM_REPO, $group_id);
 	plugin_hook_by_reference('scm_add_repo', $hook_params);
 	if ($hook_params['error_msg']) {
 		$error_msg = $hook_params['error_msg'];
 	}
 	else {
 		$feedback = sprintf(_('New repository %s registered, will be created shortly.'), $repo_name);
+		$systasksq->add(SYSTASK_CORE, SYSTASK_SCM_REPO, $group_id);
 	}
 } elseif (getStringFromRequest('delete_repository') && getStringFromRequest('submit')) {
 	$repo_name = trim(getStringFromRequest('repo_name'));
@@ -80,13 +80,13 @@ if (getStringFromRequest('create_repository') && getStringFromRequest('submit'))
 	$hook_params['repo_name'] = $repo_name;
 	$hook_params['error_msg'] = '';
 	$hook_params['scm_enable_anonymous'] = getIntFromRequest('scm_enable_anonymous');
-	$sysactionsq->add(SYSACTION_CORE, SYSACTION_SCM_REPO, $group_id);
 	plugin_hook_by_reference('scm_delete_repo', $hook_params);
 	if ($hook_params['error_msg']) {
 		$error_msg = $hook_params['error_msg'];
 	}
 	else {
 		$feedback = sprintf(_('Repository %s is marked for deletion (actual deletion will happen shortly).'), $repo_name);
+		$systasksq->add(SYSTASK_CORE, SYSTASK_SCM_REPO, $group_id);
 	}
 } elseif (getStringFromRequest('submit')) {
 	$hook_params = array();
@@ -143,12 +143,10 @@ if (getStringFromRequest('create_repository') && getStringFromRequest('submit'))
 		}
 	}
 
-	if ($scm_changed)
-			$sysactionsq->add(SYSACTION_CORE, SYSACTION_SCM_REPO, $group_id);
-	else
-			// Don't call scm plugin update if their form wasn't displayed
-			// to avoid processing an apparently empty form and reset configuration
-			plugin_hook("scm_admin_update", $hook_params);
+	if (!$scm_changed)
+		// Don't call scm plugin update if their form wasn't displayed
+		// to avoid processing an apparently empty form and reset configuration
+		plugin_hook("scm_admin_update", $hook_params);
 }
 
 scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
diff --git a/tests/func/50_PluginsScmSvn/svnSSHTest.php b/tests/func/50_PluginsScmSvn/svnSSHTest.php
index 7596371..c589571 100644
--- a/tests/func/50_PluginsScmSvn/svnSSHTest.php
+++ b/tests/func/50_PluginsScmSvn/svnSSHTest.php
@@ -42,8 +42,7 @@ class ScmSvnSSHTest extends FForge_SeleniumTestCase
 		$this->uploadSshKey();
 	    
 		// Run the cronjob to create repositories
-		$this->cron("scm/create_scm_repos.php");
-		$this->cron("shell/homedirs.php");
+		$this->waitSystasks();
 
 		// Get the address of the repo
 		$this->open(ROOT);
diff --git a/tests/func/Testing/SeleniumForge.php b/tests/func/Testing/SeleniumForge.php
index 1786085..a345390 100644
--- a/tests/func/Testing/SeleniumForge.php
+++ b/tests/func/Testing/SeleniumForge.php
@@ -137,6 +137,14 @@ class FForge_SeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase
 		$this->runCommand(RUN_JOB_PATH."/forge_run_plugin_job $plugin $cmd");
 	}
 
+    /**
+     * Execute pending system tasks
+     */
+	protected function waitSystasks()
+	{
+		$this->runCommand(RUN_JOB_PATH.'/systasks_wait_until_empty.php');
+	}
+
 	protected function reload_apache()
 	{
 		$this->runCommand("service apache2 reload > /dev/null 2>&1 || service httpd reload > /dev/null 2>&1");

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

Summary of changes:
 src/GNUmakefile                                    |    2 +
 .../systasks_wait_until_empty.php}                 |   24 +++++++---
 src/bin/{light.php => systasksd}                   |   48 ++++++++++----------
 src/common/include/Group.class.php                 |    3 ++
 src/common/include/SCMPlugin.class.php             |    6 +++
 .../{SysActionsQ.class.php => SysTasksQ.class.php} |   15 +++---
 src/common/include/System.class.php                |    2 +
 src/common/include/cron_utils.php                  |    6 +--
 src/common/include/system/pgsql.class.php          |    2 +-
 src/cronjobs/scm/create_scm_repos.php              |    8 ++--
 src/db/20141210-sysactionsq.sql                    |   21 ---------
 src/db/20141210-systasks.sql                       |   21 +++++++++
 ...nforge-shell.prerm => fusionforge-common.prerm} |    2 +-
 src/docs/README.Plugins                            |    6 +++
 .../{fusionforge-light => fusionforge-systasksd}   |   14 +++---
 .../mediawiki/common/mediawikiPlugin.class.php     |   18 ++++----
 src/plugins/scmsvn/common/SVNPlugin.class.php      |    8 ++--
 src/post-install.d/common/common.sh                |    1 +
 src/post-install.d/common/ini.sh                   |    3 ++
 .../{db/db.sh => common/systasksd.sh}              |   25 ++++++----
 src/post-install.d/common/user.sh                  |    8 ++++
 src/www/include/html.php                           |    4 +-
 src/www/my/{sysactionsq.php => systasks.php}       |    6 +--
 src/www/scm/admin/index.php                        |   18 ++++----
 tests/func/50_PluginsScmSvn/svnSSHTest.php         |    3 +-
 tests/func/Testing/SeleniumForge.php               |    8 ++++
 26 files changed, 169 insertions(+), 113 deletions(-)
 copy src/{utils/forge_get_compressor => bin/systasks_wait_until_empty.php} (69%)
 rename src/bin/{light.php => systasksd} (74%)
 rename src/common/include/{SysActionsQ.class.php => SysTasksQ.class.php} (78%)
 delete mode 100644 src/db/20141210-sysactionsq.sql
 create mode 100644 src/db/20141210-systasks.sql
 copy src/debian/{fusionforge-shell.prerm => fusionforge-common.prerm} (91%)
 rename src/etc/init.d/{fusionforge-light => fusionforge-systasksd} (73%)
 copy src/post-install.d/{db/db.sh => common/systasksd.sh} (72%)
 rename src/www/my/{sysactionsq.php => systasks.php} (90%)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list