From 4b66b6d4f0ba1d9087cfd5f7c0291e92cecdf588 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 30 Mar 2015 16:42:24 +0200 Subject: [PATCH] add MySQL import script --- telemeta/util/import_sql.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 telemeta/util/import_sql.sh 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!" -- 2.39.5