From: dbs Date: Sun, 27 Jul 2008 19:04:17 +0000 (+0000) Subject: Apply patch from Aaron S. Joyner to improve user friendliness of database build script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=88643d65fec0d24ba17fea488c59ed559c41d2f9;p=Evergreen.git Apply patch from Aaron S. Joyner to improve user friendliness of database build script - validate that the fts-config.sql script exists for the specified database version - if it does not, detect the latest available version, warn the user, suggest aborting, offer to continue w/ the latest available version - rework call of psql to avoid PGPASSWORD on the command line, visible via ps - warn user if psql fails attempting to import any of these files for reasons such as couldn't connect, or file not found (not sql script errors) - provide commented out option to fail on sql script errors, for future convenience when the scripts run cleanly w/o errors - limit line length to 80 characters (a nearly unbreakable habit from work) - remove database version entirely from the user interface, down to build-db.sh. This makes minor removals from: - install.sh - config.sh - install.conf.default - Open-ILS/src/Makefile - Open-ILS/src/extras/import/build-oils-db.sh - implement automatic detection of PostgreSQL database version - abort if we can not detect the db version, providing the user with our best guess (it's probably not going to be, but oh well) - maintain fallback in the case of missing fts-config.sql for specific db version, with big shiny warnings adapted to the autodetection - abort if no fts-config.sql files exist Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Aaron S. Joyner git-svn-id: svn://svn.open-ils.org/ILS/trunk@10156 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/Makefile b/Open-ILS/src/Makefile index 98bbe970f5..5f0a4b47b8 100644 --- a/Open-ILS/src/Makefile +++ b/Open-ILS/src/Makefile @@ -177,7 +177,7 @@ storage-bootstrap: @echo "Type control-c to avoid destroying all of the data. Type enter to continue..." @echo "" @read X; - ./extras/import/build-oils-db.sh $(DBDRVR) $(DBHOST) $(DBPORT) $(DBNAME) $(DBUSER) $(DBPW) $(DBVER) + ./extras/import/build-oils-db.sh $(DBDRVR) $(DBHOST) $(DBPORT) $(DBNAME) $(DBUSER) $(DBPW) # ----------------------------------------------------------------------------------- diff --git a/Open-ILS/src/extras/import/build-oils-db.sh b/Open-ILS/src/extras/import/build-oils-db.sh index 691ce9fe95..170e05ea17 100755 --- a/Open-ILS/src/extras/import/build-oils-db.sh +++ b/Open-ILS/src/extras/import/build-oils-db.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ "_$4" == "_" ]; then echo "Usage:" - echo " $0 {Open-ILS-driver} {db-host} {db-port} {db-name} {db-user} {db-password} [db-version]" + echo " $0 {Open-ILS-driver} {db-host} {db-port} {db-name} {db-user} {db-password}" exit 1; fi @@ -12,5 +12,5 @@ WD=`dirname $0` echo "cd $WD/../../sql/$1/;" cd $WD/../../sql/$1/; pwd - ./build-db.sh $2 $3 $4 $5 $6 $7 + ./build-db.sh $2 $3 $4 $5 $6 ) diff --git a/Open-ILS/src/sql/Pg/build-db.sh b/Open-ILS/src/sql/Pg/build-db.sh index 6541b40567..cbdac17098 100755 --- a/Open-ILS/src/sql/Pg/build-db.sh +++ b/Open-ILS/src/sql/Pg/build-db.sh @@ -1,38 +1,129 @@ #!/bin/sh -# args: {db-host} {db-port} {db-name} {db-user} {db-password} {db-version} - -# echo "You may be prompted several times for your database password..." - -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 000.english.pg$6.fts-config.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 001.schema.offline.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 002.schema.config.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 002.functions.aggregate.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 002.functions.config.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 005.schema.actors.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 006.schema.permissions.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 010.schema.biblio.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 011.schema.authority.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 020.schema.functions.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 030.schema.metabib.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 040.schema.asset.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 070.schema.container.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 080.schema.money.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 090.schema.action.sql - -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 100.circ_matrix.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 110.hold_matrix.sql - -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 300.schema.staged_search.sql - -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 500.view.cross-schema.sql - -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 800.fkeys.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 900.audit-functions.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 901.audit-tables.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 950.data.seed-values.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 951.data.MODS-xsl.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 952.data.MODS3-xsl.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f 953.data.MODS32-xsl.sql - -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f reporter-schema.sql -PGPASSWORD=$5 PGUSER=$4 PGHOST=$1 PGPORT=$2 PGDATABASE=$3 psql -f extend-reporter.sql + +# --------------------------------------------------------------------------- +# Store command line args for later use +# args: {db-host} {db-port} {db-name} {db-user} {db-password} +# --------------------------------------------------------------------------- +PGHOST=$1 +PGPORT=$2 +PGDATABASE=$3 +PGUSER=$4 +PGPASSWORD=$5 +export PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD + +# --------------------------------------------------------------------------- +# Lookup the database version from the PostgreSQL server. +# --------------------------------------------------------------------------- +DB_VERSION=`psql -qtc 'show server_version;' | xargs | cut -c1,3` +if [ -z "$DB_VERSION" ] || [ `echo $DB_VERSION | grep -c '[^0-9]'` != 0 ]; then + cat <