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 etc");
117 system("touch etc/httpd.vhosts");
119 //#project vhost space
120 system("mkdir -p homedirs");
121 system("mkdir -p /home/groups");
122 if (!is_dir("homedirs/groups"))
124 symlink("/home/groups", "homedirs/groups");
127 // Create default location for SVN repositories
128 system("mkdir -p svnroot");
129 if (!is_dir("/svnroot"))
131 symlink("/var/lib/gforge/svnroot", "/svnroot");
134 // Create default location for CVS repositories
135 system("mkdir -p cvsroot");
136 if (!is_dir("/cvsroot"))
138 symlink("/var/lib/gforge/cvsroot", "/cvsroot");
141 // Create default dumps dir
142 system("mkdir -p /var/lib/gforge/dumps");
145 chdir("/opt/gforge");
147 //#restricted shell for cvs accounts
149 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
151 system("chmod 755 /bin/cvssh.pl");
153 // Create default location for gforge config files
154 system("mkdir -p /etc/gforge");
155 if (!is_file("/etc/gforge/local.inc")) {
156 system("cp etc/local.inc.example /etc/gforge/local.inc");
158 if (!is_file("/etc/gforge/httpd.conf")) {
159 system("cp etc/httpd.conf-opt /etc/gforge/httpd.conf");
161 system("mkdir -p /etc/gforge/httpd.conf.d");
162 $h = opendir ('etc/httpd.conf.d-opt') ;
163 while (false !== ($file = readdir($h))) {
166 && (preg_match ('/^[0-9a-zA-Z_-]+(.conf)?$/', $file)
167 || preg_match ('/^[0-9a-zA-Z_-]+(.inc)?$/', $file))) {
168 if (!is_file("/etc/gforge/httpd.conf.d/$file")) {
169 system("cp etc/httpd.conf.d-opt/$file /etc/gforge/httpd.conf.d");
175 system("cp etc/config.ini-opt /etc/gforge/config.ini");
176 system("cp -rL etc/config.ini.d /etc/gforge/config.ini.d");
178 // Install default configuration files for all plugins.
179 system("mkdir -p /etc/gforge/plugins/");
180 chdir("/opt/gforge/plugins");
181 foreach( glob("*") as $plugin) {
182 $source = "/opt/gforge/plugins/$plugin/etc/plugins/$plugin";
183 if (is_dir($source)) {
184 system("cp -r $source /etc/gforge/plugins/");
188 $apacheconffiles=array();
189 if (is_file('/etc/httpd/conf/httpd.conf')) {
190 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
191 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
192 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
193 } elseif (is_file('/etc/apache2/httpd.conf')) {
194 $apacheconffiles[]='/etc/apache2/httpd.conf';
196 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
199 foreach ($apacheconffiles as $apacheconffile) {
200 echo('Setting FusionForge Include For Apache...');
201 system("grep \"^Include /etc/gforge/httpd.conf\" $apacheconffile > /dev/null", $ret);
203 system("echo \"Include /etc/gforge/httpd.conf\" >> $apacheconffile");
207 // Create symlink for the wiki plugin.
208 if (!is_dir("/opt/gforge/www/wiki"))
210 symlink ("../plugins/wiki/www/", "/opt/gforge/www/wiki");
213 //#symlink plugin www's
215 chdir("/opt/gforge/www");
216 if (!is_dir("plugins"))
218 system("mkdir -p plugins");
222 if (!is_dir("cvstracker"))
224 symlink ("../../plugins/cvstracker/www/", "cvstracker");
226 if (!is_dir("svntracker"))
228 symlink ("../../plugins/svntracker/www/", "svntracker");
230 if (!is_dir("scmcvs"))
232 symlink ("../../plugins/scmcvs/www", "scmcvs");
234 if (!is_dir("fckeditor"))
236 symlink ("../../plugins/fckeditor/www", "fckeditor");
238 if (!is_dir("blocks"))
240 symlink ("../../plugins/blocks/www", "blocks");
244 chdir("/opt/gforge");
245 system("chown -R root:$args[3] /opt/gforge");
246 system("chmod -R 644 /opt/gforge/");
247 system("cd /opt/gforge && find -type d | xargs chmod 755");
248 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
249 system("chmod -R 755 /opt/gforge/cronjobs/");
250 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
251 system("chmod 755 /opt/gforge/utils/forge_get_config");
252 system("chmod 755 /opt/gforge/utils/manage-apache-config.sh");
253 system("chmod 755 /opt/gforge/utils/manage-translations.sh");
254 system("chmod 755 /opt/gforge/utils/migrate-to-ini-files.sh");
256 if (!is_dir("/etc/gforge"))
258 echo "/etc/gforge didn't exist - error - make sure you've got permission";
261 system("chown -R root:$args[3] /etc/gforge/");
262 system("chmod -R 644 /etc/gforge/");
263 system("cd /etc/gforge && find -type d | xargs chmod 755");
264 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
265 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
266 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$args[1]/\" {} \;");
267 system("echo \"noreply: /dev/null\" >> /etc/aliases");
269 # Generate a random hash for the session_key
270 $hash = md5(microtime());
271 system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
273 # Replace /path/to/gforge to /opt/gforge
274 $config = file_get_contents('/etc/gforge/local.inc');
275 $content = str_replace('/path/to/gforge', '/opt/gforge', $config);
276 file_put_contents('/etc/gforge/local.inc', $content);
279 if (is_dir("/usr/share/jpgraph")) {
280 system("perl -spi -e \"s!^(.sys_path_to_jpgraph)=.*!\\$1='/usr/share/jpgraph';!\" /etc/gforge/local.inc");
281 system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
282 system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
283 system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
284 system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
285 system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
286 system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");