#!/bin/sh -e # Support for new place for pg_hba.conf # I only try to upgrade on the default cluster if [ -x /usr/bin/pg_lsclusters ] then # We are with new postgresql working with clusters # This is probably not te most elegant way to deal with database # I install or upgrade on the default cluster if it is online # or I quit gently with a big message pg_version=`/usr/bin/pg_lsclusters | grep 5432 | grep online | cut -d' ' -f1` if [ "x$pg_version" != "x" ] then export pg_hba_dir=/etc/postgresql/${pg_version}/main/ else 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 fi else export pg_hba_dir=/etc/postgresql fi # Source debconf library. . /usr/share/debconf/confmodule #DSFHELPER:replace-files# #DSFHELPER:handle-mainconffile# create_mainconffile init_debconf_from_mainconffile #DSFHELPER:get-pw-from-debconf# #DSFHELPER:create-random-pw# #DSFHELPER:common-variables# #DSFHELPER:dbhost-variables# #DSFHELPER:dbpasswd-variables# db_input low gforge/shared/admin_login || true db_fget gforge/shared/admin_password seen || true if [ "$RET" = "false" ]; then if [ "$(get_pw gforge/shared/admin_password high)" = "not-asked" ] ; then db_set gforge/shared/admin_password $(gen_random_pw) db_get gforge/shared/admin_password || true echo "Since you asked not to see all the debconf questions, I generated a random" echo "password for the admin user. It is '${RET}'.\n" ; db_fset gforge/shared/admin_password seen true fi fi #DSFHELPER:host-variables# #DSFHELPER:shellhost-variables# #DSFHELPER:users-variables# #DSFHELPER:lists-variables# #DSFHELPER:downloadhost-variables# #DSFHELPER:groupid-variables# db_input low gforge/shared/skill_list || true db_go || true vars="admin_login admin_password skill_list" update_mainconffile $vars if ! grep -q '^pam_db_user=' /etc/gforge/gforge.conf ; then echo "pam_db_user=gforge_pam" >> /etc/gforge/gforge.conf fi if ! grep -q '^pam_db_pw=' /etc/gforge/gforge.conf ; then pam_db_pw=$(gen_random_pw) cat >> /etc/gforge/gforge.conf <<-EOF pam_db_pw=$pam_db_pw EOF fi propose_update_install ${pg_hba_dir}/pg_hba.conf db_stop