export pg_hba_dir=/var/lib/pgsql/data/
return
fi
- echo "No pg_hba_dir found"
- echo "exiting without error, but gforge db will not work"
- exit 0
+ echo "No pg_hba_dir found — exiting with error"
+ exit 1
}
# this function export in var pg_version the version of postgresql
return
fi
echo "No database found online on port 5432"
- echo "Couldn't initialize or upgrade gforge database."
- echo "Please see postgresql documentation"
- echo "and run dpkg-reconfigure -plow gforge-db-postgresql"
- echo "once the problem is solved"
- echo "exiting without error, but gforge db will not work"
- echo "right now"
- exit 0
+ echo "Couldn't initialize or upgrade gforge database"
+ exit 1
}
rm -f $cur
cur=$(mktemp /tmp/$pattern)
- perl -e "open F, \"${pg_hba_dir}/pg_hba.conf.gforge-new\" or die \$!; undef \$/; \$l=<F>; \$l=~ s/^### BEGIN GFORGE BLOCK -- DO NOT EDIT.*### END GFORGE BLOCK -- DO NOT EDIT\$/### BEGIN GFORGE BLOCK -- DO NOT EDIT\nlocal $db_name $db_user md5\nlocal $db_name ${db_user}_nss trust\nlocal $db_name ${db_user}_mta md5\n### END GFORGE BLOCK -- DO NOT EDIT/ms; print \$l;" > $cur
+ perl -e "open F, \"${pg_hba_dir}/pg_hba.conf.gforge-new\" or die \$!; undef \$/; \$l=<F>; \$l=~ s/^### BEGIN GFORGE BLOCK -- DO NOT EDIT.*### END GFORGE BLOCK -- DO NOT EDIT\$/### BEGIN GFORGE BLOCK -- DO NOT EDIT\n# user which is used by libnss to access the DB (see \/etc\/nss-pgsql.conf)\nlocal $db_name ${db_user}_nss trust\nlocal $db_name list ident\nlocal $db_name ${db_user}_mta md5\n### END GFORGE BLOCK -- DO NOT EDIT/ms; print \$l;" > $cur
cat $cur > ${pg_hba_dir}/pg_hba.conf.gforge-new
rm -f $cur
if su -s /bin/sh postgres -c "/usr/bin/psql template1" 1> $tmp1 2> $tmp2 <<-EOF
SET LC_MESSAGES = 'C' ;
CREATE USER ${db_user}_mta WITH PASSWORD '${db_user}_mta' ;
+EOF
+ then
+ rm -f $tmp1 $tmp2
+ else
+ echo "Cannot create PostgreSQL user... This shouldn't have happened."
+ echo "Maybe a problem in your PostgreSQL configuration?"
+ echo "Please report a bug to the Debian bug tracking system"
+ echo "Please include the following output:"
+ echo "CREATE USER's STDOUT:"
+ cat $tmp1
+ echo "CREATE USER's STDERR:"
+ cat $tmp2
+ rm -f $tmp1 $tmp2
+ exit 1
+ fi
+ if su -s /bin/sh postgres -c "/usr/bin/psql template1" 1> $tmp1 2> $tmp2 <<-EOF
+SET LC_MESSAGES = 'C' ;
+CREATE USER list ;
EOF
then
rm -f $tmp1 $tmp2
fi
# Create the appropriate database
- tmp1=$(mktemp /tmp/$pattern)
- tmp2=$(mktemp /tmp/$pattern)
if ! exist_db $db_name ; then
+ tmp1=$(mktemp /tmp/$pattern)
+ tmp2=$(mktemp /tmp/$pattern)
if su -s /bin/sh postgres -c "/usr/bin/psql template1" 1> $tmp1 2> $tmp2 <<EOF \
&& [ "$(tail -n +2 $tmp1 | head -1)" = 'CREATE DATABASE' ] ;
SET LC_MESSAGES = 'C' ;
fi
# Install/upgrade the database contents (tables and data)
- /usr/share/gforge/bin/db-upgrade.pl 2>&1 | grep -v ^NOTICE: \
+ /usr/share/gforge/bin/old-db-upgrade.pl 2>&1 | grep -v ^NOTICE: | grep -v ^DETAIL: | grep -v ^WARNING: \
&& p=${PIPESTATUS[0]} \
|| p=${PIPESTATUS[0]}
if [ $p != 0 ] ; then
exit $p
fi
+ /usr/share/gforge/bin/upgrade-db.php
+
if [ "$need_admin_pw" = "true" ] ; then
exit 100
fi