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");
154 system("chown -R root:$args[3] /opt/gforge");
155 system("chmod -R 644 /opt/gforge/");
156 system("cd /opt/gforge && find -type d | xargs chmod 755");
157 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
158 system("chmod -R 755 /opt/gforge/cronjobs/");
159 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
160 system("chmod 755 /opt/gforge/utils/forge_get_config");
161 system("chmod 755 /opt/gforge/utils/manage-apache-config.sh");
162 system("/opt/gforge/utils/manage-apache-config.sh build");
163 system("chmod 755 /opt/gforge/utils/manage-translations.sh");
164 system("chmod 755 /opt/gforge/utils/migrate-to-ini-files.sh");
166 //#restricted shell for cvs accounts
168 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
170 system("chmod 755 /bin/cvssh.pl");
172 // Create default location for gforge config files
173 system("mkdir -p /etc/gforge");
174 #if (!is_file("/etc/gforge/local.inc")) {
175 # system("cp etc/local.inc.example /etc/gforge/local.inc");
177 if (!is_file("/etc/gforge/httpd.conf")) {
178 system("cp etc/httpd.conf-opt /etc/gforge/httpd.conf");
180 system("mkdir -p /etc/gforge/httpd.conf.d");
181 $h = opendir ('etc/httpd.conf.d-opt') ;
182 while (false !== ($file = readdir($h))) {
185 && (preg_match ('/^[0-9a-zA-Z_-]+(.conf)?$/', $file)
186 || preg_match ('/^[0-9a-zA-Z_-]+(.inc)?$/', $file))) {
187 if (!is_file("/etc/gforge/httpd.conf.d/$file")) {
188 system("cp etc/httpd.conf.d-opt/$file /etc/gforge/httpd.conf.d");
194 system("cp etc/config.ini-opt /etc/gforge/config.ini");
195 system("cp -rL etc/config.ini.d /etc/gforge/config.ini.d");
197 // Install default configuration files for all plugins.
198 system("mkdir -p /etc/gforge/plugins/");
199 chdir("/opt/gforge/plugins");
200 foreach( glob("*") as $plugin) {
201 $source = "/opt/gforge/plugins/$plugin/etc/plugins/$plugin";
202 if (is_dir($source)) {
203 system("cp -r $source /etc/gforge/plugins/");
207 $apacheconffiles=array();
208 if (is_file('/etc/httpd/conf/httpd.conf')) {
209 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
210 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
211 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
212 } elseif (is_file('/etc/apache2/httpd.conf')) {
213 $apacheconffiles[]='/etc/apache2/httpd.conf';
215 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
218 foreach ($apacheconffiles as $apacheconffile) {
219 echo('Setting FusionForge Include For Apache...');
220 system("grep \"^Include $fusionforge_etc_dir/httpd.conf\" $apacheconffile > /dev/null", $ret);
222 system("echo \"Include $fusionforge_etc_dir/httpd.conf\" >> $apacheconffile");
226 // Create symlink for the wiki plugin.
227 if (!is_dir("$fusionforge_src_dir/www/wiki"))
229 symlink ("../plugins/wiki/www/", "$fusionforge_src_dir/www/wiki");
232 //#symlink plugin www's
233 chdir("$fusionforge_src_dir/www");
234 if (!is_dir("plugins"))
236 system("mkdir -p plugins");
240 if (!is_dir("cvstracker"))
242 symlink ("../../plugins/cvstracker/www/", "cvstracker");
244 if (!is_dir("svntracker"))
246 symlink ("../../plugins/svntracker/www/", "svntracker");
248 if (!is_dir("message"))
250 symlink ("../../plugins/message/www/", "message");
252 if (!is_dir("scmcvs"))
254 symlink ("../../plugins/scmcvs/www", "scmcvs");
256 if (!is_dir("fckeditor"))
258 symlink ("../../plugins/fckeditor/www", "fckeditor");
260 if (!is_dir("blocks"))
262 symlink ("../../plugins/blocks/www", "blocks");
264 if (!is_dir("authbuiltin"))
266 symlink ("../../plugins/authbuiltin/www", "authbuiltin");
270 chdir("/opt/gforge");
272 if (!is_dir("/etc/gforge"))
274 echo "/etc/gforge didn't exist - error - make sure you've got permission";
277 system("chown -R root:$args[3] /etc/gforge/");
278 system("chmod -R 644 /etc/gforge/");
279 system("cd /etc/gforge && find -type d | xargs chmod 755");
280 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
281 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
282 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$hostname/\" {} \;");
283 system("echo \"noreply: /dev/null\" >> /etc/aliases");
285 # Generate a random hash for the session_key
286 $hash = md5(microtime());
287 #system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
289 # Replace /path/to/gforge to /opt/gforge
290 #$config = file_get_contents('/etc/gforge/local.inc');
291 #$content = str_replace('/path/to/gforge', '/opt/gforge', $config);
292 #file_put_contents('/etc/gforge/local.inc', $content);
295 #if (is_dir("/usr/share/jpgraph")) {
296 # system("perl -spi -e \"s!^(.sys_path_to_jpgraph)=.*!\\$1='/usr/share/jpgraph';!\" /etc/gforge/local.inc");
297 # system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
298 # system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
299 # system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
300 # system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
301 # system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
302 # system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");