~ubuntu-branches/ubuntu/trusty/fusionforge/trusty

« back to all changes in this revision

Viewing changes to fusionforge-install-2.php

  • Committer: Bazaar Package Importer
  • Author(s): Roland Mas
  • Date: 2011-04-15 14:55:34 UTC
  • mfrom: (4.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110415145534-mvn1nochufjmw177
Tags: 5.0.3-1
New upstream bugfix release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        define ('RED', "\033[01;31m" );
32
32
 
33
33
        $args = $_SERVER['argv'];
 
34
        $hostname = $args[1];
34
35
 
35
36
        echo "Validating arguments  ";
36
37
        if (count($args) != 4) {
37
 
                echo "FAIL\n  Usage: $args[0]  gforge.company.com  apacheuser  apachegroup\n";
 
38
                echo "FAIL\n  Usage: $args[0] forge.company.com apacheuser apachegroup\n";
38
39
                exit(127);
39
40
        }
40
41
        echo "OK\n";
41
42
 
42
43
        //validate hostname
43
44
        echo "Validating hostname  ";
44
 
        if (!preg_match("/^([[:alnum:]._-])*$/" , $args[1])) {
 
45
        if (!preg_match("/^([[:alnum:]._-])*$/" , $hostname)) {
45
46
                echo "FAIL\n  invalid hostname\n";
46
47
                exit(2);
47
48
        }
138
139
        // Create default dumps dir
139
140
        system("mkdir -p $fusionforge_data_dir/dumps");
140
141
 
141
 
        chdir("$fusionforge_src_dir");
142
 
 
 
142
        chdir($fusionforge_src_dir);
 
143
 
 
144
        // Install apache configuration files.
 
145
        if (is_dir('/etc/httpd/conf.d')) {
 
146
                $apache_conf_dir = '/etc/httpd/conf.d/';
 
147
        } elseif (is_dir('/opt/csw/apache2/etc/httpd/conf.d')) {
 
148
                $apache_conf_dir = '/opt/csw/apache2/etc/httpd/conf.d';
 
149
        } elseif (is_dir('/etc/apache2/conf.d')) {
 
150
                $apache_conf_dir = '/etc/apache2/conf.';
 
151
        } else {
 
152
                echo "WARNING: Unable to find apache config directory, apache files not installed";
 
153
        }
 
154
 
 
155
        if (isset($apache_conf_dir)) {
 
156
                if (!is_file("$apache_conf_dir/fusionforge-httpd.conf")) {
 
157
                        system("cp etc/fusionforge-httpd.conf.example $apache_conf_dir/fusionforge-httpd.conf");
 
158
                        system("perl -pi -e \"s/forge\.company\.com/$hostname/\" $apache_conf_dir/fusionforge-httpd.conf");
 
159
                }
 
160
                if (!is_file("$apache_conf_dir/fusionforge-httpd-ssl.conf")) {
 
161
                        system("cp etc/fusionforge-httpd-ssl.conf.example $apache_conf_dir/fusionforge-httpd-ssl.conf");
 
162
                        system("perl -pi -e \"s/forge\.company\.com/$hostname/\" $apache_conf_dir/fusionforge-httpd-ssl.conf");
 
163
                }
 
164
        }
 
165
        
143
166
        //#restricted shell for cvs accounts
144
167
        //echo "linea 1\n";
145
168
        system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
151
174
        if (!is_file("$fusionforge_etc_dir/local.inc")) {
152
175
                system("cp etc/local.inc.example $fusionforge_etc_dir/local.inc");
153
176
        }
154
 
        if (!is_file("$fusionforge_etc_dir/httpd.conf")) {
155
 
                system("cp etc/gforge-httpd.conf.example $fusionforge_etc_dir/httpd.conf");
156
 
        }
157
177
 
158
178
        system("mkdir -p $fusionforge_etc_dir/httpd.d");
159
179
        system("cp plugins/*/etc/httpd.d/*.conf $fusionforge_etc_dir/httpd.d");
168
188
                }
169
189
        }
170
190
 
171
 
        $apacheconffiles=array();
172
 
        if (is_file('/etc/httpd/conf/httpd.conf')) {
173
 
                $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
174
 
        } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
175
 
                $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
176
 
        } elseif (is_file('/etc/apache2/httpd.conf')) {
177
 
                $apacheconffiles[]='/etc/apache2/httpd.conf';
178
 
        } else {
179
 
                $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
180
 
        }
181
 
 
182
 
        foreach ($apacheconffiles as $apacheconffile) {
183
 
                echo('Setting FusionForge Include For Apache...');
184
 
                system("grep \"^Include $fusionforge_etc_dir/httpd.conf\" $apacheconffile > /dev/null", $ret);
185
 
                if ($ret == 1) {
186
 
                        system("echo \"Include $fusionforge_etc_dir/httpd.conf\" >> $apacheconffile");
187
 
                }
188
 
        }
189
 
 
190
191
        // Create symlink for the wiki plugin.
191
192
        if (!is_dir("$fusionforge_src_dir/www/wiki"))
192
193
        {
236
237
        system("cd $fusionforge_etc_dir && find . -type d | xargs chmod 755");
237
238
        system("cd $fusionforge_etc_dir && find . -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
238
239
        system("cd $fusionforge_etc_dir && find . -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
239
 
        system("cd $fusionforge_etc_dir && find . -type f -exec perl -pi -e \"s/gforge\.company\.com/$args[1]/\" {} \;");
 
240
        system("cd $fusionforge_etc_dir && find . -type f -exec perl -pi -e \"s/gforge\.company\.com/$hostname/\" {} \;");
240
241
        system("echo \"noreply: /dev/null\" >> /etc/aliases");
241
242
 
242
243
// Generate a random hash for the session_key