4 * FusionForge Installation Dependency Setup
6 * Copyright 2006 GForge, LLC
7 * http://fusionforge.org/
11 * This file is part of GInstaller, it is called by install.sh.
13 * FusionForge 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 * FusionForge 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 along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 define ('GREEN', "\033[01;32m" );
29 define ('NORMAL', "\033[00m" );
30 define ('RED', "\033[01;31m" );
32 $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:]._-])*$/" , $hostname)) {
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 require_once 'install-common.inc' ;
114 chdir("/var/lib/gforge");
115 system("mkdir -p uploads");
116 system("mkdir -p scmtarballs");
117 system("mkdir -p scmsnapshots");
118 system("mkdir -p scmrepos/svn");
119 system("mkdir -p scmrepos/cvs");
121 system("mkdir -p etc");
122 system("touch etc/httpd.vhosts");
124 //#project vhost space
125 system("mkdir -p homedirs");
126 system("mkdir -p /home/groups");
127 if (!is_dir("homedirs/groups"))
129 symlink("/home/groups", "homedirs/groups");
132 if (!is_dir("/scmrepos"))
134 symlink("$fusionforge_data_dir/scmrepos", "/scmrepos");
137 // Create the old symlink /svnroot for compatibility.
138 if (!is_dir("/svnroot"))
140 symlink("$fusionforge_data_dir/scmrepos/svn", "/svnroot");
143 // Create the old symlink /cvsroot for compatibility.
144 if (!is_dir("/cvsroot"))
146 symlink("$fusionforge_data_dir/scmrepos/cvs", "/cvsroot");
149 // Create default dumps dir
150 system("mkdir -p /var/lib/gforge/dumps");
153 chdir("/opt/gforge");
155 //#restricted shell for cvs accounts
157 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
159 system("chmod 755 /bin/cvssh.pl");
161 // Create default location for gforge config files
162 system("mkdir -p /etc/gforge");
163 if (!is_file("/etc/gforge/local.inc")) {
164 system("cp etc/local.inc.example /etc/gforge/local.inc");
166 if (!is_file("/etc/gforge/httpd.conf")) {
167 system("cp etc/httpd.conf-opt /etc/gforge/httpd.conf");
169 system("mkdir -p /etc/gforge/httpd.conf.d");
170 $h = opendir ('etc/httpd.conf.d-opt') ;
171 while (false !== ($file = readdir($h))) {
174 && (preg_match ('/^[0-9a-zA-Z_-]+(.conf)?$/', $file)
175 || preg_match ('/^[0-9a-zA-Z_-]+(.inc)?$/', $file))) {
176 if (!is_file("/etc/gforge/httpd.conf.d/$file")) {
177 system("cp etc/httpd.conf.d-opt/$file /etc/gforge/httpd.conf.d");
183 system("cp etc/config.ini-opt /etc/gforge/config.ini");
184 system("cp -rL etc/config.ini.d /etc/gforge/config.ini.d");
186 // Install default configuration files for all plugins.
187 system("mkdir -p /etc/gforge/plugins/");
188 chdir("/opt/gforge/plugins");
189 foreach( glob("*") as $plugin) {
190 $source = "/opt/gforge/plugins/$plugin/etc/plugins/$plugin";
191 if (is_dir($source)) {
192 system("cp -r $source /etc/gforge/plugins/");
196 $apacheconffiles=array();
197 if (is_file('/etc/httpd/conf/httpd.conf')) {
198 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
199 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
200 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
201 } elseif (is_file('/etc/apache2/httpd.conf')) {
202 $apacheconffiles[]='/etc/apache2/httpd.conf';
204 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
207 foreach ($apacheconffiles as $apacheconffile) {
208 echo('Setting FusionForge Include For Apache...');
209 system("grep \"^Include $fusionforge_etc_dir/httpd.conf\" $apacheconffile > /dev/null", $ret);
211 system("echo \"Include $fusionforge_etc_dir/httpd.conf\" >> $apacheconffile");
215 // Create symlink for the wiki plugin.
216 if (!is_dir("$fusionforge_src_dir/www/wiki"))
218 symlink ("../plugins/wiki/www/", "$fusionforge_src_dir/www/wiki");
221 //#symlink plugin www's
222 chdir("$fusionforge_src_dir/www");
223 if (!is_dir("plugins"))
225 system("mkdir -p plugins");
229 if (!is_dir("cvstracker"))
231 symlink ("../../plugins/cvstracker/www/", "cvstracker");
233 if (!is_dir("svntracker"))
235 symlink ("../../plugins/svntracker/www/", "svntracker");
237 if (!is_dir("scmcvs"))
239 symlink ("../../plugins/scmcvs/www", "scmcvs");
241 if (!is_dir("fckeditor"))
243 symlink ("../../plugins/fckeditor/www", "fckeditor");
245 if (!is_dir("blocks"))
247 symlink ("../../plugins/blocks/www", "blocks");
251 chdir("/opt/gforge");
252 system("chown -R root:$args[3] /opt/gforge");
253 system("chmod -R 644 /opt/gforge/");
254 system("cd /opt/gforge && find -type d | xargs chmod 755");
255 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
256 system("chmod -R 755 /opt/gforge/cronjobs/");
257 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
258 system("chmod 755 /opt/gforge/utils/forge_get_config");
259 system("chmod 755 /opt/gforge/utils/manage-apache-config.sh");
260 system("chmod 755 /opt/gforge/utils/manage-translations.sh");
261 system("chmod 755 /opt/gforge/utils/migrate-to-ini-files.sh");
263 if (!is_dir("/etc/gforge"))
265 echo "/etc/gforge didn't exist - error - make sure you've got permission";
268 system("chown -R root:$args[3] /etc/gforge/");
269 system("chmod -R 644 /etc/gforge/");
270 system("cd /etc/gforge && find -type d | xargs chmod 755");
271 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
272 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
273 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$hostname/\" {} \;");
274 system("echo \"noreply: /dev/null\" >> /etc/aliases");
276 # Generate a random hash for the session_key
277 $hash = md5(microtime());
278 system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
280 # Replace /path/to/gforge to /opt/gforge
281 $config = file_get_contents('/etc/gforge/local.inc');
282 $content = str_replace('/path/to/gforge', '/opt/gforge', $config);
283 file_put_contents('/etc/gforge/local.inc', $content);
286 if (is_dir("/usr/share/jpgraph")) {
287 system("perl -spi -e \"s!^(.sys_path_to_jpgraph)=.*!\\$1='/usr/share/jpgraph';!\" /etc/gforge/local.inc");
288 system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
289 system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
290 system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
291 system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
292 system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
293 system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");