6 * Francisco Gimeno <kikov@fco-gimeno.com>
11 require dirname(__FILE__).'/../../env.inc.php';
12 require_once $gfcommon.'include/pre.php';
13 require $gfcommon.'include/cron_utils.php';
15 // Owner of files - apache
16 $file_owner=forge_get_config('apache_user').':'.forge_get_config('apache_group');
18 // Whether to separate directories by first letter like /m/mygroup /a/apple
19 $first_letter = false;
21 // Populate the groups with the files present in the directory
22 // Comment this to have it created empty.
23 $template_groups = 'template_groups';
27 This script create the gforge/upload directory for groups
32 echo "Usage ".$argv[0]." <path> <-f>\n";
33 echo "-f First Letter activated... do groups/m/myprojec\n";
36 if (isset($argv[2]) && $argv[2]=='-f' ) {
40 $upload_path = $argv[1];
41 $basedir = dirname($argv[0]);
43 $err = "Creating Groups at ". $upload_path."\n";
45 if (forge_get_config('apache_user') == '' || forge_get_config('apache_group') == '') {
46 $err .= "Error! sys_apache_user Is Not Set Or sys_apache_group Is Not Set!";
52 $res = db_query_params ('SELECT unix_group_name FROM groups WHERE status != $1 AND status != $2;',
56 $err .= "Error! Database Query Failed: ".db_error();
61 $groups_dir = "$upload_path/groups";
63 if (!is_dir($groups_dir))
64 system("mkdir -p $groups_dir");
67 while ( $row = db_fetch_array($res) ) {
69 $name = $row["unix_group_name"][0]."/".$row["unix_group_name"];
71 $name = $row["unix_group_name"];
74 if (!is_dir("$groups_dir/$name")) {
75 system("mkdir -p $groups_dir/$name");
77 if (isset($template_groups) && !empty($template_groups))
78 system("(cd $basedir/$template_groups ; tar cf - --exclude=.svn *) |" .
79 " (cd $groups_dir/$name; tar xf -)");
83 system("chown $file_owner -R $groups_dir/.");
84 system("find $groups_dir/. -type d -exec chmod 700 {} \;");
85 system("find $groups_dir/. -type f -exec chmod 600 {} \;");