-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
55 lines (45 loc) · 1.31 KB
/
entrypoint.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
#!/usr/bin/env bash
echo "[client]
user=${DB_USER}
password=${DB_PASS}
host=${DB_HOST}" > ~/.my.cnf
chmod 600 ~/.my.cnf
if [[ ! -f "Server.jar" ]]
then
if [[ ! -f "download/callersbane.zip" ]]
then
mkdir -p download
curl -o download/callersbane.zip "https://download.scrolls.com/callersbane/server/CallersBane-Server-2.0.1.zip"
fi
cp download/callersbane.zip .
unzip callersbane.zip
cp -rf CallersBane-Server/* .
rm -rf CallersBane-Server
if [[ ! -f "Server.jar" ]]
then
echo "Failed to get Server.jar"
exit 1
fi
fi
while ! mysqladmin ping --silent
do
echo "Waiting for database to be active"
sleep 1
done
result=$(mysql -s -N -e "SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='scrolls'")
if [ "$result" -eq "0" ]
then
echo "Creating database"
mysql < callersbane_database.sql
fi
# update db with our IP in the config
mysql -e "UPDATE scrolls.servers SET ip = '${SERVER_IP}', port = '${SERVER_PORT}' WHERE id = '${NODE_ID}'"
java \
-Xmx${MEMORY} \
-Dio.netty.epollBugWorkaround=true \
-Dscrolls.mode=PROD \
-Dscrolls.node.id=${NODE_ID} \
-Dhibernate.connection.url="jdbc:mysql://${DB_HOST}:3306/scrolls" \
-Dhibernate.connection.username="${DB_USER}" \
-Dhibernate.connection.password="${DB_PASS}" \
-jar turtles-3.0-SNAPSHOT.jar