summaryrefslogtreecommitdiff
path: root/localserver/initdb.sh
diff options
context:
space:
mode:
Diffstat (limited to 'localserver/initdb.sh')
-rwxr-xr-xlocalserver/initdb.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/localserver/initdb.sh b/localserver/initdb.sh
new file mode 100755
index 0000000..074f8c5
--- /dev/null
+++ b/localserver/initdb.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+export DIR="$(pwd)"
+export VER=$(cat versions/sqlver 2>/dev/null)
+
+cd ../../server-data/sql-files
+
+echo Creating db and user...
+echo Enter mysql root password:
+mysql --force -u root -p <./init.sql
+result=$?
+if [ "$result" != 0 ]; then
+ echo Password failed. Trying with sudo...
+ sudo mysql --force -u root <./init.sql
+fi
+
+export CMD="mysql -u evol -pevol evol"
+
+echo Creating tables...
+$CMD <main.sql
+$CMD <logs.sql
+
+if [[ -z "${VER}" ]]; then
+ mkdir ${DIR}/versions
+ echo "20" >${DIR}/versions/sqlver
+fi