Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bunch of improvements. #2

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions odinms/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
FROM java:6

RUN apt-get update
RUN apt-get install -y vim

RUN echo 'alias ll="ls -lha --color=auto"' >> ~/.bashrc

WORKDIR /odinms

COPY thepack_82 .
Expand All @@ -14,3 +9,5 @@ EXPOSE 7576
EXPOSE 7577
EXPOSE 7578
EXPOSE 8484

CMD ["/bin/bash","compile_and_run.sh"]
2 changes: 1 addition & 1 deletion odinms/thepack_82/ThePack/channel.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
net.sf.odinms.world.host=THIS_IP
net.sf.odinms.world.host=maplestory
net.sf.odinms.channel.count=2
net.sf.odinms.channel.0.key=release1
net.sf.odinms.channel.1.key=release2
2 changes: 1 addition & 1 deletion odinms/thepack_82/ThePack/db.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://ODINMS_MYSQL_CONTAINER_IP_ADDRESS/odinms
url=jdbc:mysql://maplestory-db/odinms
user = root
password = root
2 changes: 1 addition & 1 deletion odinms/thepack_82/ThePack/login.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
net.sf.odinms.world.host=THIS_IP
net.sf.odinms.world.host=maplestory
net.sf.odinms.login.key=releaselogin
7 changes: 0 additions & 7 deletions odinms/thepack_82/ThePack/run.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/usr/bin/env bash

THIS_IP=`grep $HOSTNAME /etc/hosts | awk '{print $1}'`

sed -i "s/ODINMS_MYSQL_CONTAINER_IP_ADDRESS/$ODINMS_MYSQL_CONTAINER_IP_ADDRESS/" db.properties
sed -i "s/THIS_IP/$THIS_IP/" world.properties
sed -i "s/THIS_IP/$THIS_IP/" login.properties
sed -i "s/THIS_IP/$THIS_IP/" channel.properties

java -cp '.:dist/*' -Dnet.sf.odinms.recvops=recvops.properties -Dnet.sf.odinms.sendops=sendops.properties -Dnet.sf.odinms.wzpath=wz -Djavax.net.ssl.keyStore=filename.keystore -Djavax.net.ssl.keyStorePassword=passwd -Djavax.net.ssl.trustStore=filename.keystore -Djavax.net.ssl.trustStorePassword=passwd net.sf.odinms.net.world.WorldServer &
sleep 10
java -cp '.:dist/*' -Dnet.sf.odinms.recvops=recvops.properties -Dnet.sf.odinms.sendops=sendops.properties -Dnet.sf.odinms.wzpath=wz -Dnet.sf.odinms.login.config=login.properties -Djavax.net.ssl.keyStore=filename.keystore -Djavax.net.ssl.keyStorePassword=passwd -Djavax.net.ssl.trustStore=filename.keystore -Djavax.net.ssl.trustStorePassword=passwd net.sf.odinms.net.login.LoginServer &
Expand Down
4 changes: 4 additions & 0 deletions odinms/thepack_82/compile_and_run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env bash

sed -i "s/THIS_IP/$THIS_IP/g" ./ThePack/world.properties

cd ThePack
source compile.sh && source run.sh

sleep infinity
35 changes: 30 additions & 5 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
#!/usr/bin/env bash

# Build images.
docker build -t odinms_mysql odinms_mysql
docker build -t odinms odinms

ODINMS_MYSQL_CONTAINER_ID=`docker run -d -p 3306:3306 odinms_mysql`
# Create private bridge network - connects the game and database servers.
NETWORK=`docker network ls | grep thepack | awk {'print $2'}`
if [[ ! $NETWORK == "thepack" ]]; then
docker network create thepack
fi

ODINMS_MYSQL_CONTAINER_IP_ADDRESS=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $ODINMS_MYSQL_CONTAINER_ID`
# Create volume for MySQL data.
VOLUME=`docker volume ls | grep -w thepack-db | awk {'print $2'}`
if [[ ! $VOLUME == "thepack-db" ]]; then
docker volume create thepack-db
fi

#docker run -it --rm -e ODINMS_MYSQL_CONTAINER_IP_ADDRESS=$ODINMS_MYSQL_CONTAINER_IP_ADDRESS -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 odinms bash -c 'source compile_and_run.sh'
docker run -it --rm -e ODINMS_MYSQL_CONTAINER_IP_ADDRESS=$ODINMS_MYSQL_CONTAINER_IP_ADDRESS -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 odinms bash
# Run containers.
DB_CONTAINER=`docker container ps | grep -w odinms_mysql | awk {'print $2'}`
if [[ ! $DB_CONTAINER == "odinms_mysql" ]]; then
docker run -d --volume thepack-db:/var/lib/mysql --network thepack --name maplestory-db odinms_mysql
fi

docker rm -f $ODINMS_MYSQL_CONTAINER_ID
# Sleep needed to avoid race condition.
sleep 5

MS_CONTAINER=`docker container ps | grep -w odinms | awk {'print $2'}`
if [[ ! $MS_CONTAINER == "odinms" ]]; then

# Best effort attempt at getting the server IP address. idk, better than localhost?
HOST_IP=`ifconfig | grep -w inet | grep -v 127.0.0.1 | grep -v broadcast\ 172 | awk {'print $2'} | tail -n 1`

docker run -d -e THIS_IP=${HOST_IP} -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --network thepack --name maplestory odinms

# Add "maplestory" container to the default bridge network - so it can use the host IP.
docker network connect bridge maplestory
fi