[Fusionforge-commits] r13524 - in trunk/src: . install

Christian Bayle cbayle at fusionforge.org
Sun Jun 19 23:03:51 CEST 2011


Author: cbayle
Date: 2011-06-19 23:03:51 +0200 (Sun, 19 Jun 2011)
New Revision: 13524

Modified:
   trunk/src/install-ng
   trunk/src/install/deps
   trunk/src/install/install2
   trunk/src/install/install3
Log:
Fix various errors


Modified: trunk/src/install/deps
===================================================================
--- trunk/src/install/deps	2011-06-19 08:17:11 UTC (rev 13523)
+++ trunk/src/install/deps	2011-06-19 21:03:51 UTC (rev 13524)
@@ -25,9 +25,9 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 msg(){
-	GREEN="\033[01;32m"
-	NORMAL="\033[00m"
-	RED="\033[01;31m"
+	GREEN=""
+	NORMAL=""
+	RED=""
 	case $1 in
 		red)
 			echo "$RED $2 $NORMAL"
@@ -39,14 +39,22 @@
 }
 
 
-install_redhat() {
-	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
+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
 }
 
-install_debian() {
+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
@@ -59,7 +67,8 @@
 }
 
 # http://www.arklinux.org/
-install_ark() {
+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
@@ -71,7 +80,8 @@
 	msg red "You Must Install htmlpurifier manually."
 }
 
-install_suse() {
+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
 
@@ -92,7 +102,8 @@
 	msg red "You Must Install htmlpurifier manually."
 }
 
-install_opensuse() {
+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
 
@@ -123,7 +134,7 @@
 baseurl = $rpm_repo
 enabled = 0
 protect = 0
-gpgcheck = 0';
+gpgcheck = 0
 END
 	fi
 }
@@ -147,23 +158,23 @@
 #mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
 enabled = 0
 protect = 0
-gpgcheck = 0';
+gpgcheck = 0
 END
 	fi
 }
 
