Upgrading to v1.2.0 involves installing MediaWiki and PHP5.
------------------------------------------------------------

# dumped the gforge database
/etc/init.d/httpd stop

pg_dumpall -U postgres > gforge_all.pg

# Stop everything
/etc/init.d/postgresql stop

# Comment out postgres update from yum.conf
vi /etc/yum.conf

# upgraded php  (and postgres)
# IN /etc/yum.repos.d/CentOS-Base.repo, I enabled centosplus
yum info php postgresql # You should see php 5
yum update php-pear php-mysql php php-pgsql php-devel php-gd potgresql

# Get the postgres contribs (tsearch)
# Installed default to: /usr/share/pgsql/contrib
yum install postgresql-contrib


# Move the old db out of the way
rm -Rf /var/lib/pgsql/data.old
mv /var/lib/pgsql/data /var/lib/pgsql/data.old

# Start postgres
su - postgres
initdb -D /var/lib/pgsql/data
postmaster -D /var/lib/pgsql/data &
exit  # Back to root

psql -U postgres -f gforge_all.pg

#--- CHANGES THAT NEEDED TO BE MADE
#Line 62 - gforge/www/themes/nitrc/Theme.class,
#  - redeclaration of $COLOR_HTMLBOX_TITLE  (combine with higher line)
#
#in /etc/php.ini Update the line:
#allow_call_time_pass_reference = True

# Start httpd
/etc/init.d/httpd start


############### INSTALL TSEARCH2 **********************

# Backup DB again for safety
pg_dump -U gforge gforge > gforge.bak.sql

# Create New MW Schema
# Open psql client and *temporarily make gforge user a superuser
psql -U postgres gforge
	gforge=> alter user gforge superuser;

	# test with: gforge=> select * from pg_shadow;
	\q

psql gforge gforge -c "CREATE SCHEMA mediawiki;"

# Open and edit  /usr/share/pgsql/contrib/tsearch2.sql
  # At the top, change line to read: SET search_path = mediawiki;
vi /usr/share/pgsql/contrib/tsearch2.sql

# Execute tsearch2.sql setup:
psql -U gforge gforge < /usr/share/pgsql/contrib/tsearch2.sql

	# Should say "COMMIT" if successful
	# Test: gforge=> set search_path=mediawiki;

# INSTALL PHP-XML
yum install php-xml

####################  FIX JPGRAPH for PHP5 ############################
# Please insert the following 3 lines starting on the second line
# in /usr/lib/jpgraph/jpgraph.php:

$HTTP_SERVER_VARS = array(
 'PHP_SELF' => $_SERVER['PHP_SELF']
);

		
#Also by setting the following in /etc/php.ini:

         allow_call_time_pass_reference = True

         memory_limit = 64M  #increase from 8M

#######################################################
# AT THIS POINT, UPDATE TO v1.2
# COPY THE TAR FILE TO A GOOD LOCATION SAY ~/nitrc_v1_2_0-2.tar.gz
cd /usr/lib/gforge
tar -zxf ~/nitrc_v1_2_0-2.tar.gz

###################### MEDIAWIKI INSTALL STEPS ########################

# NITRCSRC/gforge/plugins/mwiki/includes/DatabasePostgres.php
# Comment out line 489 ($path .= ", public";)
# Add line 490: $path .= ", mediawiki";
# Search for "Alter User" and eliminate public (paranoia)

# Make mediawiki filder writable:
cd /usr/lib/gforge/plugins/mwiki
chmod a+w config

# Move localsettings out of way to config 
mv LocalSettings.php LocalSettings.php.bk

# WIKI Install Form Fields:
# GO TO: http://SYSTEMNAME/plugins/mwiki/

	Wiki name: NITRC Wiki
	Contact Email: butch@tcg.com
	Lang: En
	Admin Username: nitrc
	PW: SOME_PASSWORD
	<defaults...>
	
	DATABASE CONFIG:
	
	DB type: postgres
	host: localhost
	DB Name: gforge
	db username: gforge
	db password: SOME_PASSWORD
		# NOTE: may need to set gforge postgres pw=SOME_PASSWORD
		gforge=> ALTER USER gforge WITH PASSWORD 'SOME_PASSWORD';

	superuser account: [skip checkbox / uncheck]
	
	Database Port: 5432
	Schema for mediawiki: mediawiki
	Schema for tsearch2: mediawiki

	! INSTALL !

	psql -U postgres gforge
		ALTER USER gforge SET search_path TO public, mediawiki;

# Move LocalSettings to the correct spot
cd /usr/lib/gforge/plugins/mwiki/config/
mv LocalSettings.php ../LocalSettings.php.new
# RESTORE THE CVS COPY OF LOCALSETTINGS.PHP
cd /usr/lib/gforge/plugins/mwiki/
mv LocalSettings.php.bk LocalSettings.php

# adjust postgres config file:
cd /var/lib/pgsql/data/
cp postgresql.conf postgresql.conf.bak
vi postgresql.conf

# turn-on add_missing_from (don't forget to uncomment line)
add_missing_from = on
#save


/etc/init.d/postgresql stop
/etc/init.d/postgresql start

############# PHP.ini Changes ################

# set php.ini option:
cd /etc/
vi php.ini

#enable register_long_arrays in php.ini (set "OFF" to "ON")
register_long_arrays = On

/etc/init.d/httpd stop
/etc/init.d/httpd start


#Run Install DB Upgrade script
# NOTE: DO A SANITY CHECK TO SEE IF A MEDIAWIKI PLUGIN ALREADY EXISTS, AND IF
# SO TAKE IT OUT
psql -U gforge gforge < Upgrade_v1.1.1-1_to_v1.1.1-2.sql
psql -U gforge gforge < Upgrade_v1.1.1-2_to_v1.1.1-3.sql

