summaryrefslogtreecommitdiff
path: root/localserver/initdb.sh
blob: 5a5db2d678e3b1b97064386e56322f6bcf94829e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash

export DIR="$(pwd)"
export VER=$(cat versions/sqlver 2>/dev/null)

cd ../../serverdata/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 "19" >${DIR}/versions/sqlver
fi