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";
101 echo "Creating /var/log/gforge ";
102 system("mkdir -p /var/log/gforge ");
103 if (!is_dir("/var/log/gforge"))
105 echo "FAIL\n /var/log/gforge didn't exist - error - make sure you've got permission";
110 system("cp -r * /opt/gforge");
112 chdir("/var/lib/gforge");
113 system("mkdir -p uploads");
114 system("mkdir -p scmtarballs");
115 system("mkdir -p scmsnapshots");
116 system("mkdir -p scmrepos/svn");
117 system("mkdir -p scmrepos/cvs");
119 system("mkdir -p etc");
120 system("touch etc/httpd.vhosts");
122 //#project vhost space
123 system("mkdir -p homedirs");
124 system("mkdir -p /home/groups");
125 if (!is_dir("homedirs/groups"))
127 symlink("/home/groups", "homedirs/groups");
130 if (!is_dir("/scmrepos"))
132 symlink("$fusionforge_data_dir/scmrepos", "/scmrepos");
135 // Create the old symlink /svnroot for compatibility.
136 if (!is_dir("/svnroot"))
138 symlink("$fusionforge_data_dir/scmrepos/svn", "/svnroot");
141 // Create the old symlink /cvsroot for compatibility.
142 if (!is_dir("/cvsroot"))
144 symlink("$fusionforge_data_dir/scmrepos/cvs", "/cvsroot");
147 // Create default dumps dir
148 system("mkdir -p /var/lib/gforge/dumps");
151 chdir("/opt/gforge");
153 //#restricted shell for cvs accounts
155 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
157 system("chmod 755 /bin/cvssh.pl");
159 // Create default location for gforge config files
160 system("mkdir -p /etc/gforge");
161 if (!is_file("/etc/gforge/local.inc")) {
162 system("cp etc/local.inc.example /etc/gforge/local.inc");
164 if (!is_file("/etc/gforge/httpd.conf")) {
165 system("cp etc/httpd.conf-opt /etc/gforge/httpd.conf");
167 system("mkdir -p /etc/gforge/httpd.conf.d");
168 $h = opendir ('etc/httpd.conf.d-opt') ;
169 while (false !== ($file = readdir($h))) {
172 && (preg_match ('/^[0-9a-zA-Z_-]+(.conf)?$/', $file)
173 || preg_match ('/^[0-9a-zA-Z_-]+(.inc)?$/', $file))) {
174 if (!is_file("/etc/gforge/httpd.conf.d/$file")) {
175 system("cp etc/httpd.conf.d-opt/$file /etc/gforge/httpd.conf.d");
181 system("cp etc/config.ini-opt /etc/gforge/config.ini");
182 system("cp -rL etc/config.ini.d /etc/gforge/config.ini.d");
184 // Install default configuration files for all plugins.
185 system("mkdir -p /etc/gforge/plugins/");
186 chdir("/opt/gforge/plugins");
187 foreach( glob("*") as $plugin) {
188 $source = "/opt/gforge/plugins/$plugin/etc/plugins/$plugin";
189 if (is_dir($source)) {
190 system("cp -r $source /etc/gforge/plugins/");
194 $apacheconffiles=array();
195 if (is_file('/etc/httpd/conf/httpd.conf')) {
196 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
197 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
198 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
199 } elseif (is_file('/etc/apache2/httpd.conf')) {
200 $apacheconffiles[]='/etc/apache2/httpd.conf';
202 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
205 foreach ($apacheconffiles as $apacheconffile) {
206 echo('Setting FusionForge Include For Apache...');
207 system("grep \"^Include /etc/gforge/httpd.conf\" $apacheconffile > /dev/null", $ret);
209 system("echo \"Include /etc/gforge/httpd.conf\" >> $apacheconffile");
213 // Create symlink for the wiki plugin.
214 if (!is_dir("/opt/gforge/www/wiki"))
216 symlink ("../plugins/wiki/www/", "/opt/gforge/www/wiki");
219 //#symlink plugin www's
221 chdir("/opt/gforge/www");
222 if (!is_dir("plugins"))
224 system("mkdir -p plugins");
228 if (!is_dir("cvstracker"))
230 symlink ("../../plugins/cvstracker/www/", "cvstracker");
232 if (!is_dir("svntracker"))
234 symlink ("../../plugins/svntracker/www/", "svntracker");
236 if (!is_dir("scmcvs"))
238 symlink ("../../plugins/scmcvs/www", "scmcvs");
240 if (!is_dir("fckeditor"))
242 symlink ("../../plugins/fckeditor/www", "fckeditor");
244 if (!is_dir("blocks"))
246 symlink ("../../plugins/blocks/www", "blocks");
250 chdir("/opt/gforge");
251 system("chown -R root:$args[3] /opt/gforge");
252 system("chmod -R 644 /opt/gforge/");
253 system("cd /opt/gforge && find -type d | xargs chmod 755");
254 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
255 system("chmod -R 755 /opt/gforge/cronjobs/");
256 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
257 system("chmod 755 /opt/gforge/utils/forge_get_config");
258 system("chmod 755 /opt/gforge/utils/manage-apache-config.sh");
259 system("chmod 755 /opt/gforge/utils/manage-translations.sh");
260 system("chmod 755 /opt/gforge/utils/migrate-to-ini-files.sh");
262 if (!is_dir("/etc/gforge"))
264 echo "/etc/gforge didn't exist - error - make sure you've got permission";
267 system("chown -R root:$args[3] /etc/gforge/");
268 system("chmod -R 644 /etc/gforge/");
269 system("cd /etc/gforge && find -type d | xargs chmod 755");
270 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
271 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
272 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$args[1]/\" {} \;");
273 system("echo \"noreply: /dev/null\" >> /etc/aliases");
275 # Generate a random hash for the session_key
276 $hash = md5(microtime());
277 system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
279 # Replace /path/to/gforge to /opt/gforge
280 $config = file_get_contents('/etc/gforge/local.inc');
281 $content = str_replace('/path/to/gforge', '/opt/gforge', $config);
282 file_put_contents('/etc/gforge/local.inc', $content);
285 if (is_dir("/usr/share/jpgraph")) {
286 system("perl -spi -e \"s!^(.sys_path_to_jpgraph)=.*!\\$1='/usr/share/jpgraph';!\" /etc/gforge/local.inc");
287 system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
288 system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
289 system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
290 system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
291 system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
292 system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");