TT#68026 Migrate k-c-t from /etc/mysql/sipwise.cnf to /etc/mysql/sipwise_extra.cnf

Change-Id: I9319a932d9c429d9722dfc1451341e6157036525
changes/88/34088/1
Alexander Lutay 6 years ago
parent e136fbc859
commit 693be79d5c

@ -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"

@ -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
}

Loading…
Cancel
Save