2 # FusionForge Installation Dependency Setup
4 # Copyright 2006 GForge, LLC
5 # Copyright 2011 Christian Bayle <bayle@debian.org>
6 # http://fusionforge.org/
10 # This file is part of GInstaller, it is called by install.sh.
12 # FusionForge is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # FusionForge is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along
23 # with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 echo "$RED $2 $NORMAL"
35 echo "$GREEN $2 $NORMAL"
47 msg red "Validating arguments: FAIL"
48 msg red "Usage: $0 fusionforge.org apacheuser apachegroup"
51 msg green "Running install2_files $hostname $apacheuser $apachegroup"
54 CHECK=`echo $hostname | grep -E "[^[:alnum:]\-]"`
57 msg green "Validating hostname: OK";
59 msg red "Validating hostname: FAIL invalid hostname"
62 if ! getent passwd $apacheuser > /dev/null
64 msg red "Invalid apache user"
67 msg green "Apache user $apacheuser exists"
70 if ! getent group $apachegroup > /dev/null
72 msg red "Invalid apache group"
75 msg green "Apache group $apachegroup exists"
78 if [ -z "$fusionforge_dir" ] ; then msg red "fusionforge_dir not set" ; exit 4 ; fi
79 if [ -z "$fusionforge_data_dir" ] ; then msg red "fusionforge_data_dir not set" ; exit 4 ; fi
80 if [ -z "$fusionforge_log_dir" ] ; then msg red "fusionforge_log_dir not set" ; exit 4 ; fi
82 for dir in $fusionforge_dir $fusionforge_data_dir $fusionforge_log_dir
86 if mkdir -p $dir > /dev/null
88 msg green "Creating $dir : OK"
90 msg red "Creating $dir : FAILED"
91 msg red "$dir didn't exist - error - make sure you've got permission"
97 if [ "$fusionforge_dir" != "$fusionforge_src_dir" ]
99 cp -r * $fusionforge_dir
102 mkdir -p $fusionforge_data_dir/uploads
103 mkdir -p $fusionforge_data_dir/scmtarballs
104 mkdir -p $fusionforge_data_dir/scmsnapshots
105 mkdir -p $fusionforge_data_dir/scmrepos/svn
106 mkdir -p $fusionforge_data_dir/scmrepos/cvs
108 mkdir -p $fusionforge_data_dir/etc
109 touch $fusionforge_data_dir/etc/httpd.vhosts
111 mkdir -p $fusionforge_data_dir/homedirs
112 mkdir -p /home/groups
113 if [ ! -L $fusionforge_data_dir/homedirs/groups ]
115 ln -s /home/groups $fusionforge_data_dir/homedirs/groups
118 if [ ! -L /scmrepos ]
120 ln -s $fusionforge_data_dir/scmrepos /scmrepos
123 # Create the old symlink /svnroot for compatibility.
126 ln -s $fusionforge_data_dir/scmrepos/svn /svnroot
129 # Create the old symlink /cvsroot for compatibility.
132 ln -s $fusionforge_data_dir/scmrepos/cvs /cvsroot
135 # Create default dumps dir
136 mkdir -p $fusionforge_data_dir/dumps
139 chown -R root:$apachegroup $fusionforge_dir
140 chmod -R 644 $fusionforge_dir
141 chmod 755 $fusionforge_dir/install*
142 cd $fusionforge_dir && find -type d | xargs chmod 755
143 chown -R $apacheuser:$apachegroup $fusionforge_data_dir/uploads
144 chmod -R 755 $fusionforge_dir/cronjobs/
145 chmod 755 $fusionforge_dir/www/scm/viewvc/bin/cgi/viewvc.cgi
146 chmod 755 $fusionforge_dir/utils/forge_get_config
147 chmod 755 $fusionforge_dir/utils/forge_set_password
148 chmod 755 $fusionforge_dir/utils/forge_run_job
149 chmod 755 $fusionforge_dir/utils/forge_run_plugin_job
150 chmod 755 $fusionforge_dir/plugins/*/cronjobs/*
151 find $fusionforge_dir -type f -name "*.sh" -exec chmod 755 {} \;
152 $fusionforge_dir/utils/manage-apache-config.sh build
154 #restricted shell for cvs accounts
155 cp $fusionforge_dir/plugins/scmcvs/bin/cvssh.pl /bin/
156 chmod 755 /bin/cvssh.pl
158 # Create default location for gforge config files
159 # TODO BEGIN : could this be replaced by $fusionforge_dir/utils/manage-apache-config.sh install ?
160 mkdir -p $fusionforge_etc_dir
161 if [ ! -f $fusionforge_etc_dir/httpd.conf ]
163 cp $fusionforge_dir/etc/httpd.conf-opt $fusionforge_etc_dir/httpd.conf
165 mkdir -p $fusionforge_etc_dir/httpd.conf.d
167 ls $fusionforge_dir/etc/httpd.conf.d-opt/[0-9a-zA-Z_-]*.conf $fusionforge_dir/etc/httpd.conf.d-opt/[0-9a-zA-Z_-]*.inc | while read file
169 cp $file $fusionforge_etc_dir/httpd.conf.d/
172 cp $fusionforge_dir/etc/config.ini-opt $fusionforge_etc_dir/config.ini
173 cp -rL $fusionforge_dir/etc/config.ini.d $fusionforge_etc_dir/
176 # Install default configuration files for all plugins.
177 mkdir -p $fusionforge_etc_dir/plugins/
179 cd $fusionforge_dir/plugins
180 find $fusionforge_dir/plugins -maxdepth 1 -type d| while read plugdir
182 plugin=`basename $plugdir`
183 if [ -d $fusionforge_dir/plugins/$plugin/etc/plugins/$plugin ]
185 cp -r $fusionforge_dir/plugins/$plugin/etc/plugins/$plugin $fusionforge_etc_dir/plugins/
189 for file in /opt/csw/apache2/etc/httpd.conf /etc/apache2/httpd.conf /etc/apache2/apache2.conf
193 msg green 'Setting FusionForge Include For Apache...'
194 if ! grep -q "^Include $fusionforge_etc_dir/httpd.conf" $file > /dev/null 2>&1
196 echo "Include $fusionforge_etc_dir/httpd.conf" >> $file
200 if [ -f /etc/httpd/conf/httpd.conf ]
202 if [ ! -f /etc/httpd/conf.d/gforge.conf ]
204 echo "Include $fusionforge_etc_dir/httpd.conf" > /etc/httpd/conf.d/gforge.conf
206 if grep -q "^Include $fusionforge_etc_dir/httpd.conf" /etc/httpd/conf/httpd.conf > /dev/null 2>&1
208 echo "Remove include from /etc/httpd/conf/httpd.conf"
209 perl -pi -e "s!^Include $fusionforge_etc_dir/httpd.conf!!" /etc/httpd/conf/httpd.conf
213 # Create symlink for the wiki plugin.
214 if [ ! -d $fusionforge_src_dir/www/wiki ]
216 ln -s ../plugins/wiki/www/ $fusionforge_src_dir/www/wiki
219 # symlink plugin www's
220 cd $fusionforge_src_dir/www
221 if [ ! -d "plugins" ]
225 cd $fusionforge_src_dir/www/plugins
226 for plugin in cvstracker svntracker message scmcvs fckeditor blocks authbuiltin mantis mediawiki online_help projects_hierarchy quota_management
228 if [ ! -L "$plugin" ]
230 if [ -d ../../plugins/$plugin/www/ ]
232 ln -s ../../plugins/$plugin/www/ $plugin
234 msg red "TARGET DIR ../../plugins/$plugin/www/ doesn't exist for plugin $plugin"
240 if [ ! -d $fusionforge_etc_dir ]
242 msg red "$fusionforge_etc_dir didn't exist - error - make sure you've got permission"
246 chown -R root:$apachegroup $fusionforge_etc_dir
247 chmod -R 644 $fusionforge_etc_dir
248 cd $fusionforge_etc_dir && find -type d | xargs chmod 755
249 cd $fusionforge_etc_dir && find -type f -exec perl -pi -e "s/apacheuser/$apacheuser/" {} \;
250 cd $fusionforge_etc_dir && find -type f -exec perl -pi -e "s/apachegroup/$apachegroup/" {} \;
251 cd $fusionforge_etc_dir && find -type f -exec perl -pi -e "s/gforge.company.com/$hostname/" {} \;
252 echo "noreply: /dev/null" >> /etc/aliases
255 install2_files_redhat()
257 install2_files $1 apache apache
260 install2_files_suse()
262 install2_files $1 wwwrun www
265 install2_files_ubuntu()
267 install2_files $1 www-data www-data
270 install2_files_debian()
272 install2_files $1 www-data www-data
275 install2_files_unknown()
277 echo "Only Debian, Ubuntu, Red Hat, Fedora or CentOS and OpenSUSE are supported by this script.";
278 echo "See INSTALL for normal installation";