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
24 * along with FusionForge; 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");
155 system("chown -R root:$args[3] /opt/gforge");
156 system("chmod -R 644 /opt/gforge/");
157 system("cd /opt/gforge && find -type d | xargs chmod 755");
158 system("chown -R $args[2]:$args[3] /var/lib/gforge/uploads");
159 system("chmod -R 755 /opt/gforge/cronjobs/");
160 system("chmod 755 /opt/gforge/www/scm/viewvc/bin/cgi/viewvc.cgi");
161 system("chmod 755 /opt/gforge/utils/forge_get_config");
162 system("chmod 755 /opt/gforge/utils/manage-apache-config.sh");
163 system("/opt/gforge/utils/manage-apache-config.sh build");
164 system("chmod 755 /opt/gforge/utils/manage-translations.sh");
165 system("chmod 755 /opt/gforge/utils/migrate-to-ini-files.sh");
167 //#restricted shell for cvs accounts
169 system("cp plugins/scmcvs/bin/cvssh.pl /bin/");
171 system("chmod 755 /bin/cvssh.pl");
173 // Create default location for gforge config files
174 system("mkdir -p /etc/gforge");
175 #if (!is_file("/etc/gforge/local.inc")) {
176 # system("cp etc/local.inc.example /etc/gforge/local.inc");
178 if (!is_file("/etc/gforge/httpd.conf")) {
179 system("cp etc/httpd.conf-opt /etc/gforge/httpd.conf");
181 system("mkdir -p /etc/gforge/httpd.conf.d");
182 $h = opendir ('etc/httpd.conf.d-opt') ;
183 while (false !== ($file = readdir($h))) {
186 && (preg_match ('/^[0-9a-zA-Z_-]+(.conf)?$/', $file)
187 || preg_match ('/^[0-9a-zA-Z_-]+(.inc)?$/', $file))) {
188 if (!is_file("/etc/gforge/httpd.conf.d/$file")) {
189 system("cp etc/httpd.conf.d-opt/$file /etc/gforge/httpd.conf.d");
195 system("cp etc/config.ini-opt /etc/gforge/config.ini");
196 system("cp -rL etc/config.ini.d /etc/gforge/config.ini.d");
198 // Install default configuration files for all plugins.
199 system("mkdir -p /etc/gforge/plugins/");
200 chdir("/opt/gforge/plugins");
201 foreach( glob("*") as $plugin) {
202 $source = "/opt/gforge/plugins/$plugin/etc/plugins/$plugin";
203 if (is_dir($source)) {
204 system("cp -r $source /etc/gforge/plugins/");
208 $apacheconffiles=array();
209 if (is_file('/etc/httpd/conf/httpd.conf')) {
210 $apacheconffiles[]='/etc/httpd/conf/httpd.conf';
211 } elseif (is_file('/opt/csw/apache2/etc/httpd.conf')) {
212 $apacheconffiles[]='/opt/csw/apache2/etc/httpd.conf';
213 } elseif (is_file('/etc/apache2/httpd.conf')) {
214 $apacheconffiles[]='/etc/apache2/httpd.conf';
216 $apacheconffiles[]='/etc/apache2/sites-enabled/000-default';
219 foreach ($apacheconffiles as $apacheconffile) {
220 echo('Setting FusionForge Include For Apache...');
221 system("grep \"^Include $fusionforge_etc_dir/httpd.conf\" $apacheconffile > /dev/null", $ret);
223 system("echo \"Include $fusionforge_etc_dir/httpd.conf\" >> $apacheconffile");
227 // Create symlink for the wiki plugin.
228 if (!is_dir("$fusionforge_src_dir/www/wiki"))
230 symlink ("../plugins/wiki/www/", "$fusionforge_src_dir/www/wiki");
233 //#symlink plugin www's
234 chdir("$fusionforge_src_dir/www");
235 if (!is_dir("plugins"))
237 system("mkdir -p plugins");
241 if (!is_dir("cvstracker"))
243 symlink ("../../plugins/cvstracker/www/", "cvstracker");
245 if (!is_dir("svntracker"))
247 symlink ("../../plugins/svntracker/www/", "svntracker");
249 if (!is_dir("message"))
251 symlink ("../../plugins/message/www/", "message");
253 if (!is_dir("scmcvs"))
255 symlink ("../../plugins/scmcvs/www", "scmcvs");
257 if (!is_dir("fckeditor"))
259 symlink ("../../plugins/fckeditor/www", "fckeditor");
261 if (!is_dir("blocks"))
263 symlink ("../../plugins/blocks/www", "blocks");
265 if (!is_dir("authbuiltin"))
267 symlink ("../../plugins/authbuiltin/www", "authbuiltin");
271 chdir("/opt/gforge");
273 if (!is_dir("/etc/gforge"))
275 echo "/etc/gforge didn't exist - error - make sure you've got permission";
278 system("chown -R root:$args[3] /etc/gforge/");
279 system("chmod -R 644 /etc/gforge/");
280 system("cd /etc/gforge && find -type d | xargs chmod 755");
281 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apacheuser/$args[2]/\" {} \;");
282 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/apachegroup/$args[3]/\" {} \;");
283 system("cd /etc/gforge && find -type f -exec perl -pi -e \"s/gforge\.company\.com/$hostname/\" {} \;");
284 system("echo \"noreply: /dev/null\" >> /etc/aliases");
286 # Generate a random hash for the session_key
287 $hash = md5(microtime());
288 #system("perl -spi -e \"s/sys_session_key = 'foobar'/sys_session_key = '$hash'/\" /etc/gforge/local.inc");
290 # Replace /path/to/gforge to /opt/gforge
291 #$config = file_get_contents('/etc/gforge/local.inc');
292 #$content = str_replace('/path/to/gforge', '/opt/gforge', $config);
293 #file_put_contents('/etc/gforge/local.inc', $content);
296 #if (is_dir("/usr/share/jpgraph")) {
297 # system("perl -spi -e \"s!^(.sys_path_to_jpgraph)=.*!\\$1='/usr/share/jpgraph';!\" /etc/gforge/local.inc");
298 # system("perl -spi -e \"s!//(.gantt_title_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
299 # system("perl -spi -e \"s!//(.gantt_title_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
300 # system("perl -spi -e \"s!//(.gantt_title_font_size=.*)!\\$1!\" /etc/gforge/local.inc");
301 # system("perl -spi -e \"s!//(.gantt_task_font_family)='FF_ARIAL';!\\$1='FF_LIBERATION_SANS';!\" /etc/gforge/local.inc");
302 # system("perl -spi -e \"s!//(.gantt_task_font_style=.*)!\\$1!\" /etc/gforge/local.inc");
303 # system("perl -spi -e \"s!//(.gantt_task_font_size=.*)!\\$1!\" /etc/gforge/local.inc");