awipsadmin->awips

This commit is contained in:
mjames-upc 2018-07-09 14:58:15 -06:00
parent c90e0cb229
commit 849e75caef
29 changed files with 70 additions and 71 deletions

View file

@ -26,8 +26,8 @@ WITH (
OIDS=FALSE OIDS=FALSE
); );
ALTER TABLE cpg_session ALTER TABLE cpg_session
OWNER TO awipsadmin; OWNER TO awips;
GRANT ALL ON TABLE cpg_session TO awipsadmin; GRANT ALL ON TABLE cpg_session TO awips;
GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE cpg_session TO awips; GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE cpg_session TO awips;
GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE cpg_session TO pguser; GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE cpg_session TO pguser;
@ -46,7 +46,7 @@ WITH (
OIDS=FALSE OIDS=FALSE
); );
ALTER TABLE sent_prod_record ALTER TABLE sent_prod_record
OWNER TO awipsadmin; OWNER TO awips;
GRANT ALL ON TABLE sent_prod_record TO awipsadmin; GRANT ALL ON TABLE sent_prod_record TO awips;
GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE sent_prod_record TO awips; GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE sent_prod_record TO awips;
GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE sent_prod_record TO pguser; GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE, TRIGGER ON TABLE sent_prod_record TO pguser;

View file

@ -5,6 +5,6 @@
* *
*/ */
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
CREATE TABLESPACE climate OWNER awipsadmin LOCATION '%{tablespace_dir}%/climate'; CREATE TABLESPACE climate OWNER awips LOCATION '%{tablespace_dir}%/climate';
COMMENT ON TABLESPACE climate IS 'Climate Database tablespace'; COMMENT ON TABLESPACE climate IS 'Climate Database tablespace';
CREATE DATABASE climate OWNER awipsadmin TABLESPACE climate; CREATE DATABASE climate OWNER awips TABLESPACE climate;

View file

@ -20,6 +20,6 @@
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
DROP DATABASE IF EXISTS dc_ob7oax; DROP DATABASE IF EXISTS dc_ob7oax;
DROP TABLESPACE IF EXISTS damcat; DROP TABLESPACE IF EXISTS damcat;
CREATE TABLESPACE damcat OWNER awipsadmin LOCATION '%{tablespace_dir}%/damcat'; CREATE TABLESPACE damcat OWNER awips LOCATION '%{tablespace_dir}%/damcat';
COMMENT ON TABLESPACE damcat IS 'DAMCAT Database tablespace'; COMMENT ON TABLESPACE damcat IS 'DAMCAT Database tablespace';
CREATE DATABASE dc_ob7oax OWNER awipsadmin TABLESPACE damcat; CREATE DATABASE dc_ob7oax OWNER awips TABLESPACE damcat;

View file

@ -20,6 +20,6 @@
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
DROP DATABASE IF EXISTS hmdb; DROP DATABASE IF EXISTS hmdb;
DROP TABLESPACE IF EXISTS hmdb; DROP TABLESPACE IF EXISTS hmdb;
CREATE TABLESPACE hmdb OWNER awipsadmin LOCATION '%{tablespace_dir}%/hmdb'; CREATE TABLESPACE hmdb OWNER awips LOCATION '%{tablespace_dir}%/hmdb';
COMMENT ON TABLESPACE hmdb IS 'HMDB Database tablespace'; COMMENT ON TABLESPACE hmdb IS 'HMDB Database tablespace';
CREATE DATABASE hmdb OWNER awipsadmin TABLESPACE hmdb; CREATE DATABASE hmdb OWNER awips TABLESPACE hmdb;

View file

