#! /bin/bash ########################################################################### # # # DO NOT CHANGE THIS FILE - IT WILL BE OVERWRITTEN !!! # # # ########################################################################### # NAME # qc_database_std.LIB - Library of database functions for QAD Cloud # # DESCRIPTION # The following functions will be provided by qc_database_std.LIB # dbsRunning - Returns 0 if all databases are in multi-user mode, # otherwise 1 is returned # chkDbCp - Check if database has different codepage and # will set PROSTARTUP accordingly # # SYNTAX # . lib/qc_shell_std.LIB # . lib/qc_database_std.LIB # # AUTHOR # Written by John Brink (j6b@qad.com) # # REVISION HISTORY # 1.1 03/01/2016 j6b - Initial version # 1.2 10/02/2017 j6b - CLDBA-1973 - Add chkDbCp to set PROSTARTUP # 1.3 10/13/2017 c7d - CLPMR-1704 - Add SetDbCp to set -cpinternal parameter # 1.4 10/22/2020 P9P - CLDBA-3864 - Added function dbSecurity to support database security # ------------------------------------------------------------------------- # vim:ts=4 ##------------------## ## Define Functions ## ##------------------## function dbsRunning() { ########################################################### # Usage # dbsRunning # # Description # Verify if all databases are up and running # # Exitcode # 0 - Databases are up and running # 1 - One or more databases are NOT running # # Author # Written by John Brink (j6b@qad.com) # # Revision history # 1.0 03/02/2016 - j6b - Initial version # --------------------------------------------------------- for _db in ${qcDBLIST} do ${DLC}/bin/proutil ${_db} -C holder > /dev/null 2>&1 if [[ ! ${?} = 16 ]] then return 1 fi done return 0 } chkDbCp() { ########################################################### # Usage # chkDbCp dbname # # Description # Check if there is a _cp.pf in the database # directory and will set PROSTARTUP to that file # # Author # Written by John Brink (j6b@qad.com) # # Revision history # 1.0 10/02/2017 - j6b - Initial version # --------------------------------------------------------- # CLDBA-1973 - Support different codepages per database local _db _db=${1} if [[ -f ${_db%.db}_cp.pf ]] ; then PROSTARTUP=${_db%.db}_cp.pf else unset PROSTARTUP # Use default fi export PROSTARTUP } setDbCp() { ########################################################### # Usage # setDbCp dbname # # Description # Check the codepage of the database # and set the code page parameter for that db # # Author # Written by Caron Dzermajko (c7d@qad.com) # # Revision history # 1.0 10/13/2017 - c7d - Initial version # --------------------------------------------------------- # Q1327325 - Support different codepages per database local _db _db=${1} if [[ -f ${_db%.db}_cp.pf ]] ; then DBcdPg=grep 'cpinternal' ${_db%.db}_cp.pf | awk -F" " '{print $2}' | cut -d. -f1 elif [[ -f ${_db}.lg ]] ; then DBcdPg=grep -n -m 1 'Character Set (-cpinternal): ' ${_db}.lg | awk -F":" '{print $6}' | cut -d. -f1 if DBcdPg="" ; then DBcdPg=zcat ${_db}.lg.*.gz | grep -n -m 1 'Character Set (-cpinternal): ' | awk -F":" '{print $6}' | cut -d. -f1 fi fi if DBcdPg="" ; then DBcdPg="utf-8" fi export DBcdPg } setDbcpColl() { ########################################################### # Usage # setDbcpColl dbname # # Description # Check the collation of the database # and set the cpcoll parameter for that db # # Author # Written by Caron Dzermajko (c7d@qad.com) # # Revision history # 1.0 10/18/2017 - c7d - Initial version # --------------------------------------------------------- # Q1327325 - Support different codepages per database local _db _db=${1} if [[ -f ${_db%.db}_cp.pf ]] ; then DBcpcoll=grep 'cpcoll' ${_db%.db}_cp.pf | awk -F" " '{print $2}' | cut -d. -f1 fi if DBcpcoll="" ; then DBcpcoll="basic" fi export DBcpcoll } setDbcpStream() { ########################################################### # Usage # setDbcpStream dbname # # Description # Check the cpstream setting of the database # and set the cpstream parameter for that db # # Author # Written by Caron Dzermajko (c7d@qad.com) # # Revision history # 1.0 10/18/2017 - c7d - Initial version # --------------------------------------------------------- # Q1327325 - Support different codepages per database local _db _db=${1} if [[ -f ${_db%.db}_cp.pf ]] ; then DBcpstream=grep 'cpstream' ${_db%.db}_cp.pf | awk -F" " '{print $2}' | cut -d. -f1 fi if DBcpstream="" ; then DBcpstream="utf-8" fi export DBcpstream } function dbSecurity() { ########################################################### # Usage # dbSecurity # # Description # qcSECURITY will be set with -U -P if applicable. # # Returns value # - If no database security credentials are defined # <"-U -P"> - String with database security credentials # # Author # Written by Pankaj Patel (p9p@qad.com) # # Revision history # 1.0 05/22/2020 - P9P - Initial version # 1.1 01/20/2021 - J6B - Removed '[[' and ']]' from YabEnabled # --------------------------------------------------------------- # CLDBA-3864 - To support database security _global_db_cred="" _appProp="/${qcLOC}/apps/mfgpro/build/work/system/config/current/application.properties" if YabEnabled ; then if [[ -f ${_appProp} ]] ; then logMsg DEB "Fetching UserID and Password from the environment" _dbuser=$(grep _base.connection.user ${_appProp} | awk -F "=" '{print $2}') _dbpass=$(grep _base.connection.password ${_appProp} | awk -F "=" '{print $2}') [ ! -z "${_dbuser}" ] && _global_db_cred="-U ${_dbuser} -P ${_dbpass}" || _global_db_cred="" fi fi qcSECURITY=${_global_db_cred} export qcSECURITY }