Allow in-browse editing of account groups.
[capital-apms.git] / convert / post-load-conversion.sh
blobbcbd7fd2e6ff2994c5de0a5e18dc42e5ed091112
1 #!/bin/sh
3 [ "${PGDBNAME}" = "" ] && export PGDBNAME="catalyst"
4 if [ "${APMSROOT}" = "" ]; then
5 if [ -f "dba/update-apms-database" ]; then
6 export APMSROOT=`pwd`
7 else
8 export APMSROOT=/usr/share/apms
9 fi
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"
18 try_db_user() {
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}"
27 else
28 if try_db_user "postgres" ; then
29 export DBA="-U postgres"
30 else
31 export DBA=""
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"
45 else
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
57 cd ${APMSROOT}
58 dba/update-apms-database --dbname ${DBNAME} --dbuser ${APMS_DBAUSER} --appuser ${APMS_APPUSER} --owner ${APMS_DBAUSER}