[Fusionforge-commits] FusionForge branch Branch_5_3 updated. c2d6c247843517cfd09efe6f25625c3b95d6b620

Sylvain Beucler beuc-inria at fusionforge.org
Tue Apr 22 11:29:00 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, Branch_5_3 has been updated
       via  c2d6c247843517cfd09efe6f25625c3b95d6b620 (commit)
      from  e6ad4fe6974e38ac345d96226066ca1518a24fb6 (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 c2d6c247843517cfd09efe6f25625c3b95d6b620
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Tue Apr 22 11:21:28 2014 +0200

    Optimize homedirs.php
    - Read usernames from nss_passwd rather than storing nb_groups*nb_users*avg(len(username)) in RAM (800MB->8MB here)
    - chmod/chgrp homedirs only when created (no need after)
    - Read group names and titles only (don't put the full group objects in RAM)
    - Clarify fpfx -> ftp_pfx

diff --git a/src/cronjobs/homedirs.php b/src/cronjobs/homedirs.php
index b0c37f1..b330e70 100755
--- a/src/cronjobs/homedirs.php
+++ b/src/cronjobs/homedirs.php
@@ -81,23 +81,24 @@ if (!($hpfx = forge_get_config('homedir_prefix'))) {
 	// this should be set in configuration
 	exit();
 }
+rtrim($hpfx, '/');
 
 if (!is_dir($hpfx)) {
 	@mkdir($hpfx, 0755, true);
 }
 
 if (forge_get_config('use_ftp_uploads')) {
-	if (!($fpfx = forge_get_config('ftp_upload_dir'))) {
+	if (!($ftp_pfx = forge_get_config('ftp_upload_dir'))) {
 		// this should be set in the configuration
 		exit();
 	}
 
-	if (!is_dir($fpfx)) {
-		@mkdir($fpfx, 0755, true);
+	if (!is_dir($ftp_pfx)) {
+		@mkdir($ftp_pfx, 0755, true);
 	}
 } else {
 	/* signal that we do not use FTP */
-	$fpfx = false;
+	$ftp_pfx = false;
 }
 
 /* read in the group home template file */
@@ -112,30 +113,24 @@ if (($fo = fopen(dirname(__FILE__) . '/../utils/default_page.php', 'r'))) {
 }
 
 /* create user homes */
-
-$active_projects = group_get_active_projects();
-$unames = array();
-foreach ($active_projects as $project) {
-	foreach ($project->getUsers() as $u) {
-		$unames[] = $u->getUnixName();
-	}
-}
-$unames = array_unique($unames);
-foreach ($unames as $uname) {
-	$uhome = $hpfx . "/" . $uname;
-	if (!is_dir($uhome)) {
-		@mkdir($uhome);
+$dirs = array_flip(glob("$hpfx/*/"));
+$res = db_query_params('SELECT login FROM nss_passwd', array());
+foreach(util_result_column_to_array($res,0) as $uname) {
+	$uhome = "$hpfx/$uname/";
+	if (!isset($dirs[$uhome])) {
+		mkdir($uhome);
+		chown($uhome, $uname);
+		chgrp($uhome, USER_DEFAULT_GROUP);
 	}
-	system("chown $uname:" . USER_DEFAULT_GROUP . " " . $uhome);
 }
 
 /* create project/group homes */
+$res = db_query_params('SELECT unix_group_name, group_name FROM groups WHERE status=$1', array('A'));
+while ($row = pg_fetch_array($res)) {
+	$groupname = $row['unix_group_name'] ;
 
-foreach ($active_projects as $project) {
-	$groupname = $project->getUnixName() ;
-
-	if ($fpfx && !is_dir($fpfx . '/' . $groupname)) {
-		@mkdir($fpfx . '/' . $groupname);
+	if ($ftp_pfx && !is_dir($ftp_pfx . '/' . $groupname)) {
+		@mkdir($ftp_pfx . '/' . $groupname);
 		//XXX chown/chgrp/chmod?
 	}
 
@@ -153,11 +148,11 @@ foreach ($active_projects as $project) {
 			    str_replace('##purpose##',
 			    _('Please replace this file with your own website'),
 			    str_replace('##welcome_to##',
-			    sprintf(_('Welcome to %s'), $project->getPublicName()),
+			    sprintf(_('Welcome to %s'), $row['group_name']),
 			    str_replace('##body##',
 			    _("We're Sorry but this Project hasn't uploaded their personal webpage yet.").'<br />'.
 			    sprintf(_('Please check back soon for updates or visit <a href="%s">the project page</a>.'),
-			    util_make_url('/projects/' . $project->getUnixName())),
+			    util_make_url('/projects/' . $row['unix_group_name'])),
 			    $contents)))));
 			fclose($fw);
 		}

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

Summary of changes:
 src/cronjobs/homedirs.php |   45 ++++++++++++++++++++-------------------------
 1 file changed, 20 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list