From 3ae56622944eec14087b8f1f4c5b9525e884c043 Mon Sep 17 00:00:00 2001 From: Omni Date: Fri, 30 Nov 2018 23:35:59 +0000 Subject: [PATCH 01/16] Removing commented line. --- run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/run.sh b/run.sh index ed3a8105..b71a1f74 100644 --- a/run.sh +++ b/run.sh @@ -7,7 +7,6 @@ ODINMS_MYSQL_CONTAINER_ID=`docker run -d -p 3306:3306 odinms_mysql` ODINMS_MYSQL_CONTAINER_IP_ADDRESS=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $ODINMS_MYSQL_CONTAINER_ID` -#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 docker rm -f $ODINMS_MYSQL_CONTAINER_ID From f16b648da8f4fca33109505619e35a1eb3e705f5 Mon Sep 17 00:00:00 2001 From: Omni Date: Fri, 30 Nov 2018 23:38:26 +0000 Subject: [PATCH 02/16] Removed vim and the ll alias - Going to fix the environment instead. --- odinms/Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/odinms/Dockerfile b/odinms/Dockerfile index 176b26cc..ad36fe55 100644 --- a/odinms/Dockerfile +++ b/odinms/Dockerfile @@ -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 . From 61ddba3441266586412bcfbdde69673068d76975 Mon Sep 17 00:00:00 2001 From: Omni Date: Fri, 30 Nov 2018 23:51:53 +0000 Subject: [PATCH 03/16] Removed interactive mode. Gave containers a name. Removing random junk. --- odinms/Dockerfile | 2 ++ run.sh | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/odinms/Dockerfile b/odinms/Dockerfile index ad36fe55..a4eb2e2d 100644 --- a/odinms/Dockerfile +++ b/odinms/Dockerfile @@ -9,3 +9,5 @@ EXPOSE 7576 EXPOSE 7577 EXPOSE 7578 EXPOSE 8484 + +CMD ["/bin/bash","compile_and_run.sh"] diff --git a/run.sh b/run.sh index b71a1f74..45f1d78d 100644 --- a/run.sh +++ b/run.sh @@ -3,10 +3,7 @@ docker build -t odinms_mysql odinms_mysql docker build -t odinms odinms -ODINMS_MYSQL_CONTAINER_ID=`docker run -d -p 3306:3306 odinms_mysql` +ODINMS_MYSQL_CONTAINER_ID=`docker run -d --name odinms_mysql odinms_mysql` -ODINMS_MYSQL_CONTAINER_IP_ADDRESS=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $ODINMS_MYSQL_CONTAINER_ID` +docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --name odinms odinms -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 - -docker rm -f $ODINMS_MYSQL_CONTAINER_ID From f8cebf5af2790401f710d01e449514582aa7ed44 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 00:04:03 +0000 Subject: [PATCH 04/16] Variable not needed. --- run.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 45f1d78d..38ccaab8 100644 --- a/run.sh +++ b/run.sh @@ -3,7 +3,6 @@ docker build -t odinms_mysql odinms_mysql docker build -t odinms odinms -ODINMS_MYSQL_CONTAINER_ID=`docker run -d --name odinms_mysql odinms_mysql` - +docker run -d --name odinms_mysql odinms_mysql docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --name odinms odinms From ef3b8d5f018dff94998d422c39f8d4dee894f727 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 00:22:42 +0000 Subject: [PATCH 05/16] Added private network bridge. --- run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 38ccaab8..d90db3e9 100644 --- a/run.sh +++ b/run.sh @@ -3,6 +3,8 @@ docker build -t odinms_mysql odinms_mysql docker build -t odinms odinms -docker run -d --name odinms_mysql odinms_mysql -docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --name odinms odinms +docker network create thepack + +docker run -d --network thepack --name maplestory-db odinms_mysql +docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --network thepack --name maplestory odinms From 8084adaadbaa3ee73cbd6b6646ac8842a44cde8e Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 00:36:07 +0000 Subject: [PATCH 06/16] Check if network bridge already exists. --- run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index d90db3e9..4746fd62 100644 --- a/run.sh +++ b/run.sh @@ -3,7 +3,10 @@ docker build -t odinms_mysql odinms_mysql docker build -t odinms odinms -docker network create thepack +NETWORK=`docker network ls | grep thepack | awk {'print $2'}` +if [[ ! $NETWORK == "thepack" ]]; then + docker network create thepack +fi docker run -d --network thepack --name maplestory-db odinms_mysql docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --network thepack --name maplestory odinms From 54f1bf78cfa91367562d9479a9af610b99dbc029 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 01:04:42 +0000 Subject: [PATCH 07/16] Added comments. --- run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run.sh b/run.sh index 4746fd62..09bb1fba 100644 --- a/run.sh +++ b/run.sh @@ -1,13 +1,16 @@ #!/usr/bin/env bash +# Build images. docker build -t odinms_mysql odinms_mysql docker build -t odinms odinms +# 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 +# Run containers. docker run -d --network thepack --name maplestory-db odinms_mysql docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --network thepack --name maplestory odinms From 4bd09f12934c01cde1a5f72194daaba8de7ae72a Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 01:14:14 +0000 Subject: [PATCH 08/16] Check if containers are already running. --- run.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 09bb1fba..aaa5cda1 100644 --- a/run.sh +++ b/run.sh @@ -11,6 +11,12 @@ if [[ ! $NETWORK == "thepack" ]]; then fi # Run containers. -docker run -d --network thepack --name maplestory-db odinms_mysql -docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --network thepack --name maplestory odinms +DB_CONTAINER=`docker container ps | grep -w odinms_mysql | awk {'print $2'}` +if [[ ! $DB_CONTAINER == "odinms_mysql" ]]; then + docker run -d --network thepack --name maplestory-db odinms_mysql +fi +MS_CONTAINER=`docker container ps | grep -w odinms | awk {'print $2'}` +if [[ ! $MS_CONTAINER == "odinms" ]]; then + docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --network thepack --name maplestory odinms +fi From 712ef9f89709e74916dcbd1a5af7a04537c94327 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 01:38:03 +0000 Subject: [PATCH 09/16] Added volume to hold database - somewhat important. --- run.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index aaa5cda1..ab925188 100644 --- a/run.sh +++ b/run.sh @@ -10,10 +10,16 @@ if [[ ! $NETWORK == "thepack" ]]; then docker network create thepack fi +# 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 + # Run containers. DB_CONTAINER=`docker container ps | grep -w odinms_mysql | awk {'print $2'}` if [[ ! $DB_CONTAINER == "odinms_mysql" ]]; then - docker run -d --network thepack --name maplestory-db odinms_mysql + docker run -d --volume thepack-db:/var/lib/mysql --network thepack --name maplestory-db odinms_mysql fi MS_CONTAINER=`docker container ps | grep -w odinms | awk {'print $2'}` From 1482df00753bc99de7f0049703c420ceba733b01 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 01:49:35 +0000 Subject: [PATCH 10/16] Using internal DNS instead of a variable. --- odinms/thepack_82/ThePack/channel.properties | 2 +- odinms/thepack_82/ThePack/db.properties | 2 +- odinms/thepack_82/ThePack/login.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/odinms/thepack_82/ThePack/channel.properties b/odinms/thepack_82/ThePack/channel.properties index b549dfdf..5792a0a2 100644 --- a/odinms/thepack_82/ThePack/channel.properties +++ b/odinms/thepack_82/ThePack/channel.properties @@ -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 diff --git a/odinms/thepack_82/ThePack/db.properties b/odinms/thepack_82/ThePack/db.properties index 12447631..4eee62fd 100644 --- a/odinms/thepack_82/ThePack/db.properties +++ b/odinms/thepack_82/ThePack/db.properties @@ -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 diff --git a/odinms/thepack_82/ThePack/login.properties b/odinms/thepack_82/ThePack/login.properties index b483b497..599f242f 100644 --- a/odinms/thepack_82/ThePack/login.properties +++ b/odinms/thepack_82/ThePack/login.properties @@ -1,2 +1,2 @@ -net.sf.odinms.world.host=THIS_IP +net.sf.odinms.world.host=maplestory net.sf.odinms.login.key=releaselogin From 8e9306d0d8a791830de3a33343f186efd8cf6093 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 01:52:16 +0000 Subject: [PATCH 11/16] Removing THIS_IP variable. --- odinms/thepack_82/ThePack/run.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/odinms/thepack_82/ThePack/run.sh b/odinms/thepack_82/ThePack/run.sh index 28da75fa..68b1c4de 100644 --- a/odinms/thepack_82/ThePack/run.sh +++ b/odinms/thepack_82/ThePack/run.sh @@ -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 & From 6f93922d6e24ed4b2321434850bdc45dd25ff228 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 02:05:23 +0000 Subject: [PATCH 12/16] Keep CMD script alive forever. --- odinms/thepack_82/compile_and_run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odinms/thepack_82/compile_and_run.sh b/odinms/thepack_82/compile_and_run.sh index daf32837..2e692b11 100644 --- a/odinms/thepack_82/compile_and_run.sh +++ b/odinms/thepack_82/compile_and_run.sh @@ -2,3 +2,5 @@ cd ThePack source compile.sh && source run.sh + +sleep infinity From 0e908bf518723db4cc6b60f609e1202cbf95ecaf Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 02:16:40 +0000 Subject: [PATCH 13/16] Attaching game server container to host bridge network. --- run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run.sh b/run.sh index ab925188..72824e40 100644 --- a/run.sh +++ b/run.sh @@ -25,4 +25,7 @@ fi MS_CONTAINER=`docker container ps | grep -w odinms | awk {'print $2'}` if [[ ! $MS_CONTAINER == "odinms" ]]; then docker run -d -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 From 8f860eebd57816a2b2f2fd00c40beeb17b40a206 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 03:02:35 +0000 Subject: [PATCH 14/16] Attempt to configure public IP automatically. --- odinms/thepack_82/compile_and_run.sh | 2 ++ run.sh | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/odinms/thepack_82/compile_and_run.sh b/odinms/thepack_82/compile_and_run.sh index 2e692b11..bc539a8d 100644 --- a/odinms/thepack_82/compile_and_run.sh +++ b/odinms/thepack_82/compile_and_run.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +sed -i "s/THIS_IP/$THIS_IP/g" ./ThePack/world.properties + cd ThePack source compile.sh && source run.sh diff --git a/run.sh b/run.sh index 72824e40..ca587ca8 100644 --- a/run.sh +++ b/run.sh @@ -24,7 +24,11 @@ fi MS_CONTAINER=`docker container ps | grep -w odinms | awk {'print $2'}` if [[ ! $MS_CONTAINER == "odinms" ]]; then - docker run -d -p 7575:7575 -p 7576:7576 -p 7577:7577 -p 7578:7578 -p 8484:8484 --network thepack --name maplestory odinms + + # 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'} | head -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 From d47eeb38aa52aa097e11db47e44992b343feb341 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 03:34:03 +0000 Subject: [PATCH 15/16] Added sleep to avoid race condition. --- run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run.sh b/run.sh index ca587ca8..cfa7a27f 100644 --- a/run.sh +++ b/run.sh @@ -22,6 +22,9 @@ if [[ ! $DB_CONTAINER == "odinms_mysql" ]]; then docker run -d --volume thepack-db:/var/lib/mysql --network thepack --name maplestory-db odinms_mysql fi +# Sleep needed to avoid race condition. +sleep 5 + MS_CONTAINER=`docker container ps | grep -w odinms | awk {'print $2'}` if [[ ! $MS_CONTAINER == "odinms" ]]; then From 86f5eddbd06dd3d0b32efc1658dd961a81f0d706 Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 1 Dec 2018 04:15:47 +0000 Subject: [PATCH 16/16] Improving IP logic - trying to avoid bridge networks. --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index cfa7a27f..99af649e 100644 --- a/run.sh +++ b/run.sh @@ -29,7 +29,7 @@ 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'} | head -n 1` + 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