-install_centos(){
-	install_redhat
+deps_centos(){
+	deps_redhat
 }
 
-install_rhel(){
-	install_redhat
+deps_rhel(){
+	deps_redhat
 }
 
-install_fedora(){
-	install_redhat
+deps_fedora(){
+	deps_redhat
 }
 
-install_ubuntu(){
-	install_debian
+deps_ubuntu(){
+	deps_debian
 }

Modified: trunk/src/install/install2
===================================================================
--- trunk/src/install/install2	2011-06-19 08:17:11 UTC (rev 13523)
+++ trunk/src/install/install2	2011-06-19 21:03:51 UTC (rev 13524)
@@ -24,9 +24,9 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 msg(){
-	GREEN="\033[01;32m"
-	NORMAL="\033[00m"
-	RED="\033[01;31m"
+	GREEN=""
+	NORMAL=""
+	RED=""
 	case $1 in
 		red)
 			echo "$RED $2 $NORMAL"
@@ -46,32 +46,38 @@
 	then
 		msg red "Validating arguments: FAIL"
 		msg red "Usage: $0 fusionforge.org apacheuser apachegroup"
-		exit(127);
+		exit 127
 	else
 		msg green "Validating arguments: OK"
 	fi
 
 	CHECK=`echo $hostname | grep -E "[^[:alnum:]\-]"`
-	if [ "$CHECK" != "" ] ; then
+	if [ "$CHECK" != "" ]
+	then
 		msg green "Validating hostname: OK";
 	else
 		msg red "Validating hostname: FAIL invalid hostname"
 	fi
 
-	if getent passwd $apacheuser > /dev/null
+	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
+	if ! getent group $apachegroup > /dev/null
 	then
 		msg red "Invalid apache group"
 	 	exit 3
+	else
+		msg green "Apache group $apachegroup exists"
 	fi
  
-	insscriptdir=`cd \`dirname $0\`; pwd`
-	. $insscriptdir/config
+	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
@@ -104,24 +110,24 @@
 
 	mkdir -p $fusionforge_data_dir/homedirs
 	mkdir -p /home/groups
-	if [ ! -d  $fusionforge_data_dir/homedirs/groups ]
+	if [ ! -L  $fusionforge_data_dir/homedirs/groups ]
 	then
 		ln -s /home/groups $fusionforge_data_dir/homedirs/groups
 	fi
 
-	if [ ! -d  $fusionforge_data_dir/scmrepos ]
+	if [ ! -L  /scmrepos ]
 	then 
 		ln -s $fusionforge_data_dir/scmrepos /scmrepos
 	fi
 
 	# Create the old symlink /svnroot for compatibility.
-	if [ ! -d /svnroot ]
+	if [ ! -L /svnroot ]
 	then 
 		ln -s $fusionforge_data_dir/scmrepos/svn /svnroot
 	fi
 		
 	# Create the old symlink /cvsroot for compatibility.
-	if [ ! -d /cvsroot ]
+	if [ ! -L /cvsroot ]
 	then 
 		ln -s $fusionforge_data_dir/scmrepos/cvs /cvsroot
 	fi
@@ -132,6 +138,7 @@
 	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/
@@ -166,7 +173,7 @@
 	mkdir -p $fusionforge_etc_dir/plugins/
 
 	cd $fusionforge_dir/plugins
-	find $fusionforge_dir/plugins -type d -maxdepth 1 | while read plugdir
+	find $fusionforge_dir/plugins -maxdepth 1 -type d| while read plugdir
 	do
 		plugin=`basename $plugdir`
 		if [ -d $fusionforge_dir/plugins/$plugin/etc/plugins/$plugin ]
@@ -180,7 +187,7 @@
 		if [ -f $file ]
 		then 
 			msg green 'Setting FusionForge Include For Apache...'
-			if ! grep -q "^Include" $fusionforge_etc_dir/httpd.conf $file > /dev/null
+			if ! grep -q "^Include" $fusionforge_etc_dir/httpd.conf $file > /dev/null 2>&1
 			then
 				echo "Include $fusionforge_etc_dir/httpd.conf" >> $file
 			fi
@@ -195,15 +202,17 @@
 
 	# symlink plugin www's
 	cd $fusionforge_src_dir/www
-	if [ ! -d plugins ]
+	if [ ! -d "plugins" ]
 	then
 		mkdir -p plugins
 	fi
 	for plugin in cvstracker svntracker message scmcvs fckeditor blocks authbuiltin
-	if [ ! -d $plugin ]
-	then
-		ln -s ../../plugins/$plugin/www/ $plugin
-	fi
+	do
+		if [ ! -L "$plugin" ]
+		then
+			ln -s ../../plugins/$plugin/www/ $plugin
+		fi
+	done
 
 	cd $fusionforge_dir
 	if [ ! -d $fusionforge_etc_dir ]

Modified: trunk/src/install/install3
===================================================================
--- trunk/src/install/install3	2011-06-19 08:17:11 UTC (rev 13523)
+++ trunk/src/install/install3	2011-06-19 21:03:51 UTC (rev 13524)
@@ -24,15 +24,23 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 msg(){
-	GREEN="\033[01;32m"
-	NORMAL="\033[00m"
-	RED="\033[01;31m"
-	case $1 in
+	GREEN=""
+	NORMAL=""
+	RED=""
+	if [ "$1" = "noreturn" ]
+	then
+		extra="-n"
+		shift
+	else
+		extra=""
+	fi
+	color=$1 ; shift
+	case $color in
 		red)
-			echo "$RED $2 $NORMAL"
+			echo $extra "$RED $1 $NORMAL"
 			;;
 		green)
-			echo "$GREEN $2 $NORMAL"
+			echo $extra "$GREEN $1 $NORMAL"
 			;;
 	esac
 }
@@ -40,11 +48,14 @@
 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) VALUES (currval('users_pk_seq'), 1, 'A'); INSERT INTO pfo_user_role (user_id, role_id) VALUES (currval('users_pk_seq'), 3)\""
+	if [ -f /tmp/fusionforge-use-pfo-rbac ]
+	then
+		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) VALUES (currval('users_pk_seq'), 1, 'A'); INSERT INTO pfo_user_role (user_id, role_id) VALUES (currval('users_pk_seq'), 3)\""
+	else
+		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) VALUES (currval('users_pk_seq'), 1, 'A')\""	
+	fi
 }
 
