quieter install of db packages;edex rpm cleanup

This commit is contained in:
mjames-upc 2017-11-13 15:27:35 -07:00
parent 220023adf0
commit e461b6b35c
4 changed files with 24 additions and 84 deletions

View file

@ -176,16 +176,13 @@ function prepare()
local a2_pg_ctl="/awips2/postgresql/bin/pg_ctl"
DB_OWNER=`ls -l /awips2/ | grep -w 'data' | awk '{print $3}'`
I_STARTED_POSTGRESQL="NO"
echo "Determining if PostgreSQL is running ..."
su - ${DB_OWNER} -c \
"${a2_pg_ctl} status -D /awips2/data &"
"${a2_pg_ctl} status -D /awips2/data &" > /dev/null 2>&1
RC=$?
if [ ${RC} -eq 0 ]; then
echo "INFO: PostgreSQL is running."
else
if [ ${RC} -ne 0 ]; then
echo "Starting PostgreSQL as user: ${DB_OWNER} ..."
su - ${DB_OWNER} -c \
"${a2_postmaster} -D /awips2/data &"
"${a2_postmaster} -D /awips2/data &" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FATAL: Failed to start PostgreSQL."
return 0

View file

@ -60,7 +60,6 @@ if [ ${RC} -ne 0 ]; then
fi
SQL_LOG="${RPM_BUILD_ROOT}/awips2/database/sqlScripts/share/sql/maps/maps.log"
# So that it will automatically be removed when the rpm is removed.
touch ${SQL_LOG}
%pre
@ -99,21 +98,20 @@ DROPDB="${POSTGRESQL_INSTALL}/bin/dropdb"
PG_RESTORE="${POSTGRESQL_INSTALL}/bin/pg_restore"
PSQL="${PSQL_INSTALL}/bin/psql"
# Determine who owns the PostgreSQL Installation
# Determine who owns the PostgreSQL Installation (awips)
DB_OWNER=`ls -l /awips2/ | grep -w 'data' | awk '{print $3}'`
# Our log file
SQL_LOG="/awips2/database/sqlScripts/share/sql/maps/maps.log"
# Determine if PostgreSQL is running.
I_STARTED_POSTGRESQL="NO"
su - ${DB_OWNER} -c \
"${PG_CTL} status -D /awips2/data > /dev/null 2>&1"
"${PG_CTL} status -D /awips2/data &" > /dev/null 2>&1
RC="$?"
# Start PostgreSQL if it is not running.
if [ ! "${RC}" = "0" ]; then
su - ${DB_OWNER} -c \
"${POSTMASTER} -D /awips2/data > /dev/null 2>&1 &"
"${POSTMASTER} -D /awips2/data &" > /dev/null 2>&1
RC="$?"
if [ ! "${RC}" = "0" ]; then
printFailureMessage
@ -188,7 +186,7 @@ fi
# stop PostgreSQL if we started it.
if [ "${I_STARTED_POSTGRESQL}" = "YES" ]; then
su - ${DB_OWNER} -c \
"${PG_CTL} stop -D /awips2/data"
"${PG_CTL} stop -D /awips2/data" >> ${SQL_LOG} 2>&1
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "Warning: Failed to shutdown PostgreSQL."
@ -234,19 +232,22 @@ SQL_LOG="/awips2/database/sqlScripts/share/sql/maps/maps.log"
# start PostgreSQL if it is not running
I_STARTED_POSTGRESQL="NO"
su - ${DB_OWNER} -c \
"${PG_CTL} status -D /awips2/data > /dev/null 2>&1"
"${PG_CTL} status -D /awips2/data &" >> ${SQL_LOG} 2>&1
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "Failed To Start The PostgreSQL Server."
exit 1
fi
# Start PostgreSQL if it is not running.
if [ ! "${RC}" = "0" ]; then
su - ${DB_OWNER} -c \
"${POSTMASTER} -D /awips2/data > /dev/null 2>&1 &"
"${POSTMASTER} -D /awips2/data &" >> ${SQL_LOG} 2>&1
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "Failed To Start The PostgreSQL Server."
exit 1
fi
# Give PostgreSQL Time To Start.
sleep 10
I_STARTED_POSTGRESQL="YES"
else
@ -261,7 +262,7 @@ MAPS_DB=`${PSQL} -U awips -l | grep maps | awk '{print $1}'`
if [ "${MAPS_DB}" = "maps" ]; then
# drop the maps database
su - ${DB_OWNER} -c \
"${DROPDB} -U awips maps" >> ${SQL_LOG}
"${DROPDB} -U awips maps" >> ${SQL_LOG} 2>&1
fi
# Is there a maps tablespace?
@ -271,19 +272,18 @@ MAPS_DIR=`${PSQL} -U awips -d postgres -c "\db" | grep maps | awk '{print $5}'`
if [ ! "${MAPS_DIR}" = "" ]; then
# drop the maps tablespace
su - ${DB_OWNER} -c \
"${PSQL} -U awips -d postgres -c \"DROP TABLESPACE maps\"" >> ${SQL_LOG}
"${PSQL} -U awips -d postgres -c \"DROP TABLESPACE maps\"" >> ${SQL_LOG} 2>&1
# remove the maps data directory that we created
echo "Attempting To Removing Directory: ${MAPS_DIR}"
if [ -d "${MAPS_DIR}" ]; then
su - ${DB_OWNER} -c "rmdir ${MAPS_DIR}"
su - ${DB_OWNER} -c "rmdir ${MAPS_DIR}" >> ${SQL_LOG} 2>&1
fi
fi
# stop PostgreSQL if we started it
if [ "${I_STARTED_POSTGRESQL}" = "YES" ]; then
su - ${DB_OWNER} -c \
"${PG_CTL} stop -D /awips2/data"
"${PG_CTL} stop -D /awips2/data" >> ${SQL_LOG} 2>&1
sleep 2
fi

