You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
system-tests/sbin/ngcp-mysql-compare-dbs

79 lines
1.6 KiB

#!/bin/bash
set -euo pipefail
usage() {
cat - <<__USAGE__
$(basename "$0") used to compare mysql schemes between two hosts.
Usage: $(basename "$0") [options]
Options:
--formatter=[tap] - Specify the output format.
Skip it to get human readable output.
-h|--help - Show this message.
__USAGE__
}
get_local_instances() {
local_instances+=("${NGCP_HOSTNAME}:3306")
if [[ "${NGCP_TYPE}" == 'carrier' && "${NGCP_IS_PROXY}" == 'yes' ]]; then
local_instances+=("${NGCP_HOSTNAME}:3308")
fi
}
FORMATTER=''
args=$(getopt -n "$(basename "$0")" -o h -l help,formatter: -- "$@")
eval set -- "${args}"
while true; do
case "${1}" in
--formatter)
FORMATTER="${2}"
shift 2
;;
-h|--help)
usage
exit 0
;;
--)
shift
break
;;
*)
log_error "Unknown parameter '${1}'"
exit 1
;;
esac
done
NGCP_ROLES='/etc/default/ngcp-roles'
if [[ ! -r "${NGCP_ROLES}" ]]; then
echo "Cannot read mandatory config file ${NGCP_ROLES}" 2>&1
exit 1
fi
. "${NGCP_ROLES}"
MYSQL_CREDENTIALS='/etc/mysql/sipwise_extra.cnf'
if [[ ! -r "${MYSQL_CREDENTIALS}" ]]; then
echo "Cannot read mandatory config file '${MYSQL_CREDENTIALS}'" 2>&1
exit 1
fi
declare -a opts
if [[ -n "${FORMATTER}" ]]; then
opts+=(--formatter="${FORMATTER}")
fi
declare -a local_instances=()
get_local_instances
for local_mysql in "${local_instances[@]}"; do
/usr/share/ngcp-system-tests/compare_dbs.pl \
--host-db1="${local_mysql%:*}" \
--port-db1="${local_mysql#*:}" \
"${opts[@]}"
done