-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
62 lines (53 loc) · 1.65 KB
/
setup.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Get the directory this file is in (the project base)
basedir=$(cd $(dirname $0) && pwd)
mysql=mysql # mysql executable
host=localhost # mysql host
username= # mysql user
passwd= # mysql password
# parse the command line parameters
while getopts 'm:h:u:p:d:' OPTION
do case "$OPTION" in
m) mysql="$OPTARG"
;;
h) host="$OPTARG"
;;
u) username="$OPTARG"
;;
p) passwd="$OPTARG"
;;
?) printf "Reloads the MMOServerDB install\n"
printf ""
exit 2
;;
esac
done
shift $(($OPTIND - 1))
for i in $(find . ! -name . -type d -prune)
do
schema=$(basename $i)
if [ ! -f $i/create.sql ]; then
continue;
fi
if [ -f $i/create_users.sql ]; then
$mysql -u $username -p$passwd -h $host --default-character-set=utf8 <$i/create_users.sql
printf "Installing create_users.sql [Done]\n"
fi
$mysql -u $username -p$passwd -h $host --default-character-set=utf8 <$i/create.sql
printf "Installing create.sql [Done]\n"
for j in $(find $i/scripts -name *.sql)
do
$mysql -u $username -p$passwd -h $host --database=$schema --default-character-set=utf8 <$j
printf "Installing $j [Done]\n"
done
for j in $(find $i/functions -name *.sql)
do
$mysql -u $username -p$passwd -h $host --database=$schema --default-character-set=utf8 <$j
printf "Installing $j [Done]\n"
done
for j in $(find $i/procedures -name *.sql)
do
$mysql -u $username -p$passwd -h $host --database=$schema --default-character-set=utf8 <$j
printf "Installing $j [Done]\n"
done
done