From a6dcea5e09c877a4c7c9e877239b2f42d8c4ecda Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Wed, 12 May 2021 23:22:47 +0200 Subject: [PATCH] TT#122035 Allow ngcp-synd-db to sync passwords from db01 on Carrier The bullsyeye-based MariaDB 10.5.9 has invalid root password set by default. It is not possible to connect DB instance from network, the only option is to connect DB instance through the socket. The ngcp-installer calls ngcp-sync-db to replicate db01:3306->prx01:3308 on proxy node for the Carrier case. We have to open networking root access temporary. ngcp-sync-db will replicate 'root' password from db01 the next moment. Also update '1>/dev/null 2>/dev/null' to Sipwise style '&>/dev/null'. Change-Id: I12ff71efdd8283531f03ceaf87345f3cc4e71419 --- ngcp-update-db-schema | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ngcp-update-db-schema b/ngcp-update-db-schema index 9498b988..ebc92f52 100755 --- a/ngcp-update-db-schema +++ b/ngcp-update-db-schema @@ -54,7 +54,7 @@ declare -a MYSQL_OPTS=() MYSQL_OPTS+=("--defaults-extra-file=${SIPWISE_EXTRA_CNF}") # check connection with sipwise user -if ! mysql "${MYSQL_OPTS[@]}" -e 'SELECT 1;' 1>/dev/null 2>/dev/null ; then +if ! mysql "${MYSQL_OPTS[@]}" -e 'SELECT 1;' &>/dev/null ; then echo "Error: can't connect to local MariaDB port 3306 using '${SIPWISE_EXTRA_CNF}'" >&2 exit 1 fi @@ -250,6 +250,19 @@ revision_wrapper $(printf '%s\0' *.up | sort -z -n | while IFS= read -r -d "" fi # for carrier prx* hosts sync master-slave replication for not_replicated statements (if any) if $RUN_SYNC_DB && ($NOT_REPLICATED_REV_APPLIED || [ -n "$AUTOMATED_INSTALL_MODE" ]); then + + # check connection to MariaDB on port 3308 using socket to bypass auth as root has invalid password + if ! mysql -S /run/mysqld/mysqld2.sock -e 'SELECT 1;' &>/dev/null ; then + echo "Error: can't connect to local MariaDB:3308 using socket '/run/mysqld/mysqld2.sock'" >&2 + exit 1 + fi + + # Reset 'root' password temporary to allow ngcp-sync-db replicate all credentials from db01 + if ! mysql -S /run/mysqld/mysqld2.sock -e "SET PASSWORD FOR root@localhost = '';" 2>/dev/null ; then + echo "Error: Failed to temporary reset password for user 'root' on MariaDB:3308" >&2 + exit 1 + fi + if [ -x "$SYNC_DB" ] ; then PRX_SYNC_DBS="ngcp billing carrier kamailio provisioning prosody mysql" PRX_IGNORE_TABLES="kamailio.voicemail_spool"