-
Notifications
You must be signed in to change notification settings - Fork 7
/
linux_installer.sh
158 lines (135 loc) · 5.5 KB
/
linux_installer.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# Modified script from WhyDB
############################################################################
#
# Tool Configuration
#
# user - MYSQL username
# pass - MYSQL password
# wdb - Your world database
#
############################################################################
user="mysql_user"
pass="mysql_password"
wdb="wow_world"
############################################################################
#
# Server configuration, do not edit past this point
#
############################################################################
server="localhost"
port="3306"
devpath="./main_db/world"
procpath="./main_db/procs"
uppath="./world_updates"
bkpath="dump"
############################################################################
#
# Create a backup folder, if one doesn't exist
#
############################################################################
if [ ! -d "${bkpath}" ]; then
mkdir "${bkpath}"
chmod 0755 "${bkpath}"
fi
############################################################################
#
# Main program
#
############################################################################
until [ "${option}" = "x" ]; do
logo
echo " i - Install Clean World Database"
echo " u - Update World Database"
echo " x - Exit Tool"
echo
read -p " Enter option: " option
if [ "${option}" = "i" ]; then
mysqldump -h ${server} --user=${user} --port=${port} --password=${pass} --add-drop-table --no-data ${wdb} | grep ^DROP | mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${wdb}
echo
echo
echo " [Cleaning World DB] Finished..."
echo " Adding Stored Procedures"
max=`ls -1 "${procpath}"/*.sql | wc -l`
e=0
for table in "${procpath}"/*.sql; do
e=$((${i}+1))
echo " [${e}/${max}] import: ${table##*/}"
mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${wdb} < "${table}"
done
echo " Adding Adding Stored Procedures Complete"
echo " Importing world data"
max=`ls -1 "${devpath}"/*.sql | wc -l`
i=0
for table in "${devpath}"/*.sql; do
i=$((${i}+1))
echo " [${i}/${max}] import: ${table##*/}"
mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${wdb} < "${table}"
done
echo
echo " [Importing] Finished..."
elif [ "${option}" = "b" ]; then
echo
rm -rf "${bkpath}/logon_backup.sql"
rm -rf "${bkpath}/character_backup.sql"
echo " [Deleting Old Backups] Finished..."
echo
mysqldump -h ${server} --user=${user} --port=${port} --password=${pass} ${ldb} > "${bkpath}/logon_backup.sql"
echo " [Backing Up Logon Database] Finished..."
mysqldump -h ${server} --user=${user} --port=${port} --password=${pass} ${cdb} > "${bkpath}/character_backup.sql"
echo " [Backing Up Char Database] Finished..."
echo
echo " [Backing Up] Finished..."
elif [ "${option}" = "r" ]; then
echo
mysqldump -h ${server} --user=${user} --port=${port} --password=${pass} --add-drop-table --no-data ${ldb} | grep ^DROP | mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${ldb}
echo " [Emptying Logon Database] Finished..."
mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${ldb} < "${bkpath}/logon_backup.sql"
echo " [Restoring Logon Database From Backup] Finished..."
echo
mysqldump -h ${server} --user=${user} --port=${port} --password=${pass} --add-drop-table --no-data ${cdb} | grep ^DROP | mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${cdb}
echo " [Emptying Char Database] Finished..."
mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${cdb} < "${bkpath}/character_backup.sql"
echo " [Restoring Char Database From Backup] Finished..."
echo
echo " [Restoring Backup] Finished..."
elif [ "${option}" = "u" ]; then
available_changesets="${uppath}/changeset_*.sql"
if [ "${available_changesets}" != "${uppath}/changeset_*.sql" ]; then
echo
echo " Here's a list of available updates:"
echo
for changeset in ${available_changesets[@]};
do
echo " ${changeset##*/}"
done
echo
read -p " Which update would you like to import (type x to abort): " index
if [ "${index}" != "x" ]; then
update="${uppath}/changeset_${index}.sql"
if [ ! -f "${update}" ]; then
echo
echo " ${update} file does not exist."
else
echo
echo " Importing changeset ${index}."
mysql -h ${server} --user=${user} --port=${port} --password=${pass} ${wdb} < "${update}"
echo
echo " [Updating World Database] Finished..."
fi
fi
else
echo
echo " Currently, no updates are available."
fi
elif [ "${option}" != "x" ]; then
echo
read -p " Incorrect option '${option}'."
echo
fi
if [ "${option}" != "x" ]; then
echo
read -p " Press any key to continue..."
echo
fi
done