#Copy media_wiki_scripter.php to /usr/lib/gforge/www,
# run it
# copy results to a psql session
# then remove it

# Copy db_rating_maint.php to /usr/lib/gforge/www/rating, i
# Hit it at http://stage.nitrc.org/rating/db_rating_maint.php
# and let Keith know to implement FR 414

# Fix permissions on uploads
chmod 777 /usr/lib/gforge/plugins/mwiki/images

############# Upgrade OpenSSH 5.0 ############
# Install PAM headers for compilation
wget http://linuxsoft.cern.ch/cern/slc4X/i386/yum/updates/pam-devel-0.77-66.21.i386.rpm
rpm -i pam-devel-0.77-66.21.i386.rpm
# Get and install OpenSSH5.0
wget ftp://ftp.cse.buffalo.edu/pub/OpenBSD/OpenSSH/portable/openssh-5.0p1.tar.gz
tar zxvf openssh-5.0p1.tar.gz
cd openssh-5.0p1
./configure -prefix=/usr/local -sysconfdir=/etc/openssh -with-md5-passwords -with-pam --without-zlib-version-check
make
make install
cp /etc/ssh/* /etc/openssh/
sed 's/^\(GSSAPI.*\)$/#\1/' < /etc/ssh/sshd_config > /etc/openssh/sshd_config
sed 's/^ *\(GSSAPI.*\)$/#\1/' < /etc/ssh/ssh_config > /etc/openssh/ssh_config
cp /etc/pam.d/sshd /etc/pam.d/openssh
# PLEASE NOTE, AFTER YOU RUN THE NEXT LINE, YOU WILL NOT BE ABLE TO SSH TO THE MACHINE UNTIL 
# EVERYTHING IS FIXED.  SO YOU MAY WISH TO OPEN A SECOND SSH CONNECTION JUST IN CASE
# IF YOU HAVE A PROBLEM, CONTACT UCSD IMMEDIATELY
/etc/init.d/sshd stop
yum remove openssh
ln -s /etc/pam.d/openssh /etc/pam.d/sshd
/usr/local/sbin/sshd
echo "echo Starting ssh daemon." >> /etc/rc.local
echo "/usr/local/sbin/sshd" >> /etc/rc.local

# Fix sftp
mkdir /usr/libexec/openssh
ln -s /usr/local/libexec/sftp-server /usr/libexec/openssh/sftp-server

# UPDATE /etc/yum.conf to exclude openssh*.  The line should read:
exclude=postgres* openssh*

# Fix SFTP capability
# Update /etc/openssh/sshd_config, replace the line
Subsystem       sftp    internal-sftp
# And append the following lines (which only allows wheel users to ssh in normally:
ChrootDirectory /export/home/groups

Match group wheel
        ChrootDirectory /

# Now set things up for CVS
mkdir /export/home/groups/bin
mkdir /export/home/groups/lib
mkdir /export/home/groups/tmp
mkdir /export/home/groups/etc
mkdir /export/home/groups/usr
mkdir /export/home/groups/dev
mkdir /export/home/groups/cvsroot
mkdir /export/home/groups/export
mkdir /export/home/groups/state
mkdir /export/home/groups/proc
mkdir /export/home/groups/home

# Append the following lines to /etc/rc.local
echo Setting up SFTP CHROOT binds.
mount --bind /bin /export/home/groups/bin
mount --bind /lib /export/home/groups/lib
mount --bind /tmp /export/home/groups/tmp
mount --bind /etc /export/home/groups/etc
mount --bind /usr /export/home/groups/usr
mount --bind /dev /export/home/groups/dev
mount --bind /cvsroot /export/home/groups/cvsroot
mount --bind /export /export/home/groups/export
mount --bind /state /export/home/groups/state
mount --bind /proc /export/home/groups/proc
mount --bind /home /export/home/groups/home

#
# AFTER installation For one click backup

* Copy the VM to /home/groups and chmod ugo+r to the file

* Add the following lines to root crontab:

#
#       INT NITRC project export job
#
0 2 * * * php -c /usr/lib/gforge/common/backup/php.ini -f /usr/lib/gforge/common/backup/createBackups.php

Bug 3138:
---------
* Make sure /usr/bin/mypserver.sh has the following contents:

#!/bin/sh
/usr/bin/cvs -f `ls -d /cvsroot/* | sed -e '1,$s/.*/--allow-root=&/'` pserver

* Make sure /usr/bin/mypserver.sh is executable (as root):

chmod 755 /usr/bin/mypserver.sh

* Make sure /etc/xinetd.d/cvspserver has the following contents:

service cvspserver
{
        disable             = no
        socket_type         = stream
        protocol            = tcp
        wait                = no
        user                = root
        server              = /usr/bin/mypserver.sh
        server_args         = -f
}

* Restart xinetd
/etc/init.d/xinetd restart

AFTER PROMOTION
---------------
* This is a fun step: For every /cvsroot/*/CVSROOT/config files remove
* any lines that match UseNewInfoFmtStrings=yes

* Also in CVS log scripts fix command-line for post.php

* Make sure that /usr/lib/gforge/plugins/scmcvs/etc/plugins/scmcvs/config.php
* /etc/gforge/plugins/cvstracker/config.php and
* /etc/gforge/plugins/scmcvs/config.php
* has the line:

$cvs_binary_version='1.11';

* and that sys_plugins_path is correctly set to /usr/lib/gforge/plugins

* and that the "sys_default_domain" is correct for the environment