@ -20,14 +20,14 @@
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
DROP DATABASE IF EXISTS maps; DROP DATABASE IF EXISTS maps;
DROP TABLESPACE IF EXISTS maps; DROP TABLESPACE IF EXISTS maps;
CREATE TABLESPACE maps owner awipsadmin location '%{tablespace_dir}%/maps'; CREATE TABLESPACE maps owner awips location '%{tablespace_dir}%/maps';
CREATE DATABASE maps OWNER awipsadmin TABLESPACE maps; CREATE DATABASE maps OWNER awips TABLESPACE maps;
\connect maps \connect maps
BEGIN TRANSACTION; BEGIN TRANSACTION;
GRANT CONNECT, TEMPORARY ON DATABASE maps TO awips; GRANT CONNECT, TEMPORARY ON DATABASE maps TO awips;
CREATE SCHEMA mapdata AUTHORIZATION awipsadmin; CREATE SCHEMA mapdata AUTHORIZATION awips;
GRANT USAGE ON SCHEMA mapdata to awips; GRANT USAGE ON SCHEMA mapdata to awips;
ALTER DEFAULT PRIVILEGES IN SCHEMA mapdata GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER, TRUNCATE ON TABLES TO awips; ALTER DEFAULT PRIVILEGES IN SCHEMA mapdata GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER, TRUNCATE ON TABLES TO awips;
@ -40,7 +40,7 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO awips;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO awips; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO awips;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TYPES TO awips; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TYPES TO awips;
CREATE SCHEMA topology AUTHORIZATION awipsadmin; CREATE SCHEMA topology AUTHORIZATION awips;
GRANT USAGE ON SCHEMA topology to awips; GRANT USAGE ON SCHEMA topology to awips;
ALTER DEFAULT PRIVILEGES IN SCHEMA topology GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER, TRUNCATE ON TABLES TO awips; ALTER DEFAULT PRIVILEGES IN SCHEMA topology GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER, TRUNCATE ON TABLES TO awips;

View file

@ -34,7 +34,7 @@ if [ $# -lt 1 ] ; then
fi fi
PGBINDIR=/awips2/postgresql/bin PGBINDIR=/awips2/postgresql/bin
PGUSER=awipsadmin PGUSER=awips
PGPORT=5432 PGPORT=5432
if [ -z $1 ] ; then if [ -z $1 ] ; then

View file

@ -20,7 +20,7 @@ echo usage: `basename $0` filePath fileName schema tableName [AWIPS2_install_dir
echo " schema - database schema, usually mapdata, where the GeoJSON file is to be imported" echo " schema - database schema, usually mapdata, where the GeoJSON file is to be imported"
echo " tableName - database table name where the GeoJSON file is to be imported" echo " tableName - database table name where the GeoJSON file is to be imported"
echo " AWIPS2_install_dir - optional special AWIPS2 install directory if not /awips2" echo " AWIPS2_install_dir - optional special AWIPS2 install directory if not /awips2"
echo " dbUser - optional database user id, default to awipsadmin" echo " dbUser - optional database user id, default to awips"
echo " dbPort - optional database port number" echo " dbPort - optional database port number"
echo " simplev - optional list of geometry simplification levels to be created" echo " simplev - optional list of geometry simplification levels to be created"
} }
@ -50,7 +50,7 @@ else
fi fi
if [ -z "${6}" ] ; then if [ -z "${6}" ] ; then
PGUSER=awipsadmin PGUSER=awips
else else
PGUSER=${6} PGUSER=${6}
fi fi

View file

@ -36,7 +36,7 @@ SCHEMA=${2}
TABLE=`echo "${3}" | tr '[:upper:]' '[:lower:]'` TABLE=`echo "${3}" | tr '[:upper:]' '[:lower:]'`
if [ -z $4 ] ; then if [ -z $4 ] ; then
PGUSER=awipsadmin PGUSER=awips
else else
PGUSER=${4} PGUSER=${4}
fi fi

View file

@ -36,7 +36,7 @@ SCHEMA=${2}
TABLE=`echo "${3}" | tr '[:upper:]' '[:lower:]'` TABLE=`echo "${3}" | tr '[:upper:]' '[:lower:]'`
if [ -z $4 ] ; then if [ -z $4 ] ; then
PGUSER=awipsadmin PGUSER=awips
else else
PGUSER=${4} PGUSER=${4}
fi fi

View file