-msg green "-=# Welcome to FusionForge DB-Installer #=-"
-
 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
@@ -75,12 +86,9 @@
 }
 
 get_config(){
-	insscriptdir=`cd \`dirname $0\`; pwd`
-	. $insscriptdir/config
-
 	if [ ! -d "$fusionforge_src_dir" ]
 	then
-		msg red "Error: GForge folder doesn't exist. Run fusionforge-install-2.php first."
+		msg red "Error: $fusionforge_src_dir folder doesn't exist. Run install2 first."
 		exit 2
 	fi
 }
@@ -92,7 +100,7 @@
 	do
 		if [ -f $pghbafile ]
 		then
-			$pghba="$pghbafile"
+			pghba="$pghbafile"
 		fi
 	done
 	if [ -z "$pghba" ]
@@ -109,7 +117,7 @@
 	do
 		if [ -f $tsearchfile ]
 		then
-			$tsearch="$tsearchfile"
+			tsearch="$tsearchfile"
 		fi
 	done
 	if [ -z "$tsearch" ]
@@ -127,7 +135,7 @@
 	then
 		while test -z "$FFORGE_DB"
 		do
-			msg green "* Enter the Database Name (fusionforge): "
+			msg noreturn green "* Enter the Database Name (fusionforge): "
 			read FFORGE_DB
 		done
 	fi
@@ -138,7 +146,7 @@
 	then
 		while test -z "$FFORGE_USER"
 		do
-			msg green "* Enter the Database Username (gforge): "
+			msg noreturn green "* Enter the Database Username (gforge): "
 			read FFORGE_USER
 		done
 	fi
@@ -176,9 +184,9 @@
 
 	if [ -d /home/$gforge_user ]
 	then
-		$susufix = ''
+		susufix=''
 	else
-		$susufix = '-'
+		susufix='-'
 	fi
 
 	msg green " * Creating $gforge_db Database..."
@@ -205,7 +213,7 @@
 	then
 		while test -z "$FFORGE_ADMIN_USER"
 		do
-			msg green " * Enter the Admin Username (fforgeadmin): "
+			msg noreturn green " * Enter the Admin Username (fforgeadmin): "
 			read FFORGE_ADMIN_USER
 		done
 	fi
@@ -217,15 +225,15 @@
 		retry=5
 		while test -z "$FFORGE_ADMIN_PASSWORD" -a $retry -gt 0
 		do
-			msg green " * Enter the Site Admin Password:"
+			msg noreturn green " * Enter the Site Admin Password:"
 			read -s FFORGE_ADMIN_PASSWORD1
 			if validatePassword "$FFORGE_ADMIN_PASSWORD1"
 			then
-				msg green " * Please enter it again:"
+				msg noreturn green " * Please enter it again:"
 				read -s FFORGE_ADMIN_PASSWORD2
-				if [ "FFORGE_ADMIN_PASSWORD1" == "FFORGE_ADMIN_PASSWORD2" ]
+				if [ "$FFORGE_ADMIN_PASSWORD1" == "$FFORGE_ADMIN_PASSWORD2" ]
 				then
-					FFORGE_ADMIN_PASSWORD=$FFORGE_ADMIN_PASSWORD1
+					FFORGE_ADMIN_PASSWORD="$FFORGE_ADMIN_PASSWORD1"
 				else
 					msg green "Passwords don't match. Please try again."
 				fi
@@ -238,7 +246,7 @@
 			exit 1
 		else
 			create_db_admin_user "$gforge_db" "$admin_user"
-			forge_set_password "$admin_user" "$FFORGE_ADMIN_PASSWORD"
+			$fusionforge_src_dir/utils/forge_set_password "$admin_user" "$FFORGE_ADMIN_PASSWORD"
 		fi
 	fi
 }
@@ -294,7 +302,7 @@
 		return 1
 	fi
         CHECK=`echo $password | grep -E "[[:alnum:]]*"`
-        if [ "$CHECK" == "" ] ; then
+        if [ "$CHECK" == "" ]
         then
                 msg red "Password contains invalid characters. Please try again."
 		return 2
