3 # ---------------------------------------------------------------------------
4 # Store command line args for later use
5 # args: {db-host} {db-port} {db-name} {db-user} {db-password} {verbose}
6 # ---------------------------------------------------------------------------
13 export PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD
15 # ---------------------------------------------------------------------------
16 # Lookup the database version from the PostgreSQL server.
17 # ---------------------------------------------------------------------------
18 DB_VERSION=`psql -qtc 'show server_version;' | xargs | cut -c1,3`
19 if [ -z "$DB_VERSION" ] || [ `echo $DB_VERSION | grep -c '[^0-9]'` != 0 ]; then
21 ********************************************************************************
22 * Could not determine the version of PostgreSQL you have installed. Our best *
25 * which didn't make any sense. For assistance, please email *
26 * open-ils-general@list.georgialibraries.org or join #Evergreen on the *
27 * freenode IRC network. *
28 ********************************************************************************
33 # ---------------------------------------------------------------------------
34 # Validate fts-config file is available for specified DB_VERSION.
35 # ---------------------------------------------------------------------------
36 if [ -e "000.english.pg$DB_VERSION.fts-config.sql" ]; then
37 fts_config_file="000.english.pg$DB_VERSION.fts-config.sql"
39 # -------------------------------------------------------------------------
40 # Attempt to auto-detect the latest available config file.
41 # -------------------------------------------------------------------------
43 for i in $(seq 80 99 | sort -rn); do
44 if [ -e "000.english.pg$i.fts-config.sql" ]; then
49 if [ -z "$last_ver" ]; then
51 ********************************************************************************
52 * Cannot locate any configuration files for full text search config. This *
53 * may indicate a problem with your copy of the source files. We attempted to *
54 * find files like 000.english.pg83.fts-config.sql in this directory: *
56 * but were unsuccessful. Aborting. *
57 ********************************************************************************
62 a=$DB_VERSION # preserves the text alignment below, in a cheap fashion
63 b=$last_ver # assuming of course two character DB_VERSION and last_ver
65 ********************************************************************************
66 * There is no configuration for full text search config, for the database *
67 * version you have installed ($a). If you're not really sure why, you should *
68 * proabably press 'Control-C' now, and abort. To continue using the latest *
69 * available version ($b), press enter. For assistance, please email *
70 * open-ils-general@list.georgialibraries.org or join #Evergreen on the *
71 * freenode IRC network. *
72 ********************************************************************************
75 fts_config_file="000.english.pg$last_ver.fts-config.sql"
78 # ---------------------------------------------------------------------------
79 # Import files via psql, warn user on error, suggest abort. SQL scripts
80 # are processed in the ordered listed in sql_file_manifest.
81 # ---------------------------------------------------------------------------
82 cat sql_file_manifest | while read sql_file; do
83 if [ `expr "$sql_file" : "^#"` = 1 ] || [ "$sql_file" = '' ]; then
87 if [ $sql_file = 'FTS_CONFIG_FILE' ]; then
88 sql_file=$fts_config_file
91 # It would be wise to turn this on only if confidence is high that errors in
92 # scripts will result in terminal failures. Currently, there are a couple
93 # that seem benign. --asjoyner
94 # export ON_ERROR_STOP=1
96 export PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD
97 # Hide most of the harmless messages that obscure real problems
98 if [ -z "$VERBOSE" ]; then
99 psql -v eg_version=NULL -f $sql_file 2>&1 | grep -v NOTICE | grep -v "^INSERT"
101 psql -v eg_version=NULL -f $sql_file
105 ********************************************************************************
106 * There was an error with a database configuration file: *
108 * It is very likely that your installation will be unsuccessful because of *
109 * this error. Press Control-C to abort, or press enter to charge ahead. *
110 ********************************************************************************