diff --git a/.gitignore b/.gitignore index b25a549..7122335 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ data/* .env -.DS_Store \ No newline at end of file +.DS_Store +cert.pfx \ No newline at end of file diff --git a/README.md b/README.md index 7c06f2b..0ed4fce 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ This can also be done by creating a new folder named `data` manually, without th docker-compose up -d ``` -This runs Uchu in the background along with Postgres, Redis and Adminer. You can attach to the `Uchu.Master` shell using: +This runs Uchu in the background along with Postgres and Redis. You can attach to the `Uchu.Master` shell using: ```bash docker attach uchudocker_uchu_1 ``` -This allows you to input shell commands like `/adduser `. You can exit the shell using `Ctrl+C`. +This allows you to input shell commands like `/adduser `. You can exit the shell using `Ctrl+P + Ctrl+Q` (`Ctrl+C` closes the container, not just your attach session). ## Closing @@ -72,10 +72,8 @@ When applying any changes to the `.env` file after your initial `docker-compose ## Adminer -Uchu Docker also automatically runs [Adminer](https://www.adminer.org), which allows you to easily modify the Uchu database in a user friendly way. After running Uchu Docker you can access Adminer through your browser at 0.0.0.0:8080. Select the `PostgreSQL` database type, set the server to `db` and enter the credentials found in the `.env` file to login. More info on how to use Adminer can be found on their website. +Uchu Docker can also run [Adminer](https://www.adminer.org), which allows you to easily modify the Uchu database in a user friendly way. You can activate this by uncommenting the lines after `# Uncomment this if you wish to use adminer` in `docker-compose.yaml`, note that you probably don't need this by default but can assist with more user friendly database management. Select the `PostgreSQL` database type, set the server to `db` and enter the credentials found in the `.env` file to login. More info on how to use Adminer can be found on their website. ## Hosting (Advanced) -This Docker setup can be used to host Uchu as long as all ports are exposed (see the .env.sample file for all ports that need to be exposed). Do note that hosting Uchu on anything other than `localhost` requires a valid PFX certificate from a trusted CA like Let's Encrypt and therefore also a valid domain name. You *cannot* use a self signed certificate even if you first generate your own root certificate, as the TcpUdp mod does not look at the OS certificate store for valid root certificates. You can specify the path to your PFX certificate using the `$CERTIFICATE` environment variable. - -When hosting Uchu on a private network, for example in a LAN scenario, it might be a bit cumbersome to get a valid certficate and a domain. An alternative solution would be to run Uchu on a host device, find it's private network IP using `ipconfig` or `ifconfig` and port-forwarding all Uchu ports on `localhost` on client machines to the private network IP and the respective ports. This way clients on the private network can connect with Uchu through `localhost` and therefore no certificate is required. To ensure this works port-forward all the ports from the `.env` file on all client machines to the host machine. \ No newline at end of file +This Docker setup can be used to host Uchu as long as all ports are exposed (see the .env.sample file for all ports that need to be exposed). Do note that hosting Uchu on anything other than `localhost` requires a valid PFX certificate from a trusted CA like Let's Encrypt and therefore also a valid domain name. You *cannot* use a self signed certificate even if you first generate your own root certificate, as the TcpUdp mod does not look at the OS certificate store for valid root certificates. You can add a certificate to the container by adding it to this directory under the name `cert.pfx`. Finally set the `HOSTNAME` variable in the `.env` file to the hostname for the certificate. \ No newline at end of file diff --git a/Uchu.Dockerfile b/Uchu.Dockerfile index e74d7f7..760f46f 100644 --- a/Uchu.Dockerfile +++ b/Uchu.Dockerfile @@ -1,7 +1,7 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine -COPY Uchu config.default.xml .env ./ +COPY Uchu config.default.xml .env cert.pfx* ./ -RUN apk update && apk add --no-cache gettext && apk add --no-cache openssl +RUN apk update && apk add --no-cache gettext && apk add --no-cache curl RUN set -o allexport && source .env && set +o allexport && envsubst < config.default.xml > config.xml RUN dotnet build diff --git a/config.default.xml b/config.default.xml index d0459d7..9052c33 100644 --- a/config.default.xml +++ b/config.default.xml @@ -26,8 +26,8 @@ /res - $CERTIFICATE - localhost + cert.pfx + $HOSTNAME 2002 true true diff --git a/docker-compose.yaml b/docker-compose.yaml index 408af70..fdb9c89 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,13 +7,14 @@ services: restart: always volumes: - ${DATA_FOLDER}:/var/lib/postgresql/data - adminer: - image: adminer - restart: always - depends_on: - - db - ports: - - ${ADMINER_PORT}:8080 + # Uncomment this if you wish to use adminer + # adminer: + # image: adminer + # restart: always + # depends_on: + # - db + # ports: + # - ${ADMINER_PORT}:8080 redis: image: redis:6.0.8-alpine env_file: @@ -40,5 +41,12 @@ services: - ${UCHU_WORLD_PORT_RANGE}:20000-20100 - ${UCHU_SERVER_PORT}:21836 - ${UCHU_AUTH_PORT}:40000 + - ${UCHU_HANDSHAKE_PORT}:1001/udp + - ${UCHU_CHARACTER_PORT}:2002/udp + - ${UCHU_CHAT_PORT}:2004/udp + - ${UCHU_API_PORT_RANGE}:10000-10100/udp + - ${UCHU_WORLD_PORT_RANGE}:20000-20100/udp + - ${UCHU_SERVER_PORT}:21836/udp + - ${UCHU_AUTH_PORT}:40000/udp tty: true - stdin_open: true + stdin_open: true \ No newline at end of file diff --git a/uchu.sh b/uchu.sh new file mode 100644 index 0000000..b3eb27a --- /dev/null +++ b/uchu.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# WIP Install script + +if ! [ -f ".env" ]; then + echo "Environment file does not exist yet, setting it up for you." + echo "Please specify a valid absolute path to the /res folder inside your LU client (make sure to escape spaces):" + + while ! [ -d "$GAME_FOLDER" ]; do + read GAME_FOLDER + if ! [ -d "$GAME_FOLDER" ]; then + echo "$GAME_FOLDER is not a valid directory, retry:" + fi + done + + if ! [ -d "$GAME_FOLDER/../mods" ]; then + echo "It seems like you don't have the TcpUdp mod installed in your client, you won't be able to connect with Uchu until you install this mod. More information can be found in the README." + else + echo "$GAME_FOLDER seems like a valid location, continuing." + fi + + sed "s|/res|$GAME_FOLDER|g" .env.sample > .env + + echo "Finished setting up environment file." +fi + +if ! [ -d "data" ]; then + echo "Database folder not found, adding \"data\" folder." + mkdir data +fi + +if [ -x "$(command -v docker)" ] && [ -x "$(command -v docker-compose)" ]; then + echo "Starting Uchu" + docker-compose up --build +else + echo "You don't have docker or docker-compose installed, refer to the README for installation instructions." +fi \ No newline at end of file