View file

@ -158,7 +158,7 @@ fi
if [ "${1}" = "1" ]; then
exit 0
fi
POSTGRESQL_INSTALL="/awips2/postgresql"
PSQL_INSTALL="/awips2/psql"
@ -174,13 +174,13 @@ DB_OWNER=`ls -ld ${AWIPS2_DATA_DIRECTORY} | grep -w 'data' | awk '{print $3}'`
# start PostgreSQL if it is not running
I_STARTED_POSTGRESQL="NO"
su - ${DB_OWNER} -c \
"${PG_CTL} status -D ${AWIPS2_DATA_DIRECTORY} > /dev/null 2>&1"
"${PG_CTL} status -D ${AWIPS2_DATA_DIRECTORY} &" > /dev/null 2>&1
RC="$?"
# Start PostgreSQL if it is not running.
if [ ! "${RC}" = "0" ]; then
su - ${DB_OWNER} -c \
"${POSTMASTER} -D ${AWIPS2_DATA_DIRECTORY} > /dev/null 2>&1 &"
"${POSTMASTER} -D ${AWIPS2_DATA_DIRECTORY} &" > /dev/null 2>&1
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "Failed To Start The PostgreSQL Server."
@ -196,7 +196,7 @@ else
fi
su - ${DB_OWNER} -c \
"${DROPDB} -U awips ncep"
"${DROPDB} -U awips ncep &" > /dev/null 2>&1
# Is there a ncep tablespace?
# ask psql where the ncep tablespace is ...
@ -204,18 +204,18 @@ NCEP_DIR=`${PSQL} -U awips -d postgres -c "\db" | grep ncep | awk '{print $5}'`
if [ ! "${NCEP_DIR}" = "" ]; then
su - ${DB_OWNER} -c \
"${PSQL} -U awips -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
if [ -d "${NCEP_DIR}" ]; then
su - ${DB_OWNER} -c "rmdir ${NCEP_DIR}"
su - ${DB_OWNER} -c "rmdir ${NCEP_DIR} &" > /dev/null 2>&1
fi
fi
# stop PostgreSQL if we started it.
if [ "${I_STARTED_POSTGRESQL}" = "YES" ]; then
su - ${DB_OWNER} -c \
"${PG_CTL} stop -D ${AWIPS2_DATA_DIRECTORY}"
"${PG_CTL} stop -D ${AWIPS2_DATA_DIRECTORY} &" > /dev/null 2>&1
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "Warning: Failed to shutdown PostgreSQL."