@ -72,7 +72,7 @@ if [[ "${TABLE}" == "mapdata" && $# -gt 2 ]] ; then
TABLE=`echo "${3}" | tr '[:upper:]' '[:lower:]'` TABLE=`echo "${3}" | tr '[:upper:]' '[:lower:]'`
fi fi
PGUSER=awipsadmin PGUSER=awips
PGPORT=5432 PGPORT=5432
PGBINDIR=/awips2/postgresql/bin/ PGBINDIR=/awips2/postgresql/bin/
PSQLBINDIR=/awips2/psql/bin/ PSQLBINDIR=/awips2/psql/bin/

View file

@ -35,7 +35,7 @@ DATABASEDIR=/awips2/database/sqlScripts/share/sql/maps
POSTGIS_CONTRIB=/awips2/postgresql/share/contrib/postgis-2.2 POSTGIS_CONTRIB=/awips2/postgresql/share/contrib/postgis-2.2
PGBINDIR=/awips2/postgresql/bin PGBINDIR=/awips2/postgresql/bin
PSQLBINDIR=/awips2/psql/bin PSQLBINDIR=/awips2/psql/bin
PGUSER=awipsadmin PGUSER=awips
PGPORT=5432 PGPORT=5432
${PSQLBINDIR}/psql -d postgres -U $PGUSER -q -p $PGPORT -f ${DATABASEDIR}/createMapsDb.sql ${PSQLBINDIR}/psql -d postgres -U $PGUSER -q -p $PGPORT -f ${DATABASEDIR}/createMapsDb.sql

View file

@ -1,9 +1,9 @@
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
DROP DATABASE IF EXISTS ncep; DROP DATABASE IF EXISTS ncep;
DROP TABLESPACE IF EXISTS ncep; DROP TABLESPACE IF EXISTS ncep;
CREATE TABLESPACE ncep OWNER awipsadmin LOCATION '%{tablespace_dir}%/ncep'; CREATE TABLESPACE ncep OWNER awips LOCATION '%{tablespace_dir}%/ncep';
COMMENT ON TABLESPACE ncep IS 'NCEP Database tablespace'; COMMENT ON TABLESPACE ncep IS 'NCEP Database tablespace';
CREATE DATABASE ncep OWNER awipsadmin TABLESPACE ncep; CREATE DATABASE ncep OWNER awips TABLESPACE ncep;
\c ncep \c ncep

View file

@ -2,7 +2,7 @@
# alters all database objects to be owned by awips admin. Gives CRUD roles to pg_user and awips accounts. # alters all database objects to be owned by awips admin. Gives CRUD roles to pg_user and awips accounts.
PSQL='/awips2/psql/bin/psql' PSQL='/awips2/psql/bin/psql'
adminUser='awipsadmin' adminUser='awips'
users=('awips' 'pguser') users=('awips' 'pguser')
as_awips='sudo -u awips -i ' as_awips='sudo -u awips -i '

View file

@ -25,28 +25,28 @@
ALTER USER %{databaseUsername} with password 'postgres' login superuser createdb createrole; ALTER USER %{databaseUsername} with password 'postgres' login superuser createdb createrole;
CREATE USER postgres superuser; CREATE USER postgres superuser;
-- connect as postgres user to allow rename of primary user to awipsadmin -- connect as postgres user to allow rename of primary user to awips
\c postgres postgres \c postgres postgres
ALTER USER %{databaseUsername} rename to awipsadmin; ALTER USER %{databaseUsername} rename to awips;
ALTER USER awipsadmin with password 'awips'; ALTER USER awips with password 'awips';
\c postgres awipsadmin \c postgres awips
CREATE USER awips with password 'awips' login; CREATE USER awips with password 'awips' login;
--Create the metadata tablespace --Create the metadata tablespace
CREATE TABLESPACE metadata owner awipsadmin location '%{tablespace_dir}/metadata'; CREATE TABLESPACE metadata owner awips location '%{tablespace_dir}/metadata';
--Create the database --Create the database
CREATE DATABASE metadata OWNER awipsadmin TABLESPACE metadata; CREATE DATABASE metadata OWNER awips TABLESPACE metadata;
--Switch to the metadata database --Switch to the metadata database
\c metadata; \c metadata;
--Create the AWIPS schema --Create the AWIPS schema
GRANT CONNECT, TEMPORARY ON DATABASE metadata TO awips; GRANT CONNECT, TEMPORARY ON DATABASE metadata TO awips;
CREATE SCHEMA awips AUTHORIZATION awipsadmin; CREATE SCHEMA awips AUTHORIZATION awips;
-- Grant privileges to awips -- Grant privileges to awips
GRANT USAGE ON SCHEMA awips to awips; -- Don't grant create GRANT USAGE ON SCHEMA awips to awips; -- Don't grant create
@ -57,12 +57,12 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA awips GRANT ALL ON TYPES TO awips;
ALTER DATABASE metadata SET search_path = awips, public, topology; ALTER DATABASE metadata SET search_path = awips, public, topology;
COMMENT ON ROLE awipsadmin IS 'Primary AWIPS admin user'; COMMENT ON ROLE awips IS 'Primary AWIPS admin user';
COMMENT ON ROLE awips IS 'Primary AWIPS user'; COMMENT ON ROLE awips IS 'Primary AWIPS user';
COMMENT ON DATABASE metadata IS 'AWIPS Metadata Database'; COMMENT ON DATABASE metadata IS 'AWIPS Metadata Database';
COMMENT ON TABLESPACE metadata IS 'AWIPS Metadata Database Tablespace'; COMMENT ON TABLESPACE metadata IS 'AWIPS Metadata Database Tablespace';
COMMENT ON SCHEMA awips IS 'AWIPS Schema'; COMMENT ON SCHEMA awips IS 'AWIPS Schema';
CREATE TABLESPACE pgdata_ihfs OWNER awipsadmin LOCATION '%{tablespace_dir}/pgdata_ihfs'; CREATE TABLESPACE pgdata_ihfs OWNER awips LOCATION '%{tablespace_dir}/pgdata_ihfs';
COMMENT ON TABLESPACE pgdata_ihfs IS 'IHFS Database tablespace'; COMMENT ON TABLESPACE pgdata_ihfs IS 'IHFS Database tablespace';

View file

@ -8,7 +8,7 @@
# only need to run this once per server. # only need to run this once per server.
psql="/awips2/psql/bin/psql" psql="/awips2/psql/bin/psql"
db_superuser=awipsadmin db_superuser=awips
postgres_data_dir=/awips2/database/data postgres_data_dir=/awips2/database/data
cleanup_exit () { cleanup_exit () {

View file

@ -22,7 +22,7 @@
# Configuration ############################################################### # Configuration ###############################################################
# Credentials # Credentials
db_superuser=awipsadmin db_superuser=awips
db_rep_user=replication # for connecting to master db_rep_user=replication # for connecting to master
# Master server info # Master server info

View file

@ -1,5 +1,5 @@
output_dir=output output_dir=output
db_users=(awips awipsadmin pguser postgres) db_users=(awips awips pguser postgres)
unpriv_db_users=(awips pguser) unpriv_db_users=(awips pguser)
dn_attrs='/C=US/ST=Maryland/L=Silver Spring/O=Raytheon/OU=AWIPS' dn_attrs='/C=US/ST=Maryland/L=Silver Spring/O=Raytheon/OU=AWIPS'
validity_days=$((30 * 365)) validity_days=$((30 * 365))

View file

@ -17,7 +17,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/${climate.db.name} jdbc:postgresql://${db.addr}:${db.port}/${climate.db.name}
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode"> <property name="connection.release_mode">
after_transaction after_transaction

View file

@ -35,7 +35,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/${dc.db.name} jdbc:postgresql://${db.addr}:${db.port}/${dc.db.name}
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode"> <property name="connection.release_mode">
after_transaction after_transaction

View file

@ -35,7 +35,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/${fxa.db.name} jdbc:postgresql://${db.addr}:${db.port}/${fxa.db.name}
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode"> <property name="connection.release_mode">
after_transaction after_transaction

View file

@ -35,7 +35,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/${hm.db.name} jdbc:postgresql://${db.addr}:${db.port}/${hm.db.name}
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode"> <property name="connection.release_mode">
after_transaction after_transaction

View file

@ -35,7 +35,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/${ih.db.name} jdbc:postgresql://${db.addr}:${db.port}/${ih.db.name}
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode"> <property name="connection.release_mode">
after_transaction after_transaction

View file

@ -35,7 +35,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/maps jdbc:postgresql://${db.addr}:${db.port}/maps
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode"> <property name="connection.release_mode">
after_transaction after_transaction

View file

@ -34,7 +34,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/metadata jdbc:postgresql://${db.addr}:${db.port}/metadata
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode">after_transaction</property> <property name="connection.release_mode">after_transaction</property>
<property name="jdbc.batch_size">100</property> <property name="jdbc.batch_size">100</property>

View file

@ -35,7 +35,7 @@
<property name="connection.url"> <property name="connection.url">
jdbc:postgresql://${db.addr}:${db.port}/ncep jdbc:postgresql://${db.addr}:${db.port}/ncep
</property> </property>
<property name="connection.username">awipsadmin</property> <property name="connection.username">awips</property>
<property name="connection.password">awips</property> <property name="connection.password">awips</property>
<property name="connection.release_mode"> <property name="connection.release_mode">
after_transaction after_transaction

View file

@ -144,7 +144,7 @@ function printFailureMessage() {
AWIPS_DEFAULT_OWNER="awips" AWIPS_DEFAULT_OWNER="awips"
AWIPS_DEFAULT_USER="awips" AWIPS_DEFAULT_USER="awips"
AWIPS_DEFAULT_DB_ADMIN="awipsadmin" AWIPS_DEFAULT_DB_ADMIN="awips"
AWIPS_DEFAULT_GROUP="fxalpha" AWIPS_DEFAULT_GROUP="fxalpha"
AWIPS_DEFAULT_PORT="5432" AWIPS_DEFAULT_PORT="5432"
@ -278,8 +278,8 @@ fi
execute_initial_sql_script ${SQL_SHARE_DIR}/initial_setup_server.sql > /dev/null 2>&1 execute_initial_sql_script ${SQL_SHARE_DIR}/initial_setup_server.sql > /dev/null 2>&1
/awips2/psql/bin/psql -U awipsadmin -d metadata -c "CREATE EXTENSION postgis;" > /dev/null 2>&1 /awips2/psql/bin/psql -U awips -d metadata -c "CREATE EXTENSION postgis;" > /dev/null 2>&1
/awips2/psql/bin/psql -U awipsadmin -d metadata -c "CREATE EXTENSION postgis_topology;" > /dev/null 2>&1 /awips2/psql/bin/psql -U awips -d metadata -c "CREATE EXTENSION postgis_topology;" > /dev/null 2>&1
execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.4/legacy.sql metadata > /dev/null 2>&1 execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.4/legacy.sql metadata > /dev/null 2>&1
execute_psql_sql_script ${SQL_SHARE_DIR}/permissions.sql metadata > /dev/null 2>&1 execute_psql_sql_script ${SQL_SHARE_DIR}/permissions.sql metadata > /dev/null 2>&1
execute_psql_sql_script ${SQL_SHARE_DIR}/fxatext.sql metadata > /dev/null 2>&1 execute_psql_sql_script ${SQL_SHARE_DIR}/fxatext.sql metadata > /dev/null 2>&1

View file

@ -375,7 +375,7 @@ function restoreHydroDb()
# perform the restoration # perform the restoration
echo "Restoring Database ${DAMCAT_DATABASE} ..." >> ${log_file} echo "Restoring Database ${DAMCAT_DATABASE} ..." >> ${log_file}
${a2_pg_restore} -U awipsadmin -C -d postgres ${hydro_db_directory}/${DAMCAT_DATABASE} \ ${a2_pg_restore} -U awips -C -d postgres ${hydro_db_directory}/${DAMCAT_DATABASE} \
>> ${log_file} 2>&1 >> ${log_file} 2>&1
# do not check the return code because any errors encountered during # do not check the return code because any errors encountered during
# the restoration may cause the return code to indicate a failure even # the restoration may cause the return code to indicate a failure even
@ -384,7 +384,7 @@ function restoreHydroDb()
echo "" >> ${log_file} echo "" >> ${log_file}
echo "Restoring Database ${IHFS_DATABASE} ..." >> ${log_file} echo "Restoring Database ${IHFS_DATABASE} ..." >> ${log_file}
${a2_pg_restore} -U awipsadmin -C -d postgres ${hydro_db_directory}/${IHFS_DATABASE} \ ${a2_pg_restore} -U awips -C -d postgres ${hydro_db_directory}/${IHFS_DATABASE} \
>> ${log_file} 2>&1 >> ${log_file} 2>&1
# do not check the return code because any errors encountered during # do not check the return code because any errors encountered during
# the restoration may cause the return code to indicate a failure even # the restoration may cause the return code to indicate a failure even

View file

@ -132,7 +132,7 @@ fi
# Is there a maps database? # Is there a maps database?
MAPS_DB_EXISTS="false" MAPS_DB_EXISTS="false"
MAPS_DB=`${PSQL} -U awipsadmin -l | grep maps | awk '{print $1}'` MAPS_DB=`${PSQL} -U awips -l | grep maps | awk '{print $1}'`
if [ "${MAPS_DB}" = "maps" ]; then if [ "${MAPS_DB}" = "maps" ]; then
MAPS_DB_EXISTS="true" MAPS_DB_EXISTS="true"
# We Have a Maps Database, There Is Nothing To Do. # We Have a Maps Database, There Is Nothing To Do.
@ -152,27 +152,27 @@ if [ "${MAPS_DB_EXISTS}" = "false" ]; then
# Run the setup sql for the maps database. # Run the setup sql for the maps database.
SQL_FILE="/awips2/database/sqlScripts/share/sql/maps/createMapsDb.sql" SQL_FILE="/awips2/database/sqlScripts/share/sql/maps/createMapsDb.sql"
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d postgres -U awipsadmin -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1 "${PSQL} -d postgres -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
RC=$? RC=$?
if [ ! "${RC}" -eq 0 ]; then if [ ! "${RC}" -eq 0 ]; then
printFailureMessage printFailureMessage
fi fi
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d maps -U awipsadmin -q -p 5432 -c \"CREATE EXTENSION postgis;\"" >> ${SQL_LOG} 2>&1 "${PSQL} -d maps -U awips -q -p 5432 -c \"CREATE EXTENSION postgis;\"" >> ${SQL_LOG} 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printFailureMessage printFailureMessage
fi fi
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d maps -U awipsadmin -q -p 5432 -c \"CREATE EXTENSION postgis_topology;\"" >> ${SQL_LOG} 2>&1 "${PSQL} -d maps -U awips -q -p 5432 -c \"CREATE EXTENSION postgis_topology;\"" >> ${SQL_LOG} 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printFailureMessage printFailureMessage
fi fi
SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.4/legacy.sql" SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.4/legacy.sql"
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d maps -U awipsadmin -q -p 5432 -f ${SQL_FILE}" >>${SQL_LOG} 2>&1 "${PSQL} -d maps -U awips -q -p 5432 -f ${SQL_FILE}" >>${SQL_LOG} 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printFailureMessage printFailureMessage
fi fi
@ -180,10 +180,10 @@ if [ "${MAPS_DB_EXISTS}" = "false" ]; then
# Import the data into the maps database. # Import the data into the maps database.
DB_ARCHIVE="/awips2/database/sqlScripts/share/sql/maps/maps.db" DB_ARCHIVE="/awips2/database/sqlScripts/share/sql/maps/maps.db"
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PG_RESTORE} -d maps -U awipsadmin -p 5432 -n mapdata ${DB_ARCHIVE}" >> ${SQL_LOG} 2>&1 "${PG_RESTORE} -d maps -U awips -p 5432 -n mapdata ${DB_ARCHIVE}" >> ${SQL_LOG} 2>&1
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PG_RESTORE} -d maps -U awipsadmin -p 5432 -n public -t geometry_columns -a ${DB_ARCHIVE}" \ "${PG_RESTORE} -d maps -U awips -p 5432 -n public -t geometry_columns -a ${DB_ARCHIVE}" \
>> ${SQL_LOG} 2>&1 >> ${SQL_LOG} 2>&1
fi fi
@ -255,22 +255,22 @@ if [ ! "${RC}" = "0" ]; then
fi fi
# Is there a maps database? # Is there a maps database?
MAPS_DB=`${PSQL} -U awipsadmin -l | grep maps | awk '{print $1}'` MAPS_DB=`${PSQL} -U awips -l | grep maps | awk '{print $1}'`
if [ "${MAPS_DB}" = "maps" ]; then if [ "${MAPS_DB}" = "maps" ]; then
# drop the maps database # drop the maps database
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${DROPDB} -U awipsadmin maps" >> ${SQL_LOG} "${DROPDB} -U awips maps" >> ${SQL_LOG}
fi fi
# Is there a maps tablespace? # Is there a maps tablespace?
# ask psql where the maps tablespace is ... # ask psql where the maps tablespace is ...
MAPS_DIR=`${PSQL} -U awipsadmin -d postgres -c "\db" | grep maps | awk '{print $5}'` MAPS_DIR=`${PSQL} -U awips -d postgres -c "\db" | grep maps | awk '{print $5}'`
if [ ! "${MAPS_DIR}" = "" ]; then if [ ! "${MAPS_DIR}" = "" ]; then
# drop the maps tablespace # drop the maps tablespace
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -U awipsadmin -d postgres -c \"DROP TABLESPACE maps\"" >> ${SQL_LOG} "${PSQL} -U awips -d postgres -c \"DROP TABLESPACE maps\"" >> ${SQL_LOG}
# remove the maps data directory that we created # remove the maps data directory that we created
if [ -d "${MAPS_DIR}" ]; then if [ -d "${MAPS_DIR}" ]; then

View file

@ -120,19 +120,19 @@ perl -p -i -e "s/%{tablespace_dir}%/${TABLESPACE_DIR_ESCAPED}/g" \
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d postgres -U awipsadmin -q -p 5432 -f ${SQL_SHARE_DIR}/createNcepDb.sql" >> ${SQL_LOG} 2>&1 "${PSQL} -d postgres -U awips -q -p 5432 -f ${SQL_SHARE_DIR}/createNcepDb.sql" >> ${SQL_LOG} 2>&1
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d postgres -U awipsadmin -q -p 5432 -f ${SQL_SHARE_DIR}/createNcepSchemas.sql" >> ${SQL_LOG} 2>&1 "${PSQL} -d postgres -U awips -q -p 5432 -f ${SQL_SHARE_DIR}/createNcepSchemas.sql" >> ${SQL_LOG} 2>&1
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d ncep -U awipsadmin -q -p 5432 -c \"CREATE EXTENSION postgis;\"" >> ${SQL_LOG} 2>&1 "${PSQL} -d ncep -U awips -q -p 5432 -c \"CREATE EXTENSION postgis;\"" >> ${SQL_LOG} 2>&1
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d ncep -U awipsadmin -q -p 5432 -c \"CREATE EXTENSION postgis_topology;\"" >> ${SQL_LOG} 2>&1 "${PSQL} -d ncep -U awips -q -p 5432 -c \"CREATE EXTENSION postgis_topology;\"" >> ${SQL_LOG} 2>&1
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -d ncep -U awipsadmin -q -p 5432 -f ${LEGACY_SQL}" >> ${SQL_LOG} 2>&1 "${PSQL} -d ncep -U awips -q -p 5432 -f ${LEGACY_SQL}" >> ${SQL_LOG} 2>&1
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${SQL_SHARE_DIR}/createNcepDb.sh ${PSQL_INSTALL} 5432 awipsadmin ${SQL_SHARE_DIR} ${SQL_LOG}" "${SQL_SHARE_DIR}/createNcepDb.sh ${PSQL_INSTALL} 5432 awips ${SQL_SHARE_DIR} ${SQL_LOG}"
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${SQL_SHARE_DIR}/initializeNcepDb.sh ${POSTGRESQL_INSTALL} awipsadmin 5432 ${SQL_SHARE_DIR} ${SQL_LOG}" "${SQL_SHARE_DIR}/initializeNcepDb.sh ${POSTGRESQL_INSTALL} awips 5432 ${SQL_SHARE_DIR} ${SQL_LOG}"
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${DATABASE_INSTALL}/sqlScripts/share/sql/alter_database_roles_and_permissions.sh ncep" >> ${SQL_LOG} 2>&1 "${DATABASE_INSTALL}/sqlScripts/share/sql/alter_database_roles_and_permissions.sh ncep" >> ${SQL_LOG} 2>&1
@ -187,16 +187,15 @@ if [ ! "${RC}" = "0" ]; then
fi fi
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${DROPDB} -U awipsadmin ncep" "${DROPDB} -U awips ncep"
# Is there a ncep tablespace? # Is there a ncep tablespace?
# ask psql where the ncep tablespace is ... # ask psql where the ncep tablespace is ...
NCEP_DIR=`${PSQL} -U awipsadmin -d postgres -c "\db" | grep ncep | awk '{print $5}'` NCEP_DIR=`${PSQL} -U awips -d postgres -c "\db" | grep ncep | awk '{print $5}'`
if [ ! "${NCEP_DIR}" = "" ]; then if [ ! "${NCEP_DIR}" = "" ]; then
echo "Dropping ncep tablespace..."
su - ${DB_OWNER} -c \ su - ${DB_OWNER} -c \
"${PSQL} -U awipsadmin -d postgres -c \"DROP TABLESPACE ncep\"" "${PSQL} -U awips -d postgres -c \"DROP TABLESPACE ncep\"" > /dev/null 2>&1
# remove the maps data directory that we created # remove the maps data directory that we created
if [ -d "${NCEP_DIR}" ]; then if [ -d "${NCEP_DIR}" ]; then