4 * FusionForge Installation Dependency Setup
6 * Copyright 2006 GForge, LLC
11 * This file is part of GInstaller, it is called by install.sh.
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";
102 system("cp -r * /opt/gforge");
104 chdir("/var/lib/gforge");
105 system("mkdir -p uploads");
106 system("mkdir -p scmtarballs");
107 system("mkdir -p scmsnapshots");
109 //#project vhost space
110 system("mkdir -p homedirs");
111 system("mkdir -p /home/groups");
112 if (!is_dir("homedirs/groups"))
114 symlink("/home/groups", "homedirs/groups");
117 // Create default location for SVN repositories
118 system("mkdir -p svnroot");
119 if (!is_dir("/svnroot"))
121 symlink("/var/lib/gforge/svnroot", "/svnroot");
124 // Create default location for CVS repositories
125 system("mkdir -p cvsroot");
126 if (!is_dir("/cvsroot"))
128 symlink("/var/lib/gforge/cvsroot", "/cvsroot");
131 // Create default dumps dir
132 system("mkdir -p /var/lib/gforge/dumps");
135 chdir("/opt/gforge");
137 //#restricted shell for cvs accounts
139 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
141 system("chmod 755 /bin/cvssh.pl");
143 // Create default location for gforge config files
144 system("mkdir -p /etc/gforge");
145 if (!is_file("/etc/gforge/local.inc")) {
146 system("cp etc/local.inc.example /etc/gforge/local.inc");
148 if (!is_file("/etc/gforge/httpd.conf")) {
149 system("cp etc/gforge-httpd.conf.example /etc/gforge/httpd.conf");
152 system("mkdir -p /etc/gforge/httpd.d");
153 system("cp plugins/*/etc/httpd.d/*.conf /etc/gforge/httpd.d");
155 // Install default configuration files for all plugins.
156 system("mkdir -p /etc/gforge/plugins/");
157 chdir("/opt/gforge/plugins");
158 foreach( glob("*") as $plugin) {
159 $source = "/opt/gforge/plugins/$plugin/etc/plugins/$plugin";
160 if (is_dir($source)) {
161 system("cp -r $source /etc/gforge/plugins/");
165 $apacheconffiles=array();
166 if (is_file('/etc/httpd/conf/httpd.conf')) {
167 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
168 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
169 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
170 } elseif (is_file('/etc/apache2/httpd.conf')) {
171 $apacheconffiles[]='/etc/apache2/httpd.conf';
173 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
176 foreach ($apacheconffiles as $apacheconffile) {
177 echo('Setting FusionForge Include For Apache...');
178 system("grep \"^Include /etc/gforge/httpd.conf\" $apacheconffile > /dev/null", $ret);
180 system("echo \"Include /etc/gforge/httpd.conf\" >> $apacheconffile");
184 // Create symlink for the wiki plugin.
185 if (!is_dir("/opt/gforge/www/wiki"))
187 symlink ("../plugins/wiki/www/", "/opt/gforge/www/wiki");
190 //#symlink plugin www's
192 chdir("/opt/gforge/www");
193 if (!is_dir("plugins"))
195 system("mkdir -p plugins");
199 if (!is_dir("cvstracker"))
201 symlink ("../../plugins/cvstracker/www/", "cvstracker");
203 if (!is_dir("svntracker"))
205 symlink ("../../plugins/svntracker/www/", "svntracker");
207 if (!is_dir("scmcvs"))
209 symlink ("../../plugins/scmcvs/www", "scmcvs");
211 if (!is_dir("fckeditor"))
213 symlink ("../../plugins/fckeditor/www", "fckeditor");
217 chdir("/opt/gforge");
218 system("chown -R root:$args[3] /opt/gforge");
219 system("chmod -R 644 /opt/gforge/");
220 system("cd /opt/gforge && find -type d | xargs chmod 755");
221 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
222 system("chmod -R 755 /opt/gforge/cronjobs/");
223 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
225 if (!is_dir("/etc/gforge"))
227 echo "/etc/gforge didn't exist - error - make sure you've got permission";
230 system("chown -R root:$args[3] /etc/gforge/");
231 system("chmod -R 644 /etc/gforge/");
232 system("cd /etc/gforge && find -type d | xargs chmod 755");
233 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
234 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
235 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$args[1]/\" {} \;");
236 system("echo \"noreply: /dev/null\" >> /etc/aliases");
238 # Generate a random hash for the session_key
239 $hash = md5(microtime());
240 system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
242 # Use liberation fonts if jpgraph provided in the archive.
243 if (is_dir("/opt/gforge/jpgraph")) {
244 system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
245 system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
246 system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
247 system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
248 system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
249 system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");