[Fusionforge-commits] r13773 - in branches/Branch_5_1/src: . install

Christian Bayle cbayle at fusionforge.org
Wed Jul 13 16:43:10 CEST 2011


Author: cbayle
Date: 2011-07-13 16:43:10 +0200 (Wed, 13 Jul 2011)
New Revision: 13773

Added:
   branches/Branch_5_1/src/install-ng
   branches/Branch_5_1/src/install/
   branches/Branch_5_1/src/install/config
   branches/Branch_5_1/src/install/deps
   branches/Branch_5_1/src/install/detect_os
   branches/Branch_5_1/src/install/install2
   branches/Branch_5_1/src/install/install3
   branches/Branch_5_1/src/install/install4
Log:
Add from trunk


Added: branches/Branch_5_1/src/install/config
===================================================================
--- branches/Branch_5_1/src/install/config	                        (rev 0)
+++ branches/Branch_5_1/src/install/config	2011-07-13 14:43:10 UTC (rev 13773)
@@ -0,0 +1,6 @@
+#! /bin/sh
+fusionforge_dir=${FUSIONFORGE_DIR:-/opt/gforge}
+fusionforge_src_dir=${FUSIONFORGE_SRC_DIR:-/opt/gforge}
+fusionforge_data_dir=${FUSIONFORGE_DATA_DIR:-/var/lib/gforge}
+fusionforge_log_dir=${FUSIONFORGE_LOG_DIR:-/var/log/gforge}
+fusionforge_etc_dir=${FUSIONFORGE_ETC_DIR:-/etc/gforge}

Added: branches/Branch_5_1/src/install/deps
===================================================================
--- branches/Branch_5_1/src/install/deps	                        (rev 0)
+++ branches/Branch_5_1/src/install/deps	2011-07-13 14:43:10 UTC (rev 13773)
@@ -0,0 +1,180 @@
+#! /bin/sh
+# FusionForge Installation Dependency Setup
+#
+# Copyright 2006 GForge, LLC
+# Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
+# Copyright (C) 2011 Christian Bayle
+# http://fusionforge.org/
+#
+# @version
+#
+# highly inspired from GInstaller
+#
+# FusionForge is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# FusionForge is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with FusionForge; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+msg(){
+	GREEN=""
+	NORMAL=""
+	RED=""
+	case $1 in
+		red)
+			echo "$RED $2 $NORMAL"
+			;;
+		green)
+			echo "$GREEN $2 $NORMAL"
+			;;
+	esac
+}
+
+
+deps_redhat() {
+	type=redhat
+	if [ ! -f /tmp/done_yum ]
+	then
+		set -e
+		addFusionForgeYumRepo
+		addDagRPMForgeYumRepo
+		msg green "Installing packages: Executing YUM. Please wait..."
+		yum --enablerepo=fusionforge --enablerepo=dag-rpmforge  -y --skip-broken install httpd php mailman cvs postgresql postgresql-libs postgresql-server postgresql-contrib perl-URI php-pgsql subversion mod_dav_svn postfix rcs php-gd mod_ssl wget openssh which liberation-fonts php-htmlpurifier php-mbstring php-jpgraph-1.5.2 poppler-utils php-pecl-zip php-pear-HTTP_WebDAV_Server antiword php-pecl-Fileinfo shared-mime-info rsync
+		touch /tmp/done_yum
+		set +e
+	fi
+}
+
+deps_debian() {
+	type=debian
+	msg green "Installing packages: Executing apt-get. Please wait..."
+	apt-get -y install apache2 php5 php5-cli php5-pgsql cvs postgresql postgresql-contrib libipc-run-perl liburi-perl libapache2-svn libapache2-mod-php5 subversion subversion-tools php5-curl curl ssh lsb-release php-htmlpurifier
+	a2enmod headers
+	a2enmod proxy
+	a2enmod ssl
+	a2enmod rewrite
+	a2enmod vhost_alias
+	# TODO: automate next
+	msg red "You Must Install Mailman Manually: apt-get install mailman postfix"
+}
+
+# http://www.arklinux.org/
+deps_ark() {
+	type=debian
+	msg green "Installing packages: Executing apt-get. Please wait..."
+	apt-get update
+	apt-get -y install httpd php mailman cvs postgresql postgresql-libs postgresql-server postgresql-contrib perl-URI php-pgsql subversion subversion-server-httpd postfix rcs mod_ssl wget ssh
+
+	msg green "Restarting PostgreSQL"
+	/sbin/service postgresql restart
+
+	# TODO: automate next
+	msg red "You Must Install htmlpurifier manually."
+}
+
+deps_suse() {
+	type=suse
+	msg green "Installing Packages with yast"
+	yast -i php5 apache2-prefork php mailman cvs postgresql postgresql-libs postgresql-server postgresql-contrib perl-URI php4-pgsql subversion apache-mod_dav_svn ssh postfix rcs php4-gd mod_ssl perl-IPC-Run php4-curl wget subversion-server apache2-mod_php4
+
+	msg green "Fixing php4 installation"
+	cp /usr/lib/apache2-prefork/libphp4.so /usr/lib/apache2/mod_php.so
+
+	msg green "Stopping Apache"
+	/etc/init.d/apache2 stop
+
+	msg green "Restarting PostgreSQL"
+	/etc/init.d/postgresql stop
+	/etc/init.d/postgresql start
+
+	msg green "Starting Apache"
+	/etc/init.d/apache2 start
+
+	# TODO: automate next
+	msg red "You Must Install htmlpurifier manually."
+}
+
+deps_opensuse() {
+	type=suse
+	msg green "Installing Packages with yast"
+	yast -i php5 apache2-prefork apache2-mod_php5 cvs mailman perl-IPC-Run perl-URI php5 php5-curl php5-gd php5-gettext php5-pgsql postfix postgresql postgresql-contrib postgresql-libs postgresql-server rcs openssh subversion subversion-server wget viewvc
+
+	msg green "Restarting PostgreSQL..."
+	rcpostgresql restart
+	msg green "Restarting Apache..."
+	rcapache2 restart
+
+	# TODO: automate next
+	msg red "You Must Install htmlpurifier manually."
+}
+
+addFusionForgeYumRepo() {
+	if [ ! -f "/etc/yum.repos.d/fusionforge.repo" ]
+	then 
+		msg green "Adding Fusionforge YUM repository"
+		if [ -z "$FFORGE_RPM_REPO" ]
+		then 
+			rpm_repo="http://fusionforge.fusionforge.org/rpm/5.1"
+		else
+			rpm_repo="$FFORGE_RPM_REPO"
+		fi
+		cat > /etc/yum.repos.d/fusionforge.repo <<-END
+# Name: FusionForge RPM Repository
+# URL: http://fusionforge.org/
+[fusionforge]
+name = Red Hat Enterprise \$releasever - fusionforge.org
+baseurl = $rpm_repo
+enabled = 0
+protect = 0
+gpgcheck = 0
+END
+	fi
+}
+
+addDagRPMForgeYumRepo() {
+	if [ ! -f "/etc/yum.repos.d/dag-rpmforge.repo" ]
+	then
+		msg green "Adding Dag RPMForge YUM repository" ]
+		if [ -z "$DAG_RPMFORGE_REPO" ]
+		then
+			rpm_repo="http://apt.sw.be/redhat"
+		else
+			rpm_repo="$DAG_RPMFORGE_REPO"
+		fi
+		cat > /etc/yum.repos.d/dag-rpmforge.repo <<-END
+# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
+# URL: http://rpmforge.net/
+[dag-rpmforge]
+name = Red Hat Enterprise \$releasever - RPMforge.net - dag
+baseurl = $rpm_repo/el5/en/\$basearch/dag
+#mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
+enabled = 0
+protect = 0
+gpgcheck = 0
+END
+	fi
+}
+
+deps_centos(){
+	deps_redhat
+}
+
+deps_rhel(){
+	deps_redhat
+}
+
+deps_fedora(){
+	deps_redhat
+}
+
+deps_ubuntu(){
+	deps_debian
+}


