File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ version=" 0.1.0"
3+ echo " Connecting to DB....(connect-db.sh v$version )"
4+
5+ if [ " $1 " == " -h" ]; then
6+ echo " Usage: $( basename $0 ) "
7+ exit 0
8+ fi
9+
10+ [ -z " $RG_HOME " ] && RG_HOME=' /opt/deploy/sp2'
11+ echo " RG_HOME=$RG_HOME "
12+ myinput=$( cat " $RG_HOME /config/mongo-config.json" )
13+ if [ -z " $myinput " ]; then
14+ echo " Could not find DB details file. Exiting"
15+ exit 1
16+ fi
17+
18+ mydbuser=$( jq -r ' .db_auth_config.username' <<< " ${myinput}" )
19+ mydbuserpwd=$( jq -r ' .db_auth_config.password' <<< " ${myinput}" )
20+
21+ if [ -z " $mydbuser " ] || [ -z " $mydbuserpwd " ]; then
22+ echo " Could not find DB details. Exiting"
23+ exit 1
24+ fi
25+
26+ if [ ! -f " $RG_HOME /docker-compose.yml" ]; then
27+ echo " docker-compose.yml does not exist. Exiting"
28+ exit 1
29+ fi
30+ mydocdburl=$( grep DB_HOST " $RG_HOME /docker-compose.yml" | head -1 | sed -e " s/.*DB_HOST=//" )
31+ if [ -z " $mydocdburl " ]; then
32+ echo " Could not find DB URL. Exiting"
33+ exit 1
34+ fi
35+
36+ mongo --ssl --host " $mydocdburl :27017" --sslCAFile " $RG_HOME /config/rds-combined-ca-bundle.pem" \
37+ --username " $mydbuser " --password " $mydbuserpwd "
You can’t perform that action at this time.
0 commit comments