more cloud features (#1058)
[openemr.git] / cloud / assets / eb / 09-couchdb-configuration.config
blob7a3fd33b66d6ac1f43a53a9ace21721b86102dee
1 commands:
2   create_post_dir:
3     command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
4     ignoreErrors: true
6 files:
7   "/opt/elasticbeanstalk/hooks/appdeploy/post/09-couchdb-configuration.sh":
8       mode: "000755"
9       content : |
10         #!/bin/bash
12         if [ "$(/opt/elasticbeanstalk/bin/get-config environment | jq -r .COUCHDBZONE)" == "null" ]
13           then exit 0
14         fi
16         if [ -f "/tmp/couchdbzone.json" ]
17           then exit 0
18         fi
20         CURRENTIP=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1  -d'/'`
21         CURRENT24=`echo $CURRENTIP |  sed -E 's/^([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*).*$/\1/'`
22         COUCHDBHOSTNAME=`/opt/elasticbeanstalk/bin/get-config environment | jq -r .COUCHDBZONE | jq -r .segment24\[\"$CURRENT24\"\]`
23         if [ "$COUCHDBHOSTNAME" != "null" ]
24           then
25             COUCHDBIP=`host $COUCHDBHOSTNAME | awk '/has address/ { print $4 ; exit }'`
26             echo $COUCHDBIP couchdb.openemr.local >> /etc/hosts
27         fi