View file

@ -117,20 +117,6 @@ fi
# Set ipaddress in setup.env and run chkconfig for init.d services
/awips2/edex/bin/edex setup > /dev/null 2>&1
# We need to create a link to the python shared library if it does not exist.
#pushd . > /dev/null 2>&1
#if [ -d /awips2/python/lib ]; then
# cd /awips2/python/lib
# if [ -L libpython.so ]; then
# # Ensure that we are pointing to the correct shared library.
# rm -f libpython.so
# fi
# if [ -f libpython2.7.so.1.0 ]; then
# ln -s libpython2.7.so.1.0 libpython.so
# fi
#fi
#popd > /dev/null 2>&1
if [ -f /etc/init.d/edex_camel ]; then
/sbin/chkconfig --add edex_camel
fi
@ -140,53 +126,10 @@ fi
if [ -d /awips2/.edex ]; then
# copy the common-base contributions to the EDEX installation
cp -r /awips2/.edex/* /awips2/edex
# cleanup
rm -rf /awips2/.edex
fi
SETUP_ENV="/awips2/edex/bin/setup.env"
SETUP_ENV_NEW="/awips2/edex/bin/setup.env.rpmnew"
function updateSetupEnv() {
# args
# 1 value of the variable to change
# 2 name of the variable to change
# 3 default value of the variable
local VALUE="${1}"
local VARIABLE="${2}"
local DEFAULT="${3}"
echo "${VALUE}" | sed 's/\//\\\//g' > .awips2_escape.tmp
VALUE=`cat .awips2_escape.tmp`
rm -f .awips2_escape.tmp
echo "${DEFAULT}" | sed 's/\//\\\//g' > .awips2_escape.tmp
DEFAULT=`cat .awips2_escape.tmp`
rm -f .awips2_escape.tmp
perl -p -i -e "s/export ${VARIABLE}=${DEFAULT}/export ${VARIABLE}=${VALUE}/g" \
${SETUP_ENV_NEW}
}
if [ -f "${SETUP_ENV_NEW}" ]; then
# rewrite the new setup.env with the existing configuration
source ${SETUP_ENV}
# update when a variable is added to or removed from setup.env.
updateSetupEnv "${AW_SITE_IDENTIFIER}" "AW_SITE_IDENTIFIER" "OAX"
updateSetupEnv "${DC_DB_NAME}" "DC_DB_NAME" "dc_ob7oax"
updateSetupEnv "${FXA_DB_NAME}" "FXA_DB_NAME" "fxatext"
updateSetupEnv "${HM_DB_NAME}" "HM_DB_NAME" "hmdb"
updateSetupEnv "${IH_DB_NAME}" "IH_DB_NAME" "hd_ob92oax"
updateSetupEnv "${DATA_ARCHIVE_ROOT}" "DATA_ARCHIVE_ROOT" "/tmp/sbn"
updateSetupEnv "${DB_ADDR}" "DB_ADDR" "localhost"
updateSetupEnv "${DB_PORT}" "DB_PORT" "5432"
updateSetupEnv "${BROKER_ADDR}" "BROKER_ADDR" "localhost"
updateSetupEnv "${PYPIES_SERVER}" "PYPIES_SERVER" "http://localhost:9582"
updateSetupEnv "${HTTP_SERVER}" "HTTP_SERVER" "http://localhost:9581/services"
updateSetupEnv "${JMS_SERVER}" "JMS_SERVER" "tcp://localhost:5672"
updateSetupEnv "${SHARE_DIR}" "SHARE_DIR" "/awips2/edex/data/share"
updateSetupEnv "${LDAD_EXTERNAL_HOME}" "LDAD_EXTERNAL_HOME" "/ldad"
updateSetupEnv "${LDAD_EXTERNAL_PUBLIC}" "LDAD_EXTERNAL_PUBLIC" "/data/ldad/public"
fi
%preun
if [ "${1}" = "1" ]; then
exit 0