Files
mmt_sql/scripts/onetime_compile.sh
2021-10-28 09:12:13 +00:00

63 lines
2.3 KiB
Bash
Executable File

#!/bin/bash -e
#/****************************************************************
#****** ForeWarn Licensing and / or usage Terms and Conditions *****
#ForeWarn. The NextGen Insights Solution Platform
#Copyright © 2021 COMPEGENCE. All Rights Reserved
#ForeWarn is a product of COMPEGENCE.
#To be used only with a valid license from COMPEGENCE
#www.compegence.com info@compegence.com
#****************************************************************/
#HOME="/home/compegence/customer"
#Directories
homeDir=$HOME/customer/MMT
configDir=$homeDir/conf
input_file=$configDir/etl-config.txt
declare -A credentials
while IFS="=" read -r key value; do
credentials[$key]=$value
done < <( sed -e '/^\s*$/ d' -e '/^#/ d' $input_file )
#for i in ${credentials[@]}; do echo ***$i; done
user=${credentials[user]}
password=${credentials[password]}
host=${credentials[host]}
db=${credentials[db]}
protocol=${credentials[protocol]}
server=${credentials[server]}
mmt_con="psql -X -q -A -t postgresql://$user:$password@$host/$db?options=--search_path%3D"
#declare -a archivepathvar=("$homeDir/sql/onetime/archive/schema")
declare -a archivepathsvar=("$homeDir/sql/onetime/archive/create" "$homeDir/sql/onetime/archive/function")
declare -a trxpathvar=("$homeDir/sql/onetime/createtables/common" "$homeDir/sql/onetime/createtables/ods" "$homeDir/sql/onetime/createtables/control" "$homeDir/sql/onetime/commonfunctions" "$homeDir/sql/onetime/configentries" "$homeDir/sql/onetime/dataloadfunctions/ODS_Load")
declare -a stgpathvar=("$homeDir/sql/onetime/createtables/staging" "$homeDir/sql/onetime/dataloadfunctions/budni" "$homeDir/sql/onetime/dataloadfunctions/Drawbar" "$homeDir/sql/onetime/dataloadfunctions/IHT" "$homeDir/sql/onetime/dataloadfunctions/field" "$homeDir/sql/onetime/dataloadfunctions/PTO" "$homeDir/sql/onetime/wrappers")
func_execute_conn(){
local conn="$1"
local -n param=$2
for path in "${param[@]}"
do
for files in "$path"/*
do
$conn -f $files
done
done
}
#func_execute_conn "$mmt_con'archive'" archivepathvar
func_execute_conn "$mmt_con'staging2'" stgpathvar
func_execute_conn "$mmt_con'trx'" trxpathvar
func_execute_conn "$mmt_con'archive'" archivepathsvar