Property changes on: branches/Branch_5_1/src/install/deps
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/Branch_5_1/src/install/detect_os
===================================================================
--- branches/Branch_5_1/src/install/detect_os	                        (rev 0)
+++ branches/Branch_5_1/src/install/detect_os	2011-07-13 14:43:10 UTC (rev 13773)
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Simple OS detection script
+#
+# Usage: ./install.sh <hostname>
+#
+# This will install all the fusionforge code in /opt/gforge
+# Configuration is stored in /etc/gforge
+#
+# Currently supported:
+# * Red Hat 5 / CentOS 5
+# * OpenSuSE 11
+#
+# Authors: Christian Bayle <bayle at debian.org>
+#
+
+detect_os(){
+	distrib=""
+	if [ -f "/etc/redhat-release" ]
+	then
+		distrib=`awk '{print $1}' /etc/redhat-release`
+		case $distrib in
+			CentOS)
+				os=centos
+				;;
+			Red)
+				os=rhel
+				;;
+			Fedora)
+				os=fedora
+				;;
+			openSUSE)
+				os=opensuse
+				;;
+			*)
+				os=redhat_unknown
+				;;
+		esac
+	elif [ -f "/etc/SuSE-release" ]
+	then
+        	distrib=`awk '{print $1}' /etc/SuSE-release | head -n 1`
+		if grep -q openSUSE /etc/SuSE-release
+		then
+			os="opensuse"
+		else
+        		os="suse"
+		fi
+	elif [ -f "/etc/ubuntu_version" ]
+	then
+        	distrib=`awk '{print $1}' /etc/ubuntu_version`
+        	os="ubuntu"
+	elif [ -f "/etc/debian_version" ]
+	then
+        	distrib=`awk '{print $1}' /etc/debian_version`
+        	os="debian"
+	else
+		distrib="unknown"
+		os="unknown"
+	fi
+	echo $os
+}


