Skip to content

Instantly share code, notes, and snippets.

@iversond
Created September 1, 2023 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iversond/4f301e4330cdea9374e9d96d86435be0 to your computer and use it in GitHub Desktop.
Save iversond/4f301e4330cdea9374e9d96d86435be0 to your computer and use it in GitHub Desktop.
Sample bash functions to prebuild cache and then copy to each PSAPPSRV_n folder
function run_loadcache(){
if [[ ${RESET} == 'true' ]]; then
echoinfo "Removing previous cache"
rm -rf ${PS_SERVDIR}/CACHE/1/*.DAT
rm -rf ${PS_SERVDIR}/CACHE/1/*.KEY
rm -rf ${PS_SERVDIR}/CACHE/STAGE/stage/*.DAT
rm -rf ${PS_SERVDIR}/CACHE/STAGE/stage/*.KEY
fi
echoinfo "Run LOADCACHE [ Task ]"
echodebug "Environment: $(env)"
echodebug "-------------------"
if [[ -n ${DEBUG+x} ]]; then
$PS_HOME/bin/psae -CT ORACLE -CD ${DATABASE} -CO @option.userid@ -CP @option.password@ -R LOADCACHE -AI LOADCACHE -CI @option.connect_id@ -CW @option.connect_pwd@
else
$PS_HOME/bin/psae -CT ORACLE -CD ${DATABASE} -CO @option.userid@ -CP @option.password@ -R LOADCACHE -AI LOADCACHE -CI @option.connect_id@ -CW @option.connect_pwd@ > /dev/null 2>&1
fi
result=$?
case $result in
0)
echoinfo "Run LOADCACHE [ Done ]"
;;
*)
echoerror "Run LOADCACHE [ Error ]"
echoerror " Result Code: ${result}"
;;
esac
return $result
}
function copy_new_cache(){
echoinfo "Copy New Cache Files [ Task ]"
FILE=/u01/app/psoft/cfg/appserv/${ENVIRONMENT}/psappsrv.cfg
if [ -f "$FILE" ]; then
minsetting=$(grep ^[[]PSAPPSRV -A10 $FILE | grep Min | cut -d '=' -f2 )
echodebug "PSAPPSRV Min: ${minsetting}"
for ((i=1; i<=minsetting; i++))
do
echodebug " Copying to PSAPPSRV_${i}"
if [[ -n ${DEBUG+x} ]]; then
mkdir -p $PS_CFG_HOME/appserv/${ENVIRONMENT}/CACHE/PSAPPSRV_${i}
cp -r $PS_SERVDIR/CACHE/STAGE/stage/* $PS_CFG_HOME/appserv/${ENVIRONMENT}/CACHE/PSAPPSRV_${i}/
else
mkdir -p $PS_CFG_HOME/appserv/${ENVIRONMENT}/CACHE/PSAPPSRV_${i} > /dev/null 2>&1
cp -r $PS_SERVDIR/CACHE/STAGE/stage/* $PS_CFG_HOME/appserv/${ENVIRONMENT}/CACHE/PSAPPSRV_${i}/ > /dev/null 2>&1
fi
done
echoinfo "Copy New Cache Files [ Done ]"
else
echoinfo "${ENVIRONMENT} does not not have an app server on this instance."
fi
}
function echoinfo() {
local GC="\033[1;32m"
local EC="\033[0m"
printf "${GC} ☆ INFO${EC}: %s${GC}\n" "$@";
}
function echodebug() {
local BC="\033[1;34m"
local EC="\033[0m"
local GC="\033[1;32m"
if [[ -n ${DEBUG+x} ]]; then
printf "${BC} ★ DEBUG${EC}: %s${GC}\n" "$@";
fi
}
function echoerror() {
local RC="\033[1;31m"
local EC="\033[0m"
printf "${RC} ✖ ERROR${EC}: %s\n" "$@" 1>&2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment