adding option to skip db create (#39)

* adding option to skip db create

* adding default value of false to SKIP_DB_CREATE

Co-authored-by: Ian Clark <ian.clark@dreamhost.com>
This commit is contained in:
Ian Clark 2020-09-04 09:55:40 -07:00 committed by GitHub
parent 051123a773
commit 5e83d1be5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,9 @@ until $MYSQL_COMMAND -e ';' ; do
sleep 3 sleep 3
done done
if [ "${SKIP_DB_CREATE:-false}" != 'true' ]; then
$MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_gmysql_dbname}" $MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_gmysql_dbname}"
fi
MYSQL_CHECK_IF_HAS_TABLE="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${PDNS_gmysql_dbname}';" MYSQL_CHECK_IF_HAS_TABLE="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${PDNS_gmysql_dbname}';"
MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_HAS_TABLE") MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_HAS_TABLE")