From: Guillaume Pellerin Date: Mon, 30 Mar 2015 14:42:24 +0000 (+0200) Subject: add MySQL import script X-Git-Tag: 1.6a^2~38 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=4b66b6d4f0ba1d9087cfd5f7c0291e92cecdf588;p=telemeta.git add MySQL import script --- diff --git a/telemeta/util/import_sql.sh b/telemeta/util/import_sql.sh new file mode 100755 index 00000000..10c0ca4c --- /dev/null +++ b/telemeta/util/import_sql.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +if [[ $# -ne 4 ]]; then + echo "Usage: $0 " + exit 1 +fi + +echo "=> Starting MySQL Server" +/usr/bin/mysqld_safe > /dev/null 2>&1 & +PID=$! + +RET=1 +while [[ RET -ne 0 ]]; do + echo "=> Waiting for confirmation of MySQL service startup" + sleep 5 + mysql -u"$1" -p"$2" -e "status" > /dev/null 2>&1 +RET=$? +done + +echo " Started with PID ${PID}" + +echo "=> Importing SQL file" +gunzip -c "$4" | mysql -u"$1" -p"$2" "$3" + +echo "=> Stopping MySQL Server" +mysqladmin -u"$1" -p"$2" shutdown + +echo "=> Done!"