Last active
November 28, 2018 18:23
-
-
Save tpjfern03/d496535de452a7eae46c0aaf21cd51fc to your computer and use it in GitHub Desktop.
Linux Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| export DATE_0=`date +'%m/%d/%Y'` | |
| export TIMESTAMP=`date +'%Y%m%d%H%M%S'` | |
| PROGNAME=$(basename $0) | |
| error_exit() | |
| { | |
| echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 | |
| exit 1 | |
| } | |
| echo `date` | |
| CWD=$(pwd) | |
| cd /home/acs || error_exit "Cannot change directory! Aborting" | |
| cd /home/acs | |
| mkdir /home/acs/omsDashboard || error_exit "Cannot create directory /home/acs/omsDashboard! Aborting" | |
| cd omsDashboard | |
| cd $CWD | |
| tar -xvf omsDash.tar.gz -C /home/acs/omsDashboard || error_exit "Cannot untar omsDash.tar.gz! Aborting" | |
| cd /home/acs/omsDashboard | |
| echo "Application Directory: " `pwd` | |
| rm -f install.sh | |
| cat << EOF | |
| >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| 1) cd to /home/acs/omsDashboard | |
| 2) Update the omsDash.yaml for your environment: | |
| Change host to this server IP in the general section | |
| Change database settings to connect to your local database in the database section | |
| Save and exit | |
| 3) Run the app: ./omsDash | |
| 4) Connect via browser: <IP>:port | |
| 5) Shutdown the app: Ctrl-C | |
| Check the logs in this folder if there are no updates in the browser. | |
| >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| EOF | |
| ####################################### | |
| . /home/acs/.profile > /dev/null 2>&1 | |
| export ORACLE_DBSTRING_HDA=EMS | |
| unset ORACLE_USER | |
| ####################################### | |
| echo 'Check database connectivity.................................' | |
| if sqlplus ${EVENT_USER}/${EVENT_PWD}@${SID} < /dev/null | grep 'Connected to'; then | |
| # have connectivity to Oracle | |
| echo "Connection established." | |
| else | |
| # No connectivity | |
| echo "Connection failed." | |
| exit 0 | |
| fi | |
| ####################################### | |
| echo 'Migrating HDA_POINTS_DEFS Points -> UTIL_POINT_DEFS .......................' | |
| sqlplus -s ${ORACLE_USER_HDA}/${ORACLE_PW_HDA}@${ORACLE_DBSTRING_HDA} << END_SQL > ${TEMPLOG} 2>&1 | |
| set head off; | |
| set pagesize 0; | |
| select count(*) from HDA_POINT_DEFS: | |
| END_SQL | |
| #RC=`cat $TEMPLOG | grep -i error | wc -l` | |
| RC=`cat $TEMPLOG | grep [0-9] | cut -c1-5` | |
| if [ "${RC}" -eq 0 ]; then | |
| echo 'No HDC Points imported...' | |
| exit 0 | |
| else | |
| echo 'HDC Points imported... ${RC}' | |
| fi | |
| ####################################### | |
| cat loadDrefs.log | grep "Rows successfully loaded." > temp.log | |
| IFS=" " | |
| while read -r records b c d; do | |
| export RC=$records | |
| #echo "${RC}" | |
| done < temp.log | |
| #echo "Result:${RC}" | |
| if [[ "${RC}" -ne "0" ]]; then | |
| #Data was loaded | |
| echo `cat temp.log` | |
| else | |
| #Data Errors | |
| echo "Data Load Errors..." | |
| cat loadDrefs.log | grep "Rows not loaded because all WHEN clauses were failed" > temp.log | |
| #RC=`cat temp.log | grep -i errors | wc -l` | |
| echo `cat temp.log` | |
| cat loadDrefs.log | grep "Rows not loaded because all fields were null" > temp.log | |
| #RC=`cat temp.log | grep -i failed | wc -l` | |
| echo `cat temp.log` | |
| exit 1 | |
| fi | |
| sleep 2 | |
| ####################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment