6 * The rest Copyright 2002-2005 (c) GForge Team
7 * Copyright 2012, Franck Villaume - TrivialDev
8 * Copyright © 2013 Thorsten Glaser, tarent solutions GmbH
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * This file creates blank user home directories and
28 * creates a group home directory with a template in it.
33 <VirtualHost 192.168.1.5>
34 ServerName gforge.company.com
35 ServerAlias *.gforge.company.com
36 VirtualDocumentRoot /home/groups/%1/htdocs
37 VirtualScriptAlias /home/groups/%1/cgi-bin
39 <Directory /home/groups>
40 Options Indexes FollowSymlinks
46 LogFormat "%h %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" gforge
47 CustomLog "|/usr/local/sbin/cronolog /home/groups/%1/logs/%Y/%m/%d/gforge.log" gforge
48 # Ensure that we don't try to use SSL on SSL Servers
49 <IfModule apache_ssl.c>
56 require_once dirname(__FILE__).'/../www/env.inc.php';
57 require_once $gfcommon.'include/pre.php';
58 require $gfcommon.'include/cron_utils.php';
60 setup_gettext_from_sys_lang();
61 define('USER_DEFAULT_GROUP', 'users');
66 * check whether directory preficēs are set
67 * and create the præfix directories unless they exist
70 if (!($gpfx = forge_get_config('groupdir_prefix'))) {
71 // this should be set in configuration
76 @mkdir($gpfx, 0755, true);
79 if (!($hpfx = forge_get_config('homedir_prefix'))) {
80 // this should be set in configuration
85 @mkdir($hpfx, 0755, true);
88 if (forge_get_config('use_ftp_uploads')) {
89 if (!($fpfx = forge_get_config('ftp_upload_dir'))) {
90 // this should be set in the configuration
95 @mkdir($fpfx, 0755, true);
98 /* signal that we do not use FTP */
102 /* read in the group home template file */
104 if (($fo = fopen(dirname(__FILE__) . '/../utils/default_page.php', 'r'))) {
106 $contents .= fread($fo, 8192);
110 $err .= 'Default Page not found';
113 /* create user homes */
115 $active_projects = group_get_active_projects();
117 foreach ($active_projects as $project) {
118 foreach ($project->getUsers() as $u) {
119 $unames[] = $u->getUnixName();
122 $unames = array_unique($unames);
123 foreach ($unames as $uname) {
124 $uhome = $hpfx . "/" . $uname;
125 if (!is_dir($uhome)) {
128 system("chown $uname:" . USER_DEFAULT_GROUP . " " . $uhome);
131 /* create project/group homes */
133 foreach ($active_projects as $project) {
134 $groupname = $project->getUnixName() ;
136 if ($fpfx && !is_dir($fpfx . '/' . $groupname)) {
137 @mkdir($fpfx . '/' . $groupname);
138 //XXX chown/chgrp/chmod?
141 $ghome = $gpfx . '/' . $groupname;
142 if (!is_dir($ghome)) {
144 /* this is safe as this directory still belongs to root */
145 @mkdir($ghome . '/htdocs');
146 @mkdir($ghome . '/cgi-bin');
148 /* write substituted template to group home */
149 if (($fw = fopen($ghome . '/htdocs/index.html', 'w'))) {
150 fwrite($fw, str_replace('##comment##',
151 _('Default Web Page for groups that haven\'t setup their page yet'),
152 str_replace('##purpose##',
153 _('Please replace this file with your own website'),
154 str_replace('##welcome_to##',
155 sprintf(_('Welcome to %s'), $project->getPublicName()),
156 str_replace('##body##',
157 sprintf(_("We're Sorry but this Project hasn't yet uploaded their personal webpage yet. <br /> Please check back soon for updates or visit <a href=\"%s\">the project page</a>."),
158 util_make_url('/projects/' . $project->getUnixName())),
163 if (forge_get_config('use_manual_uploads')) {
164 @mkdir($ghome . '/incoming');
167 //system('chmod -R ug=rwX,o=rX ' . $ghome);
168 system('chown -R ' . forge_get_config('apache_user') . ':' .
169 forge_get_config('apache_group') . ' ' . $ghome);
170 // find $ghome -type d -print0 | xargs -0 chmod g+s
171 //XXX disabled because, why is this owned by apache_group?