diff --git a/.gitignore b/.gitignore index 141ad0f..de8b83e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ pwn3.tar.gz server client -postgres-data \ No newline at end of file +postgres-data +PwnAdventure3_Windows.zip +**/windowsclient diff --git a/Dockerfile.ubuntu-latest b/Dockerfile.ubuntu-latest new file mode 100644 index 0000000..8093e97 --- /dev/null +++ b/Dockerfile.ubuntu-latest @@ -0,0 +1,15 @@ +FROM ubuntu:latest + +ENV PWN3=/opt/pwn3 + +RUN echo "deb http://security.ubuntu.com/ubuntu xenial-security main" >> /etc/apt/sources.list \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y nano vim postgresql libssl1.0.0 \ + && apt-get clean \ + && rm -rf /var/lib/apt \ + && adduser pwn3 --system --shell /bin/bash --group + +EXPOSE 5432 + +ADD --chown=pwn3 server/MasterServer/initdb.sql $PWN3/initdb.sql +ADD --chown=pwn3 setup $PWN3/setup diff --git a/docker-compose.ubuntu-latest.yml b/docker-compose.ubuntu-latest.yml new file mode 100644 index 0000000..0244168 --- /dev/null +++ b/docker-compose.ubuntu-latest.yml @@ -0,0 +1,47 @@ +version: '3.2' +services: + master: + build: + context: . + dockerfile: ./Dockerfile.ubuntu-latest + image: pwn3server-ubuntulatest + hostname: master.pwn3 + networks: + default: + aliases: + - "master.pwn3" + ports: + - "3333:3333" + volumes: + - type: bind + source: "./server" + target: "/opt/pwn3/server" + - type: bind + source: "./client" + target: "/opt/pwn3/client" + - type: bind + source: "./postgres-data" + target: "/opt/pwn3/postgres-data" + command: "/opt/pwn3/setup/masterserver.sh" + game: + build: + context: . + dockerfile: ./Dockerfile.ubuntu-latest + image: pwn3server-ubuntulatest + hostname: game.pwn3 + networks: + default: + aliases: + - "master.pwn3" + ports: + - "3000-3010:3000-3010" + volumes: + - type: bind + source: "./server" + target: "/opt/pwn3/server" + - type: bind + source: "./client" + target: "/opt/pwn3/client" + command: "/opt/pwn3/setup/gameserver.sh" + depends_on: + - master diff --git a/docker-compose.yml b/docker-compose.yml index 21cdd0f..2be7192 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,9 @@ version: '3.2' services: - init: - build: . - image: pwn3server master: + build: + context: . + dockerfile: ./Dockerfile image: pwn3server hostname: master.pwn3 networks: @@ -23,9 +23,10 @@ services: source: "./postgres-data" target: "/opt/pwn3/postgres-data" command: "/opt/pwn3/setup/masterserver.sh" - depends_on: - - init game: + build: + context: . + dockerfile: ./Dockerfile image: pwn3server hostname: game.pwn3 networks: @@ -43,5 +44,4 @@ services: target: "/opt/pwn3/client" command: "/opt/pwn3/setup/gameserver.sh" depends_on: - - init - - master \ No newline at end of file + - master diff --git a/setup/masterserver.sh b/setup/masterserver.sh index 0985d0f..1e5762d 100755 --- a/setup/masterserver.sh +++ b/setup/masterserver.sh @@ -13,14 +13,19 @@ _term() { exit 0 } +echo "Setup process kill trap" trap _term SIGTERM SIGKILL +echo "Start postgresql service" service postgresql start +echo "Sleep 10" sleep 10 +echo "Setup postgresql using template $PWN3/setup/postgres_init.sql" su postgres -c "psql -f $PWN3/setup/postgres_init.sql -d template1" +echo "Cleanup previous logs" # clean up su pwn3 -c "rm /opt/pwn3/client/PwnAdventure3_Data/PwnAdventure3/PwnAdventure3/Saved/Logs/*" @@ -36,12 +41,15 @@ else su pwn3 -c "cd /opt/pwn3/server/MasterServer/ && ./MasterServer --create-admin-team Admin" fi +echo "Cleanup previous server creds using $PWN3/setup/postgres_cleanup.sql" # cleanup all previous/old server master creds su pwn3 -c "psql master -f $PWN3/setup/postgres_cleanup.sql" +echo "Setup new server creds" # get new master server creds su pwn3 -c "cd /opt/pwn3/server/MasterServer/ && ./MasterServer --create-server-account > /opt/pwn3/server/creds" +echo "Write new server creds to server.ini" # write the new creds to the server.ini USER=$(cat /opt/pwn3/server/creds | grep 'Username:' | cut -d ":" -f 2- | xargs) PW=$(cat /opt/pwn3/server/creds | grep 'Password:' | cut -d ":" -f 2- | xargs) @@ -58,7 +66,7 @@ Password=$PW Instances=5 EOL - +echo "Run the server" # run the server su pwn3 -c "cd /opt/pwn3/server/MasterServer/ && ./MasterServer" &