Property changes on: branches/Branch_5_1/src/install/detect_os
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/Branch_5_1/src/install/install2
===================================================================
--- branches/Branch_5_1/src/install/install2	                        (rev 0)
+++ branches/Branch_5_1/src/install/install2	2011-07-13 14:43:10 UTC (rev 13773)
@@ -0,0 +1,248 @@
+#! /bin/sh
+# FusionForge Installation Dependency Setup
+#
+# Copyright 2006 GForge, LLC
+# Copyright 2011 Christian Bayle <bayle at debian.org>
+# http://fusionforge.org/
+#
+# @version
+#
+# This file is part of GInstaller, it is called by install.sh.
+#
+# FusionForge is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# FusionForge is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with FusionForge; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+msg(){
+	GREEN=""
+	NORMAL=""
+	RED=""
+	case $1 in
+		red)
+			echo "$RED $2 $NORMAL"
+			;;
+		green)
+			echo "$GREEN $2 $NORMAL"
+			;;
+	esac
+}
+
+install2_files(){
+	hostname=$1
+	apacheuser=$2
+	apachegroup=$3
+	
+	if [ $# -ne 3 ]
+	then
+		msg red "Validating arguments: FAIL"
+		msg red "Usage: $0 fusionforge.org apacheuser apachegroup"
+		exit 127
+	else
+		msg green "Validating arguments: OK"
+	fi
+
+	CHECK=`echo $hostname | grep -E "[^[:alnum:]\-]"`
+	if [ "$CHECK" != "" ]
+	then
+		msg green "Validating hostname: OK";
+	else
+		msg red "Validating hostname: FAIL invalid hostname"
+	fi
+
+	if ! getent passwd $apacheuser > /dev/null
+	then
+		msg red "Invalid apache user"
+	 	exit 2
+	else
+		msg green "Apache user $apacheuser exists"
+	fi
+
+	if ! getent group $apachegroup > /dev/null
+	then
+		msg red "Invalid apache group"
+	 	exit 3
+	else
+		msg green "Apache group $apachegroup exists"
+	fi
+ 
+	if [ -z "$fusionforge_dir" ] ; then msg red "fusionforge_dir not set" ; exit 4 ; fi
+	if [ -z "$fusionforge_data_dir" ] ; then msg red "fusionforge_data_dir not set" ; exit 4 ; fi
+	if [ -z "$fusionforge_log_dir" ] ; then msg red "fusionforge_log_dir not set" ; exit 4 ; fi
+
+	for dir in $fusionforge_dir $fusionforge_data_dir $fusionforge_log_dir
+	do
+		if [ ! -d "$dir" ]
+		then
+			if mkdir -p $dir > /dev/null
+			then
+				msg green "Creating $dir : OK"
+			else
+				msg red "Creating $dir : FAILED"
+				msg red "$dir didn't exist - error - make sure you've got permission"
+				exit 4
+			fi
+		fi
+	done
+				
+	if [ "$fusionforge_dir" != "$fusionforge_src_dir" ]
+	then
+		cp -r * $fusionforge_dir
+	fi
+
+	mkdir -p $fusionforge_data_dir/uploads
+	mkdir -p $fusionforge_data_dir/scmtarballs
+	mkdir -p $fusionforge_data_dir/scmsnapshots
+	mkdir -p $fusionforge_data_dir/scmrepos/svn
+	mkdir -p $fusionforge_data_dir/scmrepos/cvs
+
+	mkdir -p $fusionforge_data_dir/etc
+	touch $fusionforge_data_dir/etc/httpd.vhosts
+
+	mkdir -p $fusionforge_data_dir/homedirs
+	mkdir -p /home/groups
+	if [ ! -L  $fusionforge_data_dir/homedirs/groups ]
+	then
+		ln -s /home/groups $fusionforge_data_dir/homedirs/groups
+	fi
+
+	if [ ! -L  /scmrepos ]
+	then 
+		ln -s $fusionforge_data_dir/scmrepos /scmrepos
+	fi
+
+	# Create the old symlink /svnroot for compatibility.
+	if [ ! -L /svnroot ]
+	then 
+		ln -s $fusionforge_data_dir/scmrepos/svn /svnroot
+	fi
+		
+	# Create the old symlink /cvsroot for compatibility.
+	if [ ! -L /cvsroot ]
+	then 
+		ln -s $fusionforge_data_dir/scmrepos/cvs /cvsroot
+	fi
+	
+	# Create default dumps dir
+	mkdir -p $fusionforge_data_dir/dumps
+
+	cd $fusionforge_dir
+	chown -R root:$apachegroup $fusionforge_dir
+	chmod -R 644 $fusionforge_dir
+	chmod 755 $fusionforge_dir/install*
+	cd $fusionforge_dir && find -type d | xargs chmod 755
+	chown -R $apacheuser:$apachegroup $fusionforge_data_dir/uploads
+	chmod -R 755 $fusionforge_dir/cronjobs/
+	chmod 755 $fusionforge_dir/www/scm/viewvc/bin/cgi/viewvc.cgi
+	chmod 755 $fusionforge_dir/utils/forge_get_config
+	chmod 755 $fusionforge_dir/utils/forge_set_password
+	find $fusionforge_dir -type f -name "*.sh" -exec chmod 755 {} \;
+	$fusionforge_dir/utils/manage-apache-config.sh build
+
+	#restricted shell for cvs accounts
+	cp $fusionforge_dir/plugins/scmcvs/bin/cvssh.pl /bin/
+	chmod 755 /bin/cvssh.pl
+
+	# Create default location for gforge config files
+	mkdir -p $fusionforge_etc_dir
+	if [ ! -f $fusionforge_etc_dir/httpd.conf ]
+	then
+		cp $fusionforge_dir/etc/httpd.conf-opt $fusionforge_etc_dir/httpd.conf
+	fi
+	mkdir -p $fusionforge_etc_dir/httpd.conf.d
+
+	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
+	do
+		cp $file $fusionforge_etc_dir/httpd.conf.d/
+	done
+
+	cp $fusionforge_dir/etc/config.ini-opt $fusionforge_etc_dir/config.ini
+	cp -rL $fusionforge_dir/etc/config.ini.d $fusionforge_etc_dir/
+
+	# Install default configuration files for all plugins.
+	mkdir -p $fusionforge_etc_dir/plugins/
+
+	cd $fusionforge_dir/plugins
+	find $fusionforge_dir/plugins -maxdepth 1 -type d| while read plugdir
+	do
+		plugin=`basename $plugdir`
+		if [ -d $fusionforge_dir/plugins/$plugin/etc/plugins/$plugin ]
+		then 
+			cp -r $fusionforge_dir/plugins/$plugin/etc/plugins/$plugin $fusionforge_etc_dir/plugins/
+		fi
+	done
+		
+	for file in /opt/csw/apache2/etc/httpd.conf /etc/apache2/httpd.conf
+	do
+		if [ -f $file ]
+		then 
+			msg green 'Setting FusionForge Include For Apache...'
+			if ! grep -q "^Include $fusionforge_etc_dir/httpd.conf" $file > /dev/null 2>&1
+			then
+				echo "Include $fusionforge_etc_dir/httpd.conf" >> $file
+			fi
+		fi
+	done
+	if [ -f /etc/httpd/conf/httpd.conf ]
+	then
+		if [ ! -f /etc/httpd/conf.d/gforge.conf ]
+		then 
+			echo "Include $fusionforge_etc_dir/httpd.conf" > /etc/httpd/conf.d/gforge.conf
+		fi
+		if grep -q "^Include $fusionforge_etc_dir/httpd.conf" /etc/httpd/conf/httpd.conf > /dev/null 2>&1
+		then
+			echo "Remove include from /etc/httpd/conf/httpd.conf"
+			perl -pi -e "s!^Include $fusionforge_etc_dir/httpd.conf!!" /etc/httpd/conf/httpd.conf
+		fi
+	fi
+		
+	# Create symlink for the wiki plugin.
+	if [ ! -d $fusionforge_src_dir/www/wiki ]
+	then
+		ln -s ../plugins/wiki/www/ $fusionforge_src_dir/www/wiki
+	fi
+
+	# symlink plugin www's
+	cd $fusionforge_src_dir/www
+	if [ ! -d "plugins" ]
+	then
+		mkdir -p plugins
+	fi
+	cd $fusionforge_src_dir/www/plugins
+	for plugin in cvstracker svntracker message scmcvs fckeditor blocks authbuiltin
+	do
+		if [ ! -L "$plugin" ]
+		then
+			if [ -d ../../plugins/$plugin/www/ ]
+			then
+				ln -s ../../plugins/$plugin/www/ $plugin
+			else
+				msg red "TARGET DIR ../../plugins/$plugin/www/ doesn't exist for plugin $plugin"
+			fi
+		fi
+	done
+
+	cd $fusionforge_dir
+	if [ ! -d $fusionforge_etc_dir ]
+	then
+		msg red "/etc/gforge didn't exist - error - make sure you've got permission"
+		exit 2
+	fi
+	
+	chown -R root:$apachegroup $fusionforge_etc_dir
+	chmod -R 644 $fusionforge_etc_dir
+	cd $fusionforge_etc_dir && find -type d | xargs chmod 755
+	cd $fusionforge_etc_dir && find -type f -exec perl -pi -e "s/apacheuser/$apacheuser/" {} \;
+	cd $fusionforge_etc_dir && find -type f -exec perl -pi -e "s/apachegroup/$apachegroup/" {} \;
+	cd $fusionforge_etc_dir && find -type f -exec perl -pi -e "s/gforge.company.com/$hostname/" {} \;
+	echo "noreply:	/dev/null" >> /etc/aliases
+}


Property changes on: branches/Branch_5_1/src/install/install2
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/Branch_5_1/src/install/install3
===================================================================
--- branches/Branch_5_1/src/install/install3	                        (rev 0)
+++ branches/Branch_5_1/src/install/install3	2011-07-13 14:43:10 UTC (rev 13773)
@@ -0,0 +1,343 @@
+#! /bin/sh
+# FusionForge Installation Dependency Setup
+#
+# Copyright 2006 GForge, LLC
+# Copyright 2011 Christian Bayle <bayle at debian.org>
+# http://fusionforge.org/
+#
+# @version
+#
+# This file is part of GInstaller, it is called by install.sh.
+#
+# FusionForge is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# FusionForge is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with FusionForge; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+msg(){
+	GREEN=""
+	NORMAL=""
+	RED=""
+	if [ "$1" = "noreturn" ]
+	then
+		extra="-n"
+		shift
+	else
+		extra=""
+	fi
+	color=$1 ; shift
+	case $color in
+		red)
+			echo $extra "$RED $1 $NORMAL"
+			;;
+		green)
+			echo $extra "$GREEN $1 $NORMAL"
+			;;
+	esac
+}
+
+create_db_admin_user(){
+	gforge_db="$1"
+	admin_user="$2"
+	su - postgres -c "psql $gforge_db -c \"INSERT INTO users (user_name, realname, firstname, lastname, email, user_pw, unix_pw, status, theme_id) VALUES ('$admin_user', 'Forge Admin', 'Forge', 'Admin', 'root at localhost.localdomain', 'INVALID', 'INVALID', 'A', 1); INSERT INTO user_group (user_id, group_id, admin_flags, role_id) VALUES (currval('users_pk_seq'), 1, 'A',17); INSERT INTO pfo_user_role (user_id, role_id) VALUES (currval('users_pk_seq'), 3)\""
+}
+
+find_psql_init(){
+	initpsql=""
+	for initpsql in /etc/init.d/postgresql /etc/init.d/postgresql-8.2 /etc/init.d/postgresql-8.3 /etc/init.d/postgresql-8.4 /etc/init.d/cswpostgres
+	do
+		if [ -f $initpsql ]
+		then
+			pgservice=$initpsql
+		fi
+	done
+	if [ -z "$pgservice" ]
+	then
+		exit 1
+	fi
+}
+		
+psql_startdb(){
+	# Fedora9 (an maybe newer) requires running initdb
+	if [ "$pgservice" == '/etc/init.d/postgresql' ]
+	then
+		if [ -d /var/lib/pgsql/data/base ]
+		then
+			service postgresql initdb &>/dev/null
+		fi
+	fi
+
+	# Might fail if it's already running, so we'll ingnore the result
+	$pgservice start
+}
+
+get_config(){
+	if [ ! -d "$fusionforge_src_dir" ]
+	then
+		msg red "Error: $fusionforge_src_dir folder doesn't exist. Run install2 first."
+		exit 2
+	fi
+}
+
+# Where the pghba config file is
+find_pghba(){
+	pghbafile=""
+	for pghbafile in /var/lib/pgsql/data/pg_hba.conf /etc/postgresql/8.2/main/pg_hba.conf /etc/postgresql/8.3/main/pg_hba.conf /etc/postgresql/8.4/main/pg_hba.conf /opt/csw/var/pgdata/pg_hba.conf
+	do
+		if [ -f $pghbafile ]
+		then
+			pghba="$pghbafile"
+		fi
+	done
+	if [ -z "$pghba" ]
+	then
+		msg red "ERROR: Could not find pg_hba.conf file"
+		exit 1
+	fi
+}
+
+# Where the tsearch sql config file is
+find_tsearch(){
+	tsearchfile=""
+	for tsearchfile in /usr/share/pgsql/contrib/tsearch2.sql /usr/share/postgresql/8.2/contrib/tsearch2.sql /usr/share/postgresql/8.3/contrib/tsearch2.sql /usr/share/postgresql/8.4/contrib/tsearch2.sql /opt/csw/postgresql/share/contrib/tsearch2.sql
+	do
+		if [ -f $tsearchfile ]
+		then
+			tsearch="$tsearchfile"
+		fi
+	done
+	if [ -z "$tsearch" ]
+	then
+		msg red "ERROR: Could not find tsearch2.sql file"
+		exit 1
+	fi
+}
+
+forge_save_db_config(){
+
+	if [ -z "$FFORGE_DB" ]
+	then
+		while test -z "$FFORGE_DB"
+		do
+			msg noreturn green "* Enter the Database Name (fusionforge): "
+			read FFORGE_DB
+		done
+	fi
+	gforge_db="$FFORGE_DB"
+	msg green " ...using $gforge_db"
+
+	if [ -z "$FFORGE_USER" ]
+	then
+		while test -z "$FFORGE_USER"
+		do
+			msg noreturn green "* Enter the Database Username (gforge): "
+			read FFORGE_USER
+		done
+	fi
+	gforge_user="$FFORGE_USER"
+	msg green " ...using $gforge_user"
+
+	if [ ! -d "$fusionforge_etc_dir" ]
+	then
+		mkdir $fusionforge_etc_dir
+	fi
+	if [ ! -d "$fusionforge_etc_dir/config.ini.d" ]
+	then
+		mkdir $fusionforge_etc_dir/config.ini.d
+	fi
+	
+	msg green " * Saving database configuration in FForge config file"
+	if [ ! -f "$fusionforge_etc_dir/config.ini.d/rpm-install.ini" ]
+	then
+		cat > $fusionforge_etc_dir/config.ini.d/rpm-install.ini <<-EOF
+; You can edit the values here or move them to other files.
+[core]
+forge_name=FusionForge
+web_host=`hostname -f`
+
+; This file was generated by the RPM installation system.
+EOF
+	fi
+
+	if [ ! -f "$fusionforge_etc_dir/config.ini.d/rpm-install-secrets.ini" ]
+	then
+		cat > $fusionforge_etc_dir/config.ini.d/rpm-install-secrets.ini <<-EOF
+; You can edit the values here or move them to other files.
+; These values should not go into world-readable files!
+
+[core]
+database_host=""
+database_name=$gforge_db
+database_user=$gforge_user
+database_port=5432
+; database_password=""
+
+; This file was generated by the RPM installation system.
+EOF
+	fi
+	msg green " * Saving installation log in /tmp/gforge-import.log"
+}
+
+dropdbifexists()
+{
+	export PATH=$PATH:/usr/share/gforge/bin/:/usr/share/gforge/utils:/opt/gforge/utils
+	database=`FUSIONFORGE_NO_PLUGINS=true forge_get_config database_name`
+	if [ -z "$database" ]
+	then
+        	echo "Forge database name not found"
+        	exit 1
+	else
+		find_psql_init
+		$pgservice stop
+		$pgservice start
+		echo "Droping database $database"
+		su - postgres -c "dropdb -e $database"
+	fi
+}
+
+installandrundb()
+{
+	# USING $gforge_user, $gforge_db, $pghba, $fusionforge_src_dir, $fusionforge_etc_dir, $tsearch, $pgservice, $STDIN, $STDOUT;
+	msg green " * Modifying DB Access Permissions..."
+	
+	if [ ! -f $pghba.fforge.backup ]
+	then 
+		cp $pghba $pghba.fforge.backup
+	fi
+	cat > $pghba <<-EOF
+# FUSIONFORGE
+local all all trust
+EOF
+	msg green " * Restarting PostgreSQL..."
+	$pgservice stop
+	$pgservice start
+
+	msg green " * Creating $gforge_user Group..."
+	/usr/sbin/groupadd $gforge_user;
+
+	msg green " * Creating '$gforge_user' User..."
+	/usr/sbin/useradd -g $gforge_user $gforge_user
+	
+	# Let's give some time for PostgreSQL to start
+	sleep 5 
+
+	msg green " * Creating Database User $gforge_user..."
+	su - postgres -c "createuser -A -R -d -E $gforge_user"
+
+	msg green " * Creating Language..."
+	su - postgres -c "createlang plpgsql template1"
+
+	if [ -d /home/$gforge_user ]
+	then
+		susufix=''
+	else
+		susufix='-'
+	fi
+
+	msg green " * Creating $gforge_db Database..."
+	su $susufix $gforge_user -c "createdb --encoding UNICODE $gforge_db"
+
+	# Detect postgresql version, load tsearch2 for pg < 8.3
+	pgv=`postgres --version | cut -d" " -f3`
+	case $pgv in
+		7.*|8.1*|8.2*)
+			msg green " * Loading tsearch2 Database Into $gforge_db DB"
+			su - postgres -c "psql $gforge_db < $tsearch" >> /tmp/gforge-import.log
+			for table in pg_ts_cfg pg_ts_cfgmap pg_ts_dict pg_ts_parser
+			do
+				su - postgres -c "psql $gforge_db -c \"GRANT ALL on $table TO $gforge_user\";"
+			done
+			su - postgres -c "psql $gforge_db -c \"UPDATE pg_ts_cfg SET locale='en_US.UTF-8' WHERE ts_name='default'\""
+			;;
+	esac
+
+	msg green " * Loading FusionForge DB"
+	su $susufix $gforge_user -c "psql $gforge_db < $fusionforge_src_dir/db/gforge.sql" >> /tmp/gforge-import.log
+
+	msg green " * Running php db/upgrade-db.php"
+        php $fusionforge_src_dir/db/upgrade-db.php >> /tmp/gforge-upgrade.log
+
+
+	if [ -z "$FFORGE_ADMIN_USER" ]
+	then
+		while test -z "$FFORGE_ADMIN_USER"
+		do
+			msg noreturn green " * Enter the Admin Username (fforgeadmin): "
+			read FFORGE_ADMIN_USER
+		done
+	fi
+	admin_user=$FFORGE_ADMIN_USER
+	msg green " ...using $admin_user"
+
+	if [ -z "$FFORGE_ADMIN_PASSWORD" ]
+	then
+		retry=5
+		while test -z "$FFORGE_ADMIN_PASSWORD" -a $retry -gt 0
+		do
+			msg noreturn green " * Enter the Site Admin Password:"
+			read -s FFORGE_ADMIN_PASSWORD1
+			if validatePassword "$FFORGE_ADMIN_PASSWORD1"
+			then
+				msg noreturn green " * Please enter it again:"
+				read -s FFORGE_ADMIN_PASSWORD2
+				if [ "$FFORGE_ADMIN_PASSWORD1" == "$FFORGE_ADMIN_PASSWORD2" ]
+				then
+					FFORGE_ADMIN_PASSWORD="$FFORGE_ADMIN_PASSWORD1"
+				else
+					msg green "Passwords don't match. Please try again."
+				fi
+			fi
+			retry=`expr $retry - 1`
+		done
+		if [ -z "$FFORGE_ADMIN_PASSWORD" ]
+		then
+			msg green "Passwords didn't match! Aborting."
+			exit 1
+		else
+			create_db_admin_user "$gforge_db" "$admin_user"
+			$fusionforge_src_dir/utils/forge_set_password "$admin_user" "$FFORGE_ADMIN_PASSWORD"
+		fi
+	else
+		create_db_admin_user "$gforge_db" "$admin_user"
+		$fusionforge_src_dir/utils/forge_set_password "$admin_user" "$FFORGE_ADMIN_PASSWORD"
+	fi
+}
+
+validatePassword() {
+	password="$1"
+	strlen=`echo "$1" | wc -m`
+	if [ $strlen -le 7 ]
+	then
+		msg red "Password is too short. Please try again"
+		return 1
+	fi
+        CHECK=`echo $password | grep -E "[[:alnum:]]*"`
+        if [ "$CHECK" == "" ]
+        then
+                msg red "Password contains invalid characters. Please try again."
+		return 2
+	else
+		return 0
+        fi
+}
+
+install3_db(){
+	msg green "-=# Welcome to FusionForge DB-Installer #=-"
+	find_psql_init
+	psql_startdb
+	get_config
+	find_pghba
+	find_tsearch
+	forge_save_db_config
+	installandrundb
+	msg green "Done."
+}


