vitess.io/vitess@v0.16.2/examples/compose/vtorc-up.sh (about) 1 #!/bin/bash 2 3 # Copyright 2020 The Vitess Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -u 18 19 external=${EXTERNAL_DB:-0} 20 web_port=${WEB_PORT:-'8080'} 21 config=${VTORC_CONFIG:-/vt/vtorc/config.json} 22 # Copy config directory 23 cp -R /script/vtorc /vt 24 # Update credentials 25 if [ $external = 1 ] ; then 26 # Terrible substitution but we don't have jq in this image 27 # This can be overridden by passing VTORC_CONFIG env variable 28 echo "Updating $config..." 29 cp /vt/vtorc/default.json /vt/vtorc/tmp.json 30 sed -i '/MySQLTopologyUser/c\ \"MySQLTopologyUser\" : \"'"$DB_USER"'\",' /vt/vtorc/tmp.json 31 sed -i '/MySQLTopologyPassword/c\ \"MySQLTopologyPassword\" : \"'"$DB_PASS"'\",' /vt/vtorc/tmp.json 32 sed -i '/MySQLReplicaUser/c\ \"MySQLReplicaUser\" : \"'"$DB_USER"'\",' /vt/vtorc/tmp.json 33 sed -i '/MySQLReplicaPassword/c\ \"MySQLReplicaPassword\" : \"'"$DB_PASS"'\",' /vt/vtorc/tmp.json 34 cat /vt/vtorc/tmp.json 35 cp /vt/vtorc/tmp.json /vt/vtorc/config.json 36 else 37 cp /vt/vtorc/default.json /vt/vtorc/config.json 38 fi 39 40 echo "Starting vtorc..." 41 exec /vt/bin/vtorc \ 42 $TOPOLOGY_FLAGS \ 43 --logtostderr=true \ 44 --port $web_port \ 45 --config $config