@@ -304,6 +312,7 @@
 }
 
 install3(){
+	msg green "-=# Welcome to FusionForge DB-Installer #=-"
 	find_psql_init
 	psql_startdb
 	get_config

Modified: trunk/src/install-ng
===================================================================
--- trunk/src/install-ng	2011-06-19 08:17:11 UTC (rev 13523)
+++ trunk/src/install-ng	2011-06-19 21:03:51 UTC (rev 13524)
@@ -1,4 +1,4 @@
-#!/bin/dash
+#!/bin/sh -e
 #
 # Simple wrapper for FusionForge installation
 #
@@ -16,6 +16,7 @@
 #
 scriptdir=`cd \`dirname $0\`; pwd`
 . $scriptdir/install/detect_os
+. $scriptdir/install/config
 
 hostname=$1
 
@@ -27,10 +28,23 @@
 # Call to detect_os, this will set $type and $distrib
 os=$(detect_os)
 
-if [ -d "/opt/fusionforge" ]
+if [ -d "/opt/gforge" ]
 then
-	mode="update"
-	echo "Upgrading previous installation ...";
+	# If we install in place
+	if [ "`pwd`" == "/opt/gforge" ]
+	then
+		if [ -f "/opt/gforge/install_completed" ]
+		then
+			mode="update"
+			echo "Upgrading previous installation ...";
+		else
+			mode="install"
+			echo "Installing FusionForge ...";
+		fi
+	else
+		mode="update"
+		echo "Upgrading previous installation ...";
+	fi
 else
 	mode="install"
 	echo "Installing FusionForge ...";
@@ -44,17 +58,16 @@
 . $scriptdir/install/install4
 
 echo "Install type = $type"
-if [ "$type" = "redhat" ]
-then
+case $type in 
+	redhat)
 	echo "Running install/install2 "$hostname" apache apache"
 	install2 "$hostname" apache apache
-
-	if [ $mode = "install" ]
+	if [ "$mode" = "install" ]
 	then
 		echo "Running install/install3"
 		install3
 		echo "Running php db/upgrade-db.php"
-		php db/upgrade-db.php
+		cd $scriptdir; php db/upgrade-db.php
 		echo "Running install/install4"
 		install4
 
@@ -76,17 +89,18 @@
 		service crond reload
 	else
 		echo "Running php db/upgrade-db.php"
-		php db/upgrade-db.php
+		cd $scriptdir; php db/upgrade-db.php
 		php utils/normalize_roles.php
 	fi
-elif [ "$type" = "suse" ]
-then
+	;;
+
+	suse)
 	install2 "$hostname" wwwrun www
-
 	if [ $mode = "install" ]
 	then
 		install3
-		php db/upgrade-db.php
+		echo "Running php db/upgrade-db.php"
+		cd $scriptdir; php db/upgrade-db.php
 		install4
 
 		# Post installation fixes.
@@ -112,26 +126,31 @@
 		cp plugins/*/etc/cron.d/* /etc/cron.d/
 		rccron reload
 	else
-		php db/upgrade-db.php
+		echo "Running php db/upgrade-db.php"
+		cd $scriptdir; php db/upgrade-db.php
 	fi
-elif [ $type = "ubuntu" ]
-then
+	;;
+
+	ubuntu)
 	echo "--"
 	echo "For ubuntu, rather use ubuntu $distrib package"
 	echo "SEE https://fusionforge.org/mediawiki/index.php/Installing/UbuntuRepositories"
 	echo "--"
-elif [ $type = "debian" ]
-then
+	;;
+
+	debian)
 	echo "--"
 	echo "For debian, rather use debian $distrib package"
 	echo "SEE https://fusionforge.org/mediawiki/index.php/Installing/DebianRepositories"
 	echo "--"
-else
+	;;
+	
+	*)
 	echo "Only Red Hat, Fedora or CentOS and OpenSUSE are supported by this script.";
 	echo "See INSTALL for normal installation";
-	exit 1;
-fi
+	exit 1
+	;;
+esac
 
-echo "check /etc/gforge/local.inc for ${hostname} specific FusionForge settings"
-echo -e $msg;
-exit 0;
+echo "check /etc/gforge/local.inc for $hostname specific FusionForge settings"
+touch /opt/gforge/install_completed




More information about the Fusionforge-commits mailing list