diff --git a/ngcp-update-db-schema b/ngcp-update-db-schema index b120ef30..6a3124cb 100755 --- a/ngcp-update-db-schema +++ b/ngcp-update-db-schema @@ -43,6 +43,12 @@ if [ -z "${SIPWISE_DB_PASSWORD}" ] ; then exit 1 fi +# check connection with sipwise user +if ! mysql -usipwise -p${SIPWISE_DB_PASSWORD} -e 'SELECT 1;' 1>/dev/null 2>/dev/null ; then + echo 'Error: cant connect to local MySQL with sipwise user' >&2 + exit 1 +fi + # support automated installation if [ -n "$AUTOMATED_INSTALL_MODE" ] ; then echo "Running in automated installation mode, ignoring check for empty db_schema." @@ -63,12 +69,6 @@ else fi fi -# check connection with sipwise user -if ! mysql -usipwise -p${SIPWISE_DB_PASSWORD} -e 'SELECT 1;' 1>/dev/null 2>/dev/null ; then - echo 'Error: cant connect to local MySQL with sipwise user' >&2 - exit 1 -fi - if ! mysql -usipwise -p${SIPWISE_DB_PASSWORD} -e 'use ngcp;' 2>/dev/null ; then mysql -usipwise -p${SIPWISE_DB_PASSWORD} < /usr/share/ngcp-db-schema/db_scripts/init/0005_create_ngcp.up fi