4 * FusionForge Installation Dependency Setup
6 * Copyright 2006 GForge, LLC
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
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'];
36 echo "Validating arguments ";
37 if (count($args) != 4) {
38 echo "FAIL\n Usage: $args[0] gforge.company.com apacheuser apachegroup\n";
44 echo "Validating hostname ";
45 if (!preg_match("/^([[:alnum:]._-])*$/" , $hostname)) {
46 echo "FAIL\n invalid hostname\n";
51 // #validate apache user
52 //getent passwd $2 > /dev/null
54 //if [ $found_apacheuser -ne 0 ]; then
55 // echo 1>&2 "invalid apache user"
60 exec("getent passwd $args[2] > /dev/null", $arr, $t);
62 echo "invalid apache user\n";
69 // #validate apache group
70 //getent group $3 > /dev/null
71 //found_apachegroup=$?
72 //if [ $found_apachegroup -ne 0 ]; then
73 // echo 1>&2 "invalid apache group"
78 exec("getent group $args[3] > /dev/null", $arr, $t);
80 echo "invalid apache group";
84 echo "Creating /opt/gforge ";
85 system("mkdir -p /opt/gforge");
86 if (!is_dir("/opt/gforge"))
88 echo "FAIL\n /opt/gforge didn't exist - error - make sure you've got permission";
93 echo "Creating /var/lib/gforge ";
94 system("mkdir -p /var/lib/gforge ");
95 if (!is_dir("/var/lib/gforge"))
97 echo "FAIL\n /var/lib/gforge didn't exist - error - make sure you've got permission";
102 echo "Creating /var/log/gforge ";
103 system("mkdir -p /var/log/gforge ");
104 if (!is_dir("/var/log/gforge"))
106 echo "FAIL\n /var/log/gforge didn't exist - error - make sure you've got permission";
111 system("cp -r * /opt/gforge");
113 require_once 'install-common.inc' ;
115 chdir("/var/lib/gforge");
116 system("mkdir -p uploads");
117 system("mkdir -p scmtarballs");
118 system("mkdir -p scmsnapshots");
119 system("mkdir -p scmrepos/svn");
120 system("mkdir -p scmrepos/cvs");
122 system("mkdir -p etc");
123 system("touch etc/httpd.vhosts");
125 //#project vhost space
126 system("mkdir -p homedirs");
127 system("mkdir -p /home/groups");
128 if (!is_dir("homedirs/groups"))
130 symlink("/home/groups", "homedirs/groups");
133 if (!is_dir("/scmrepos"))
135 symlink("$fusionforge_data_dir/scmrepos", "/scmrepos");
138 // Create the old symlink /svnroot for compatibility.
139 if (!is_dir("/svnroot"))
141 symlink("$fusionforge_data_dir/scmrepos/svn", "/svnroot");
144 // Create the old symlink /cvsroot for compatibility.
145 if (!is_dir("/cvsroot"))
147 symlink("$fusionforge_data_dir/scmrepos/cvs", "/cvsroot");
150 // Create default dumps dir
151 system("mkdir -p /var/lib/gforge/dumps");
154 chdir("/opt/gforge");
156 //#restricted shell for cvs accounts
158 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
160 system("chmod 755 /bin/cvssh.pl");
162 // Create default location for gforge config files
163 system("mkdir -p /etc/gforge");
164 if (!is_file("/etc/gforge/local.inc")) {
165 system("cp etc/local.inc.example /etc/gforge/local.inc");
167 if (!is_file("/etc/gforge/httpd.conf")) {
168 system("cp etc/httpd.conf-opt /etc/gforge/httpd.conf");
170 system("mkdir -p /etc/gforge/httpd.conf.d");
171 $h = opendir ('etc/httpd.conf.d-opt') ;
172 while (false !== ($file = readdir($h))) {
175 && (preg_match ('/^[0-9a-zA-Z_-]+(.conf)?$/', $file)
176 || preg_match ('/^[0-9a-zA-Z_-]+(.inc)?$/', $file))) {
177 if (!is_file("/etc/gforge/httpd.conf.d/$file")) {
178 system("cp etc/httpd.conf.d-opt/$file /etc/gforge/httpd.conf.d");
184 system("cp etc/config.ini-opt /etc/gforge/config.ini");
185 system("cp -rL etc/config.ini.d /etc/gforge/config.ini.d");
187 // Install default configuration files for all plugins.
188 system("mkdir -p /etc/gforge/plugins/");
189 chdir("/opt/gforge/plugins");
190 foreach( glob("*") as $plugin) {
191 $source = "/opt/gforge/plugins/$plugin/etc/plugins/$plugin";
192 if (is_dir($source)) {
193 system("cp -r $source /etc/gforge/plugins/");
197 $apacheconffiles=array();
198 if (is_file('/etc/httpd/conf/httpd.conf')) {
199 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
200 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
201 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
202 } elseif (is_file('/etc/apache2/httpd.conf')) {
203 $apacheconffiles[]='/etc/apache2/httpd.conf';
205 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
208 foreach ($apacheconffiles as $apacheconffile) {
209 echo('Setting FusionForge Include For Apache...');
210 system("grep \"^Include $fusionforge_etc_dir/httpd.conf\" $apacheconffile > /dev/null", $ret);
212 system("echo \"Include $fusionforge_etc_dir/httpd.conf\" >> $apacheconffile");
216 // Create symlink for the wiki plugin.
217 if (!is_dir("$fusionforge_src_dir/www/wiki"))
219 symlink ("../plugins/wiki/www/", "$fusionforge_src_dir/www/wiki");
222 //#symlink plugin www's
223 chdir("$fusionforge_src_dir/www");
224 if (!is_dir("plugins"))
226 system("mkdir -p plugins");
230 if (!is_dir("cvstracker"))
232 symlink ("../../plugins/cvstracker/www/", "cvstracker");
234 if (!is_dir("svntracker"))
236 symlink ("../../plugins/svntracker/www/", "svntracker");
238 if (!is_dir("scmcvs"))
240 symlink ("../../plugins/scmcvs/www", "scmcvs");
242 if (!is_dir("fckeditor"))
244 symlink ("../../plugins/fckeditor/www", "fckeditor");
246 if (!is_dir("blocks"))
248 symlink ("../../plugins/blocks/www", "blocks");
252 chdir("/opt/gforge");
253 system("chown -R root:$args[3] /opt/gforge");
254 system("chmod -R 644 /opt/gforge/");
255 system("cd /opt/gforge && find -type d | xargs chmod 755");
256 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
257 system("chmod -R 755 /opt/gforge/cronjobs/");
258 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
259 system("chmod 755 /opt/gforge/utils/forge_get_config");
260 system("chmod 755 /opt/gforge/utils/manage-apache-config.sh");
261 system("chmod 755 /opt/gforge/utils/manage-translations.sh");
262 system("chmod 755 /opt/gforge/utils/migrate-to-ini-files.sh");
264 if (!is_dir("/etc/gforge"))
266 echo "/etc/gforge didn't exist - error - make sure you've got permission";
269 system("chown -R root:$args[3] /etc/gforge/");
270 system("chmod -R 644 /etc/gforge/");
271 system("cd /etc/gforge && find -type d | xargs chmod 755");
272 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
273 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
274 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$hostname/\" {} \;");
275 system("echo \"noreply: /dev/null\" >> /etc/aliases");
277 # Generate a random hash for the session_key
278 $hash = md5(microtime());
279 system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
281 # Replace /path/to/gforge to /opt/gforge
282 $config = file_get_contents('/etc/gforge/local.inc');
283 $content = str_replace('/path/to/gforge', '/opt/gforge', $config);
284 file_put_contents('/etc/gforge/local.inc', $content);
287 if (is_dir("/usr/share/jpgraph")) {
288 system("perl -spi -e \"s!^(.sys_path_to_jpgraph)=.*!\\$1='/usr/share/jpgraph';!\" /etc/gforge/local.inc");
289 system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
290 system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
291 system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
292 system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
293 system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
294 system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");