# with FusionForge; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-PG_VERSIONS="8.2 8.3 8.4 9.0 9.1"
+PG_VERSIONS="8.3 8.4 9.0 9.1"
msg(){
GREEN="\e[01;32m"
# Fedora9 (an maybe newer) requires running initdb
if [ "$pgservice" = '/etc/init.d/postgresql' ]
then
- if [ -d /var/lib/pgsql/data/base ]
+ if [ ! -d /var/lib/pgsql/data/base ]
then
service postgresql initdb &>/dev/null
fi
fi
}
-# Where the tsearch sql config file is
-find_tsearch(){
- tsearchfile="/usr/share/pgsql/contrib/tsearch2.sql"
- for v in $PG_VERSIONS ; do
- tsearchfile="$tsearchfile /usr/share/postgresql/$v/contrib/tsearch2.sql"
- done
- tsearchfile="$tsearchfile /opt/csw/postgresql/share/contrib/tsearch2.sql"
- for i in $tsearchfile
- do
- if [ -f $i ]
- then
- tsearch="$i"
- 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
then
susufix=''
else
- susufix='-'
+ susufix='- -s /bin/sh'
fi
msg green " * Creating $gforge_db Database..."
- su $susufix $gforge_user -c "createdb --encoding UNICODE $gforge_db"
+ su $susufix $gforge_user -c "createdb $dboption --encoding UNICODE $gforge_db"
+
+ # Enable plpgsql language
+ if [ -f /usr/bin/createlang ]
+ then
+ if [ `su -s /bin/sh postgres -c "/usr/bin/createlang -l $gforge_db | grep plpgsql | wc -l"` != 1 ]
+ then
+ su -s /bin/sh postgres -c "/usr/bin/createlang plpgsql $gforge_db"
+ else
+ echo "Procedural language on $gforge_db already enabled"
+ fi
+ else
+ echo "No way found to enable plpgsql on $gforge_db here"
+ fi
- # Detect postgresql version, load tsearch2 for pg < 8.3
- pgv=`postgres --version | cut -d" " -f3`
+ # Detect postgresql version, require at least 8.3
+ pgv=
+ for i in postgres psql ; do
+ if [ "$(type -p $i)" != '' ] ; then
+ pgv=$($i --version | cut -d" " -f3)
+ fi
+ done
+ if [ "$pgv" = '' ] ; then
+ msg red "Error: Can't find command-line PostgreSQL client."
+ exit 2
+ fi
case $pgv in
7.*|8.1*|8.2*)
- msg green " * Loading tsearch2 Database Into $gforge_db DB"
- find_tsearch
- 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'\""
+ msg red " * Unsupported PostgreSQL version; 8.3 or later is required"
+ exit 2
;;
esac
install3_db_debian()
{
- echo "Install 3 db not implemented for debian"
+ export dboption="--template=template0"
+ install3_db
}
install3_db_ubuntu()
{
- echo "Install 3 db not implemented for ubuntu"
+ export dboption="--template=template0"
+ install3_db
}
install3_db_unknown()