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