Property changes on: branches/Branch_5_1/src/install/install3
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/Branch_5_1/src/install/install4
===================================================================
--- branches/Branch_5_1/src/install/install4	                        (rev 0)
+++ branches/Branch_5_1/src/install/install4	2011-07-13 14:43:10 UTC (rev 13773)
@@ -0,0 +1,37 @@
+#! /bin/sh
+# FusionForge Installation Dependency Setup
+#
+# Copyright 2011 Christian Bayle <bayle at debian.org>
+# http://fusionforge.org/
+#
+# @version
+#
+# This file is part of GInstaller, it is called by install.sh.
+#
+# FusionForge is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# FusionForge is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with FusionForge; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+install4_config(){
+	if [ -f "/etc/gforge/local.inc" ]
+	then
+		PATH=/opt/gforge/utils/:$PATH migrate-to-ini-files.sh
+	fi
+	
+	PATH=/opt/gforge/utils/:$PATH manage-apache-config.sh install
+	
+	ls /etc/gforge/httpd.conf.d/*.generated | while read i
+	do
+		mv $i ${i%%.generated}
+	done
+}


Property changes on: branches/Branch_5_1/src/install/install4
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/Branch_5_1/src/install-ng
===================================================================
--- branches/Branch_5_1/src/install-ng	                        (rev 0)
+++ branches/Branch_5_1/src/install-ng	2011-07-13 14:43:10 UTC (rev 13773)
@@ -0,0 +1,196 @@
+#!/bin/sh
+#
+# Simple wrapper for FusionForge installation
+#
+# Usage: ./install-ng <hostname>
+#
+# This will install all the fusionforge code in /opt/gforge
+# Configuration is stored in /etc/gforge
+#
+# Currently supported:
+# * Red Hat 5 / CentOS 5
+# * OpenSuSE 11 (contributed by Martin Bernreuther)
+#
+# Author: Alain Peyrat <aljeux at free.fr>
+#         Christian Bayle <bayle at debian.org>
+#
+usage(){
+	echo "Usage: $1 [-r|-h|-a|--reinit|--help|--auto] [<hostname>]"
+}
+
+options=`getopt -o rha -l reinit,help,auto -- "$@"`
+
+if [ $? != 0 ] ; then echo "Terminating..." >&2 ; usage $0 ;exit 1 ; fi
+
+eval set -- "$options"
+
+REINIT=false
+AUTO=false
+while true
+do
+    case "$1" in
+        -r|--reinit)    REINIT=true; shift 1;;
+        -h|--help)      usage $0 ; exit 0; shift 1;;
+        -a|--auto)      AUTO=true ; shift 1;;
+	--)		shift 1; break;;
+        *)              break ;;
+    esac
+done
+
+hostname=$1
+
+if [ -z "$hostname" ]
+then
+	hostname=`hostname -f`
+fi
+echo "Using hostname=$hostname"
+
+# Load some script
+scriptdir=`cd \`dirname $0\`; pwd`
+. $scriptdir/install/detect_os
+. $scriptdir/install/config
+
+# Call to detect_os, this will set $type and $distrib
+os=$(detect_os)
+
+# Load deps script and run the appropriate one
+. $scriptdir/install/deps
+deps_$os
+
+# Load install scripts
+. $scriptdir/install/install2
+. $scriptdir/install/install3
+. $scriptdir/install/install4
+
+if $AUTO
+then
+	echo "Using automatic configuration"
+	FFORGE_DB=fforge
+	FFORGE_USER=gforge
+	FFORGE_ADMIN_USER=admin
+	FFORGE_ADMIN_PASSWORD=myadmin
+fi
+
+if $REINIT
+then
+	echo "Reinit the database"
+	rm -f /etc/gforge/install_completed
+	dropdbifexists
+fi
+
+if [ -d "/opt/gforge" ]
+then
+	if [ -f "/etc/gforge/install_completed" ]
+	then
+		mode="update"
+		echo "Upgrading previous installation ...";
+	else
+		mode="install"
+		echo "Installing FusionForge ...";
+	fi
+else
+	mode="install"
+	echo "Installing FusionForge ...";
+fi
+
+echo "Install type = $type"
+case $type in 
+	redhat)
+	echo "Running install2_files "$hostname" apache apache"
+	install2_files "$hostname" apache apache
+	if [ "$mode" = "install" ]
+	then
+		echo "Running install3_db"
+		install3_db
+		echo "Running install4_config"
+		install4_config
+
+		# Post installation fixes.
+		perl -spi -e "s/^#ServerName (.*):80/ServerName $hostname:80/" /etc/httpd/conf/httpd.conf
+		# Disable ssl
+		perl -spi -e "s/^Include/#Include/" /etc/gforge/httpd.conf.d/ssl-on.inc
+
+		chkconfig httpd on
+		chkconfig postgresql on
+		chkconfig iptables off
+
+		service httpd restart
+		service iptables stop
+		msg="IMPORTANT: Service iptables (firewall) disabled, please reconfigure after"
+
+		cp $scriptdir/packaging/cron.d/cron.fusionforge /etc/cron.d
+		cp $scriptdir/plugins/*/etc/cron.d/* /etc/cron.d/
+		service crond reload
+	else
+		echo "Running php db/upgrade-db.php"
+		cd $scriptdir; php db/upgrade-db.php
+		echo "Running php utils/normalize_roles.php"
+		cd $scriptdir; php utils/normalize_roles.php
+	fi
+	;;
+
+	suse)
+	install2_files "$hostname" wwwrun www
+	if [ $mode = "install" ]
+	then
+		echo "Running install3_db"
+		install3_db
+		echo "Running install4_config"
+		install4_config
+
+		# Post installation fixes.
+		#perl -spi -e "s/^#ServerName (.*):80/ServerName $hostname:80/" /etc/apache2/httpd.conf
+
+		chkconfig -s apache2 on
+		chkconfig -s postgresql on
+
+		# Apache settings: modules
+		for m in dav dav_svn authz_svn ssl; do
+			a2enmod $m
+			a2enflag $m
+		done
+		echo "Virtual hosts for ${hostname}:"
+		httpd2 -S -DSSL 2>&1 | grep ${hostname}
+
+		rcapache2 restart
+
+		rcSuSEfirewall2 stop
+		msg="IMPORTANT: Service SuSEfirewall2 stopped, please reconfigure after"
+
+		cp $scriptdir/packaging/cron.d/cron.fusionforge /etc/cron.d
+		cp $scriptdir/plugins/*/etc/cron.d/* /etc/cron.d/
+		rccron reload
+	else
+		echo "Running php db/upgrade-db.php"
+		cd $scriptdir; php db/upgrade-db.php
+		echo "Running php utils/normalize_roles.php"
+		cd $scriptdir; php utils/normalize_roles.php
+	fi
+	;;
+
+	ubuntu)
+	echo "--"
+	echo "For ubuntu, rather use ubuntu $distrib package"
+	echo "SEE https://fusionforge.org/mediawiki/index.php/Installing/UbuntuRepositories"
+	echo "--"
+	;;
+
+	debian)
+	echo "--"
+	echo "For debian, rather use debian $distrib package"
+	echo "SEE https://fusionforge.org/mediawiki/index.php/Installing/DebianRepositories"
+	echo "--"
+	;;
+	
+	*)
+	echo "Only Red Hat, Fedora or CentOS and OpenSUSE are supported by this script.";
+	echo "See INSTALL for normal installation";
+	exit 1
+	;;
+esac
+
+echo "check /etc/gforge/local.inc for $hostname specific FusionForge settings"
+echo "Write INSTALL COMPLETED"
+date >> /etc/gforge/install_completed
+ls -al /etc/gforge/install_completed
+


Property changes on: branches/Branch_5_1/src/install-ng
___________________________________________________________________
Added: svn:executable
   + *




More information about the Fusionforge-commits mailing list