4 * FusionForge Installation Dependency Setup
6 * Copyright 2006 GForge, LLC
11 * This file is part of GInstaller
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
29 define ('GREEN', "\033[01;32m" );
30 define ('NORMAL', "\033[00m" );
31 define ('RED', "\033[01;31m" );
33 $args = $_SERVER['argv'];
35 echo "Validating arguments ";
36 if (count($args) != 4) {
37 echo "FAIL\n Usage: $args[0] gforge.company.com apacheuser apachegroup\n";
43 echo "Validating hostname ";
44 if (!preg_match("/^([[:alnum:]._-])*$/" , $args[1])) {
45 echo "FAIL\n invalid hostname\n";
50 // #validate apache user
51 //getent passwd $2 > /dev/null
53 //if [ $found_apacheuser -ne 0 ]; then
54 // echo 1>&2 "invalid apache user"
59 exec("getent passwd $args[2] > /dev/null", $arr, $t);
61 echo "invalid apache user\n";
68 // #validate apache group
69 //getent group $3 > /dev/null
70 //found_apachegroup=$?
71 //if [ $found_apachegroup -ne 0 ]; then
72 // echo 1>&2 "invalid apache group"
77 exec("getent group $args[3] > /dev/null", $arr, $t);
79 echo "invalid apache group";
83 echo "Creating /opt/gforge ";
84 system("mkdir -p /opt/gforge");
85 if (!is_dir("/opt/gforge"))
87 echo "FAIL\n /opt/gforge didn't exist - error - make sure you've got permission";
92 echo "Creating /var/lib/gforge ";
93 system("mkdir -p /var/lib/gforge ");
94 if (!is_dir("/var/lib/gforge"))
96 echo "FAIL\n /var/lib/gforge didn't exist - error - make sure you've got permission";
101 //system("mv * /opt/gforge");
102 system("cp -r * /opt/gforge");
104 chdir("/var/lib/gforge");
105 system("mkdir -p uploads");
106 system("mkdir -p /opt/jpgraph");
107 system("mkdir -p scmtarballs");
108 system("mkdir -p scmsnapshots");
109 /*if (!is_file("/usr/bin/php4"))
111 symlink("/usr/bin/php", "/usr/bin/php4");
114 //#project vhost space
115 system("mkdir -p homedirs");
116 system("mkdir -p /home/groups");
117 if (!is_dir("homedirs/groups"))
119 symlink("/home/groups", "homedirs/groups");
122 //#Create default location for SVN repositories
123 system("mkdir -p svnroot");
124 if (!is_dir("/svnroot"))
126 symlink("/var/lib/gforge/svnroot", "/svnroot");
129 #Create default location for CVS repositories
130 system("mkdir -p cvsroot");
131 if (!is_dir("/cvsroot"))
133 symlink("/var/lib/gforge/cvsroot", "/cvsroot");
135 #create default dumps dir
136 system("mkdir -p /var/lib/gforge/dumps");
139 chdir("/opt/gforge");
141 //#restricted shell for cvs accounts
143 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
145 system("chmod 755 /bin/cvssh.pl");
147 //#Create default location for gforge config files
148 system("mkdir -p /etc/gforge");
149 system("cp etc/local.inc.example /etc/gforge/local.inc");
150 system("cp etc/gforge-httpd.conf.example /etc/gforge/httpd.conf");
152 ////#copy the scmcvs plugin config to /etc/gforge/
153 //if (!is_dir("/etc/gforge/plugins/scmcvs"))
155 // system("mkdir -p /etc/gforge/plugins/scmcvs");
157 //system("cp plugins/scmcvs/etc/plugins/scmcvs/config.php /etc/gforge/plugins/scmcvs/config.php");
159 ////#copy the scmsvn config files to /etc/gforge/
160 //if (!is_dir("/etc/gforge/plugins/scmsvn"))
162 // system("mkdir -p /etc/gforge/plugins/scmsvn");
164 //system("cp plugins/scmsvn/etc/plugins/scmsvn/config.php /etc/gforge/plugins/scmsvn/config.php");
166 ////#copy the cvstracker config files to /etc/gforge/
167 //if (!is_dir("/etc/gforge/plugins/cvstracker"))
169 // system("mkdir -p /etc/gforge/plugins/cvstracker");
171 //system("cp plugins/cvstracker/etc/plugins/cvstracker/config.php /etc/gforge/plugins/cvstracker/config.php");
173 ////#copy the svntracker config files to /etc/gforge/
174 //if (!is_dir("/etc/gforge/plugins/svntracker"))
176 // system("mkdir -p /etc/gforge/plugins/svntracker");
178 //system("cp plugins/svntracker/etc/plugins/svntracker/config.php /etc/gforge/plugins/svntracker/config.php");
181 $plugins_confFiles = array(
182 "aselectextauth" => "standard",
183 "cvssyncmail" => "standard",
184 "cvstracker" => "standard",
185 "eirc" => "/opt/gforge/plugins/eirc/etc/*",
186 "externalsearch" => "standard",
187 "fckeditor" => "standard",
188 "helloworld" => "standard",
189 "ldapextauth" => "standard",
190 "mantis" => "standard",
191 "mediawiki" => "standard",
192 "scmccase" => "standard",
193 "scmcvs" => "standard",
194 "scmsvn" => "standard",
195 "svncommitemail" => "standard",
196 "svntracker" => "standard",
199 //echo "Este es el array:\n";
200 //print_r($plugins_confFiles);
201 //echo "Antes de entrar al foreach\n";
202 foreach ($plugins_confFiles as $plugin_name => $conf_files)
204 if ($conf_files == "standard") {
205 $source = "/opt/gforge/plugins/$plugin_name/etc/plugins/$plugin_name";
206 $dest = "/etc/gforge/plugins/";
208 $source = $conf_files;
209 $dest = "/etc/gforge/plugins/$plugin_name/";
212 //echo "\tsource=$source\tdest=$dest\n\t\tmkdir -p $dest\n\t\tcp $source $dest\n";
213 if (is_dir("/opt/gforge/plugins/$plugin_name/etc/plugins/$plugin_name")) {
214 system("mkdir -p $dest");
215 system("cp -r $source $dest");
218 //echo "Despues de salir del foreach\n";
221 $apacheconffiles=array();
222 if (is_file('/etc/httpd/conf/httpd.conf')) {
223 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
224 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
225 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
226 } elseif (is_file('/etc/apache2/httpd.conf')) {
227 $apacheconffiles[]='/etc/apache2/httpd.conf';
229 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
232 foreach ($apacheconffiles as $apacheconffile) {
233 echo('Setting GForge Include For Apache...');
234 system("grep \"^Include /etc/gforge/httpd.conf\" $apacheconffile > /dev/null", $ret);
236 system("echo \"Include /etc/gforge/httpd.conf\" >> $apacheconffile");
240 // Create symlink for the wiki plugin.
241 if (!is_dir("/opt/gforge/www/wiki"))
243 symlink ("../plugins/wiki/www/", "/opt/gforge/www/wiki");
246 //#symlink plugin www's
248 chdir("/opt/gforge/www");
249 if (!is_dir("plugins"))
251 system("mkdir -p plugins");
255 if (!is_dir("cvstracker"))
257 symlink ("../../plugins/cvstracker/www/", "cvstracker");
259 if (!is_dir("svntracker"))
261 symlink ("../../plugins/svntracker/www/", "svntracker");
263 if (!is_dir("scmcvs"))
265 symlink ("../../plugins/scmcvs/www", "scmcvs");
267 if (!is_dir("fckeditor"))
269 symlink ("../../plugins/fckeditor/www", "fckeditor");
273 chdir("/opt/gforge");
274 system("chown -R root:$args[3] /opt/gforge");
275 system("chmod -R 644 /opt/gforge/");
276 system("cd /opt/gforge && find -type d | xargs chmod 755");
277 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
278 system("chmod -R 755 /opt/gforge/cronjobs/");
279 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
280 system("chmod 755 /opt/gforge/plugins/scmcvs/cronjobs/cvscreate.sh");
282 if (!is_dir("/etc/gforge"))
284 echo "/etc/gforge didn't exist - error - make sure you've got permission";
287 system("chown -R root:$args[3] /etc/gforge/");
288 system("chmod -R 644 /etc/gforge/");
289 system("cd /etc/gforge && find -type d | xargs chmod 755");
290 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
291 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
292 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$args[1]/\" {} \;");
293 system("echo \"noreply: /dev/null\" >> /etc/aliases");
295 # Generate a random hash for the session_key
296 $hash = md5(microtime());
297 system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
299 # Use liberation fonts if jpgraph provided in the archive.
300 if (is_dir("/opt/gforge/jpgraph")) {
301 system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
302 system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
303 system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
304 system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
305 system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
306 system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");