3 [ "${PGDBNAME}" = "" ] && export PGDBNAME
="catalyst"
4 if [ "${APMSROOT}" = "" ]; then
5 if [ -f "dba/update-apms-database" ]; then
8 export APMSROOT
=/usr
/share
/apms
11 [ "${AWLROOT}" = "" ] && export AWLROOT
=/usr
/share
/awl
12 [ "${DUMPDIR}" = "" ] && export DUMPDIR
=/home
/apms
/dump
/${PGDBNAME}
13 [ "${LOCALDIR}" = "" ] && export LOCALDIR
="${DUMPDIR}/local"
14 [ "${DBNAME}" = "" ] && export DBNAME
="apms_${PGDBNAME}"
15 [ "${APMS_APPUSER}" = "" ] && export APMS_APPUSER
="apms_app"
16 [ "${APMS_DBAUSER}" = "" ] && export APMS_DBAUSER
="apms_dba"
19 [ "XtestX`psql -U "${1}" -qAt "${DBNAME}" -c "SELECT usename FROM pg_user
;" 2>/dev/null`" != "XtestX" ]
22 if [ "${DBA}" = "" ]; then
24 # Try a few alternatives for a database user or give up...
25 if try_db_user
"${APMS_DBAUSER}" ; then
26 export DBA
="-U ${APMS_DBAUSER}"
28 if try_db_user
"postgres" ; then
29 export DBA
="-U postgres"
36 [ -n "${DEBUG}" ] && set -o xtrace
38 psql
${DBA} -q ${DBNAME} -f ${APMSROOT}/convert
/rename-usr.sql
40 psql
${DBA} -q ${DBNAME} -f ${AWLROOT}/dba
/schema-management.sql
41 psql
${DBA} -q ${DBNAME} -f ${AWLROOT}/dba
/awl-tables.sql
43 if [ -f "${LOCALDIR}/usr.sql" ]; then
44 psql
${DBA} -q ${DBNAME} -f "${LOCALDIR}/usr.sql
"
46 psql ${DBA} -q ${DBNAME} -f ${APMSROOT}/convert/usr.sql
49 ${APMSROOT}/dba/set-minimum-privileges.sh
51 psql ${DBA} -q ${DBNAME} -f ${APMSROOT}/convert/et-to-upper.sql
52 psql ${DBA} -q ${DBNAME} -f ${APMSROOT}/convert/conversions.sql
53 if [ -f "${APMSROOT}/convert
/specific-
${PGDBNAME}.sql
" ]; then
54 psql ${DBA} -q ${DBNAME} -f ${APMSROOT}/convert/specific-${PGDBNAME}.sql
58 dba/update-apms-database --dbname ${DBNAME} --dbuser ${APMS_DBAUSER} --appuser ${APMS_APPUSER} --owner ${APMS_DBAUSER}