diff --git a/bin/cdr_extract.sh b/bin/cdr_extract.sh index d5bdac8f..ef60627b 100755 --- a/bin/cdr_extract.sh +++ b/bin/cdr_extract.sh @@ -25,7 +25,12 @@ MUTE=false # sipwise password for mysql connections -. /etc/mysql/sipwise.cnf +declare -r SIPWISE_EXTRA_CNF="/etc/mysql/sipwise_extra.cnf" + +if [ ! -f "${SIPWISE_EXTRA_CNF}" ]; then + echo "Error: missing DB credentials file '${SIPWISE_EXTRA_CNF}'." >&2 + exit 1 +fi usage() { @@ -70,7 +75,7 @@ LOG_DIR="${BASE_DIR}/log/${GROUP}/${NAME_CHECK}" if ! "${MUTE}" ; then echo "$(date) - Exporting generated CDRs" fi -mysql -usipwise -p"${SIPWISE_DB_PASSWORD}" accounting \ +mysql --defaults-extra-file="${SIPWISE_EXTRA_CNF}" accounting \ -e "select * from cdr where call_id like 'NGCP\%${NAME_CHECK}\%%' and start_time > ${START_TIME} order by id desc limit 10\G" > "${LOG_DIR}/cdr.txt" || true if ! "${MUTE}" ; then echo "$(date) - Done" diff --git a/bin/check.sh b/bin/check.sh index 53b3e9f4..14d617f5 100755 --- a/bin/check.sh +++ b/bin/check.sh @@ -34,7 +34,12 @@ CDR=false # sipwise password for mysql connections -. /etc/mysql/sipwise.cnf +declare -r SIPWISE_EXTRA_CNF="/etc/mysql/sipwise_extra.cnf" + +if [ ! -f "${SIPWISE_EXTRA_CNF}" ]; then + echo "Error: missing DB credentials file '${SIPWISE_EXTRA_CNF}'." >&2 + exit 1 +fi # $1 kamailio msg parsed to yml @@ -296,17 +301,17 @@ delete_locations() { done # check what's in the DDBB - f=$(mysql -usipwise -p"${SIPWISE_DB_PASSWORD}" \ + f=$(mysql --defaults-extra-file="${SIPWISE_EXTRA_CNF}" \ kamailio -e 'select count(*) from location;' -s -r | head) if [ "${f}" != "0" ]; then echo "$(date) Cleaning location table" - sub=$(mysql -usipwise -p"${SIPWISE_DB_PASSWORD}" \ + sub=$(mysql --defaults-extra-file="${SIPWISE_EXTRA_CNF}" \ -e 'select concat(username, "@", domain) as user from kamailio.location;' \ -r -s | head| uniq|xargs) for f in $sub; do ngcp-kamctl proxy fifo ul.rm location "${f}" >/dev/null done - mysql -usipwise -p"${SIPWISE_DB_PASSWORD}" \ + mysql --defaults-extra-file="${SIPWISE_EXTRA_CNF}" \ -e 'delete from kamailio.location;' || true fi }