#!/bin/bash

function external_database_config() {
    ssh ${DEPLOYED_MANAGER} "sed -i 's/^\s*#\s*\(DatabaseType=\).*/\1'${DatabaseType}'/g' ${DOCKER_COMPOSE_DIR}/${ENVFILE}"
    ssh ${DEPLOYED_MANAGER} "sed -i 's/^\s*#\s*\(DatabaseServerName=\).*/\1'${DatabaseServerName}'/g' ${DOCKER_COMPOSE_DIR}/${ENVFILE}"
    ssh ${DEPLOYED_MANAGER} "sed -i 's/^\s*#\s*\(DatabaseServerPort=\).*/\1'${DatabaseServerPort}'/g' ${DOCKER_COMPOSE_DIR}/${ENVFILE}"
    ssh ${DEPLOYED_MANAGER} "sed -i 's/^\s*#\s*\(DatabaseUserName=\).*/\1'${DatabaseUserName}'/g' ${DOCKER_COMPOSE_DIR}/${ENVFILE}"
    ssh ${DEPLOYED_MANAGER} "sed -i 's/^\s*#\s*\(DatabasePassword=\).*/\1'${DatabasePassword}'/g' ${DOCKER_COMPOSE_DIR}/${ENVFILE}"
}

function remove_mysql_from_compose_file() {
    ssh ${DEPLOYED_MANAGER} "sed -i '/^#.*SVC:mysql:>>>/,/^#.*SVC:mysql:<<</s/^/#/g' ${DOCKER_COMPOSE_DIR}/middleware-master-${MIDDLEWARE_MODE}.yml"
}

function add_mysql_from_compose_file() {
    ssh ${DEPLOYED_MANAGER} "sed -i '/^#.*SVC:mysql:>>>/,/^#.*SVC:mysql:<<</s/^#//g' ${DOCKER_COMPOSE_DIR}/middleware-master-${MIDDLEWARE_MODE}.yml"
}
