#!/bin/sh

echo "MaNGOS DB patcher"
echo ""

cat README
echo ""

read -p "Press any key to continue."
echo ""

read -p "MySQL DB name: " dbname
read -p "MySQL login: " user

stty -echo
read -p "MySQL password: " pass
stty echo
echo ""
echo ""

export MYSQL_PWD=$pass

mysqlcmd="mysql -u $user -D $dbname"

echo "Stage 1..."
cd stage1
for sqlstatement in `ls *.sql`; do $mysqlcmd < $sqlstatement; done;

echo "Stage 2..."
cd ../stage2
for sqlstatement in `ls *.sql`; do $mysqlcmd < $sqlstatement; done;

echo "Stage 3..."
cd ../stage3
for sqlstatement in `ls *.sql`; do $mysqlcmd < $sqlstatement; done;

echo "Done."
