diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..86533e6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +assets/ +kubernetes/ +.gitignore +docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 04d238c..ca901c7 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,80 @@ -FROM ubuntu:22.04 +FROM cm2network/steamcmd:root-bookworm LABEL maintainer="Tim Chaubet" -VOLUME ["/mnt/vrising/server", "/mnt/vrising/persistentdata"] +#VOLUME ["/home/steam/vrising/server", "/home/steam/vrising/persistentdata"] +EXPOSE 9876/udp +# Expose 9876/tcp if using RCON. See RCON_PORT Env variable +EXPOSE 9876 +EXPOSE 9877/udp -ARG DEBIAN_FRONTEND="noninteractive" -RUN apt update -y && \ - apt-get upgrade -y && \ - apt-get install -y apt-utils && \ - apt-get install -y software-properties-common \ - tzdata && \ - add-apt-repository multiverse && \ +# Let the user change the user and group ID +ARG STEAM_USER_UID="1000" +ARG STEAM_USER_GID="1000" +ARG SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.29/supercronic-linux-amd64 +ARG SUPERCRONIC=supercronic-linux-amd64 +ARG SUPERCRONIC_SHA1SUM=cd48d45c4b10f3f0bfdd3a57d054cd05ac96812b + +ENV SERVER_DATA_PATH="/home/steam/vrising/server" \ + PERSISTENT_DATA_PATH="/home/steam/vrising/persistentdata" \ + HOST_SETTINGS_NAME="My Docker V-Rising Server" \ + HOST_SETTINGS_DESCRIPTION="V Rising Server hosted by Docker" \ + HOST_SETTINGS_PASSWORD="" \ + HOST_SETTINGS_MAX_CONNECTED_USERS="10" \ + HOST_SETTINGS_MAX_CONNECTED_ADMINS="4" \ + HOST_SETTINGS_SERVER_ADMIN_LIST="" \ + HOST_SETTINGS_SERVER_FPS="30" \ + HOST_SETTINGS_RCON_ENABLE="false" \ + HOST_SETTINGS_RCON_PASSWORD="Ch8ng3m3Pl3@s3!" \ + HOST_SETTINGS_RCON_PORT="9876" \ + HOST_SETTINGS_AUTOSAVE_COUNT="40" \ + HOST_SETTINGS_AUTOSAVE_INTERVAL="120" \ + HOST_SETTINGS_LISTEN_ON_STEAM="true" \ + HOST_SETTINGS_LISTEN_ON_EOS="true" \ + GAME_SETTINGS_PRESET="StandardPvP" \ + GAME_SETTINGS_DIFFICULTY="Normal" \ + LIST_ON_MASTER_SERVER="true" \ + SERVER_IP="127.0.0.1" \ + SAVE_NAME="world1" \ + GAME_PORT="9876" \ + QUERY_PORT="9877" \ + DEBUG_ENV="true" \ + LOGDAYS="30" \ + OVERRIDE_CONFIG="true" \ + TZ="Europe/Brussels" + +COPY --chown=${STEAM_USER_UID}:${STEAM_USER_GID} --chmod=744 files /home/steam/files/ +COPY src/debian.sources /etc/apt/sources.list.d/debian.sources + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# hadolint ignore=DL3008 +RUN DEBIAN_FRONTEND=noninteractive \ dpkg --add-architecture i386 && \ - apt update -y && \ - apt-get upgrade -y -RUN useradd -m steam && cd /home/steam && \ - echo steam steam/question select "I AGREE" | debconf-set-selections && \ - echo steam steam/license note '' | debconf-set-selections && \ - apt purge steam steamcmd && \ - apt install -y gdebi-core \ - libgl1-mesa-glx:i386 \ - wget && \ - apt install -y steam \ - steamcmd && \ - ln -s /usr/games/steamcmd /usr/bin/steamcmd -#RUN apt install -y mono-complete -RUN apt install -y wine \ - winbind \ - winetricks -RUN apt install -y xserver-xorg \ - xvfb -RUN rm -rf /var/lib/apt/lists/* && \ - apt clean && \ - apt autoremove -y + apt-get update && \ + apt-get install -y --no-install-recommends \ + supervisor \ + cron \ + gettext-base \ + procps \ + wine \ + wine32 \ + wine64 \ + winbind \ + xvfb \ + xauth \ + mingw-w64 \ + screen && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + usermod -u "${STEAM_USER_UID}" steam && groupmod -g "${STEAM_USER_GID}" steam && \ + chmod +x /home/steam/files/scripts/* && \ + curl -fsSLO "$SUPERCRONIC_URL" && \ + echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - && \ + chmod +x "$SUPERCRONIC" && \ + mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" && \ + ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic && \ + chown -R "${STEAM_USER_UID}:${STEAM_USER_GID}" /home/steam + +USER steam -COPY start.sh /start.sh -RUN chmod +x /start.sh -CMD ["/start.sh"] +CMD ["/home/steam/files/scripts/entrypoint.sh"] +HEALTHCHECK --start-period=180s \ + CMD /bin/bash /home/steam/files/scripts/healthcheck.sh diff --git a/README.md b/README.md index 8539cac..d437cf9 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Iroh -

Dockerized V Rising dedicated server in an Ubuntu 22.04 container with Wine.

+

Dockerized V Rising dedicated server in an Debian 12 container with Wine.

[![Docker Pulls](https://badgen.net/docker/pulls/trueosiris/vrising?icon=docker&label=pulls)](https://hub.docker.com/r/trueosiris/vrising/) @@ -31,20 +31,58 @@ - The game is working perfectly with a new run of the container (from scratch). I'm on it with several buddies and tested for 3 hours. - When the server is passworded, joining via Steam seems not possible. Use the ingame server list to join. -- Make sure `"ListOnSteam": true,` and `"ListOnEOS": true` are set in the ServerHostSettings.json in \persistentdata, so the server is visible in the serverlist +- Make sure `HOST_SETTINGS_LISTEN_ON_STEAM: "true"` and `HOST_SETTINGS_LISTEN_ON_EOS: "true"` are set in your Environment - Launching the server can take up to 10 minutes, even on a fast system, certainly with an existing save. Below is a screenshot of the end of the docker log of a functioning server, at the time we are able to connect to it. ## Environment variables -| Variable | Key | Description | -| ------------ | ------------------------ | ----------------------------------------------------------------------------------- | -| TZ | Europe/Brussels | timezone for ntpdate | -| SERVERNAME | published servername | mandatory setting that overrules the ServerHostSettings.json entry | -| WORLDNAME | optional worldname | default = world1. No real need to alter this. saves will be in a subdir WORLDNAME | -| GAMEPORT | optional game udp port | to overrule Port in ServerHostSettings.json config | -| QUERYPORT | optional query port | to overrule QueryPort in ServerHostSettings.json config | -| LOGDAYS | optional lifetime of logfiles | overrule default of 30 days | +| Variable | Default V(alue) | Description | Mandatory | +| --------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------- | --------- | +| TZ | Europe/Brussels | timezone for ntpdate | No | +| SERVER_DATA_PATH | /home/steam/vrising/server | Path inside the container to save server files to | No | +| PERSISTENT_DATA_PATH | /home/steam/vrising/persistentdata | Path inside the container to save world/configs/logs/etc. to | No | +| HOST_SETTINGS_NAME | My Docker V-Rising Server | The name of your server as visible in the server list | No | +| HOST_SETTINGS_DESCRIPTION | V Rising Server hosted by Docker | Description of your server | No | +| HOST_SETTINGS_PASSWORD | "" | Optional server password | No | +| HOST_SETTINGS_MAX_CONNECTED_USERS | 10 | Maximum connected users | No | +| HOST_SETTINGS_MAX_CONNECTED_ADMINS| 4 | Maximum connected admins | No | +| HOST_SETTINGS_SERVER_ADMIN_LIST | "" | Comma separated list of Admin Steam ID64s (e.g. "123456789,0987654321") | No | +| HOST_SETTINGS_SERVER_FPS | 30 | Server FPS | No | +| HOST_SETTINGS_RCON_ENABLE | "false" | Whether to enable RCON | No | +| HOST_SETTINGS_RCON_PASSWORD | "Ch8ng3m3Pl3@s3!" | RCON Password [Requires: HOST_SETTINGS_RCON_ENABLE=true] | No | +| HOST_SETTINGS_RCON_PORT | "9876" | RCON TCP Port to listen on | No | +| HOST_SETTINGS_AUTOSAVE_COUNT | 40 | How many autosaves to keep | No | +| HOST_SETTINGS_AUTOSAVE_INTERVAL | 120 | Interval in seconds for the server to autosave | No | +| HOST_SETTINGS_LISTEN_ON_STEAM | "true" | Whether to listen on steam | No | +| HOST_SETTINGS_LISTEN_ON_EOS | "true" | Whether to listen on EOS | No | +| GAME_SETTINGS_PRESET | "StandardPvP" | Game Settings preset to start the server with | No | +| GAME_SETTINGS_DIFFICULTY | "Normal" | Server default difficulty setting | No | +| LIST_ON_MASTER_SERVER | "true" | Whether to list the Server on Master Servers | No | +| SERVER_IP | "127.0.0.1" | Public facing Server IP - **You might have to experiment with this** | Maybe | +| SAVE_NAME | "default_world" | The name of your map | No | +| GAME_PORT | "9876" | UDP Port for game connections | No | +| QUERY_PORT | "9877" | UDP Port to query the server on | No | +| DEBUG_ENV | "true" | Return all variables to the stdout on container start | No | +| LOGDAYS | 30 | Number of days after which logs are deleted after their last modification | No | +| OVERRIDE_CONFIG | true | Whether to generate new configs at the start of the container. | No | + + +## A note on `OVERRIDE_CONFIG` +By default, this parameter is set to true. Any configuration should be done using the Environment Variables, changing your configs by going into your container or editing the files on your mounted file system path will be **overwritten every time the container starts**. +If you set this to `false`, the following will happen: +- When configs already exist, they are **not** overwritten +- When no configs exist, a default config is written **once** with any Environment variables you set, otherwise the defaults are used. + +## Changing the running UID/GID + +If you want to change the UID/GID of the User that's running the container for any reason, you can change the **Build ARGs**. The Image uses UID/GID 1000/1000 by default as defined in `cm2network/steamcmd:root-bookworm`. +Please note that changing this also means that you might have to adjust your volume permissions on the host when using docker. When using Kubernetes, you should verify the securityContext. + +| Variable | Default V(alue) | Description | Mandatory | +| --------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------- | --------- | +| STEAM_USER_UID | 1000 | The user ID the server will run on | No | +| STEAM_USER_GID | 1000 | The group ID the server will run on | No | ## Ports @@ -52,6 +90,7 @@ | Exposed Container port | Type | Default | | ------------------------ | ------ | --------- | | 9876 | UDP | ✔️ | +| 9876 | TCP | ❌ | | 9877 | UDP | ✔️ | ## Volumes @@ -59,8 +98,8 @@ | Volume | Container path | Description | | -------------------- | ----------------------------- | ----------------------------------------- | -| steam install path | /mnt/vrising/server | path to hold the dedicated server files | -| world | /mnt/vrising/persistentdata | path that holds the world files | +| steam install path | /home/steam/vrising/server | path to hold the dedicated server files | +| world | /home/steam/vrising/persistentdata | path that holds the world files | ## Docker cli @@ -69,9 +108,9 @@ docker run -d --name='vrising' \ --net='bridge' \ --restart=unless-stopped \ -e TZ="Europe/Paris" \ --e SERVERNAME="trueosiris-V" \ --v '/path/on/host/server':'/mnt/vrising/server':'rw' \ --v '/path/on/host/persistentdata':'/mnt/vrising/persistentdata':'rw' \ +-e HOST_SETTINGS_NAME="trueosiris-V" \ +-v '/path/on/host/server':'/home/steam/vrising/server':'rw' \ +-v '/path/on/host/persistentdata':'/home/steam/vrising/persistentdata':'rw' \ -p 9876:9876/udp \ -p 9877:9877/udp \ 'trueosiris/vrising' @@ -79,31 +118,25 @@ docker run -d --name='vrising' \ ## docker-compose.yml -```yaml -services: - vrising: - image: trueosiris/vrising - environment: - - TZ=Europe/Paris - - SERVERNAME=vrising-TrueOsiris - volumes: - - type: bind - source: /your/host/vrising/server - target: /mnt/vrising/server - bind: - create_host_path: true - - type: bind - source: /your/host/vrising/persistentdata - target: /mnt/vrising/persistentdata - bind: - create_host_path: true - ports: - - '9876:9876/udp' - - '9877:9877/udp' - restart: unless-stopped - network_mode: bridge +See the example docker-compose.yml in this repository. +Do not put any of your env variables in the "environment:" section in quotes. + +**IMPORTANT**: The compose file will create the path you define in `source` if it does not exist. Ensure you're either running with UID/GID 1000 (the default steam user in the container), change owners of these folders accordingly, or setup the `STEAM_USER_UID` and `STEAM_USER_GID` arguments correctly and rebuild the image. Otherwise you will get the following error: + +``` +mkdir: cannot create directory '/home/steam/vrising/persistentdata/Settings': Permission denied ``` +## Kubernetes + +You can use the provided example in `kubernetes/kustomize/overlays/exampleorg` to see the ways the base template could be adjusted to your requirements. +It's important to *at least* change the following: +- secret.yaml - Your RCON Secret, if you need one +- pvc.yaml - Adjust `storageClassname` and requsted storage according to your needs +- deployment.yaml - Set Image path to your registry. This image is not pushed to dockerhub by default + +To update your Pod, just delete it and wait for it to restart. + ## Links - [V Rising Dedicated Server Instructions](https://github.com/StunlockStudios/vrising-dedicated-server-instructions) @@ -112,40 +145,29 @@ services: ## RCON - Optional -To enable RCON edit `ServerHostSettings.json` and paste following lines after `QueryPort`. To communicate using RCON protocal use the [RCON CLI](https://github.com/gorcon/rcon-cli) by gorcon. +To enable RCON set the `HOST_SETTINGS_RCON_ENABLE`, `HOST_SETTINGS_RCON_PASSWORD`, `HOST_SETTINGS_RCON_PORT` variables. To communicate using RCON protocal use the [RCON CLI](https://github.com/gorcon/rcon-cli) by gorcon. -```json -"Rcon": { - "Enabled": true, - "Password": "docker", - "Port": 25575 -}, -``` ## Remarks -- Server config files are in `/path/on/host/persistentdata/Settings`. Files in `/path/on/host/server/` are overwritten on Steam update.
- Priority of settings is - - a. container variables - - b. files in /persistentdata +- Server config files are in `/path/on/host/persistentdata/Settings`. + Files in `/path/on/host/server/` are overwritten on Steam update.
+ Priority of settings is - c. files in /server. (and these are reset to defaults each new patch) + - container variables + - files in /server. (and these are reset to defaults each new patch) - If there are no files in `/path/on/host/persistentdata/Settings` on container start, the default files will be copied there from the /server directory.
- Edit `ServerHostSettings.json` if you want to change the ports, descriptions etc. -- Description can be changed in `/path/on/host/persistentdata/Settings/ServerHostSettings.json`. The server will have to be restarted after changes. + Please note that you cannot edit your config files in `$PERSISTENT_DATA_PATH/Settings/ServerGameSettings.json` or `$PERSISTENT_DATA_PATH/Settings/ServerHostSettings.json`, these will be overwritten by your ENV every time the container is restarted by default. In case you want to adjust any setting that isn't covered by the current config options, please create an issue or a PR. + If you want to manually adjust your configs and keep your changes, move your config files (with proper access rights) to your mounted folder and set `OVERRIDE_CONFIG="false"` - If you use different internal & external ports, you can only use direct connect. For example `-p 12345:6789/udp` container port 6789 as defined in ServerHostSettings.json, and exposed as 12345 will make your server invisible ~~, even if `"ListOnMasterServer=true"`~~ -- Make sure `"ListOnSteam": true,` and `"ListOnEOS": true` are set in the ServerHostSettings.json in \persistentdata, so the server is visible in the serverlist. -- If you want to see the server in the server list and want to use 27015-27016/UDP, you'll need to change the ports in the ServerHostSettings.json file to 27015 and 27016. Then expose these ports (below). Of course, forward these udp ports on your firewall from incoming wan to the ports on the internal ip of your dockerhost. +- If you want to see the server in the server list and want to use 27015-27016/UDP, you'll need to change the ports to 27015 and 27016. Then expose these ports (below). Of course, forward these udp ports on your firewall from incoming wan to the ports on the internal ip of your dockerhost. - Start the container & let the server install. - Stop the container. - - Alter the ports in `/path/on/host/persistentdata/Settings/ServerHostSettings.json` to + - Alter the ports to ``` - "Port": 27015, - "QueryPort": 27016, + GAME_PORT: "27015" + QUERY_PORT: "27016" ``` - On your firewall, port forward incoming wan udp ports 27015 and 27016 to the same udp ports on your dockerhost ip. - Restart the container with these ports: diff --git a/docker-compose.yml b/docker-compose.yml old mode 100755 new mode 100644 index cc32c83..98e9900 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,25 @@ services: vrising: image: trueosiris/vrising + build: + args: + STEAM_USER_UID: 1000 + STEAM_USER_GID: 1000 + environment: - - TZ=Europe/Paris - - SERVERNAME=vrising-TrueOsiris + - HOST_SETTINGS_NAME=My Docker-Compose V-Rising Server + - HOST_SETTINGS_DESCRIPTION=V Rising Server hosted by Docker + - HOST_SETTINGS_PASSWORD=supersecret + - HOST_SETTINGS_MAX_CONNECTED_USERS=20 volumes: - type: bind source: /your/host/vrising/server - target: /mnt/vrising/server + target: /home/steam/vrising/server bind: create_host_path: true - type: bind source: /your/host/vrising/persistentdata - target: /mnt/vrising/persistentdata + target: /home/steam/vrising/persistentdata bind: create_host_path: true ports: diff --git a/files/config_templates/ServerGameSettings.json.template b/files/config_templates/ServerGameSettings.json.template new file mode 100755 index 0000000..9a8396f --- /dev/null +++ b/files/config_templates/ServerGameSettings.json.template @@ -0,0 +1,217 @@ +{ + "GameDifficulty": "${GAME_SETTINGS_DIFFICULTY}", + "GameModeType": "PvP", + "CastleDamageMode": "Never", + "SiegeWeaponHealth": "Normal", + "PlayerDamageMode": "Always", + "CastleHeartDamageMode": "CanBeDestroyedByPlayers", + "PvPProtectionMode": "Medium", + "DeathContainerPermission": "Anyone", + "RelicSpawnType": "Unique", + "CanLootEnemyContainers": true, + "BloodBoundEquipment": true, + "TeleportBoundItems": true, + "BatBoundItems": false, + "AllowGlobalChat": true, + "AllWaypointsUnlocked": false, + "FreeCastleRaid": false, + "FreeCastleClaim": false, + "FreeCastleDestroy": false, + "InactivityKillEnabled": true, + "InactivityKillTimeMin": 3600, + "InactivityKillTimeMax": 604800, + "InactivityKillSafeTimeAddition": 172800, + "InactivityKillTimerMaxItemLevel": 84, + "StartingProgressionLevel": 0, + "DisableDisconnectedDeadEnabled": true, + "DisableDisconnectedDeadTimer": 60, + "DisconnectedSunImmunityTime": 300.0, + "InventoryStacksModifier": 1.0, + "DropTableModifier_General": 1.0, + "DropTableModifier_Missions": 1.0, + "MaterialYieldModifier_Global": 1.0, + "BloodEssenceYieldModifier": 1.0, + "JournalVBloodSourceUnitMaxDistance": 25.0, + "PvPVampireRespawnModifier": 1.0, + "CastleMinimumDistanceInFloors": 2, + "ClanSize": 4, + "BloodDrainModifier": 1.0, + "DurabilityDrainModifier": 1.0, + "GarlicAreaStrengthModifier": 1.0, + "HolyAreaStrengthModifier": 1.0, + "SilverStrengthModifier": 1.0, + "SunDamageModifier": 1.0, + "CastleDecayRateModifier": 1.0, + "CastleBloodEssenceDrainModifier": 1.0, + "CastleSiegeTimer": 420.0, + "CastleUnderAttackTimer": 60.0, + "CastleRaidTimer": 600.0, + "CastleRaidProtectionTime": 1800.0, + "CastleExposedFreeClaimTimer": 300.0, + "CastleRelocationCooldown": 10800.0, + "CastleRelocationEnabled": true, + "AnnounceSiegeWeaponSpawn": true, + "ShowSiegeWeaponMapIcon": false, + "BuildCostModifier": 1.0, + "RecipeCostModifier": 1.0, + "CraftRateModifier": 1.0, + "ResearchCostModifier": 1.0, + "RefinementCostModifier": 1.0, + "RefinementRateModifier": 1.0, + "ResearchTimeModifier": 1.0, + "DismantleResourceModifier": 1.0, + "ServantConvertRateModifier": 1.0, + "RepairCostModifier": 1.0, + "Death_DurabilityFactorLoss": 0.125, + "Death_DurabilityLossFactorAsResources": 1.0, + "StarterEquipmentId": 0, + "StarterResourcesId": 0, + "VBloodUnitSettings": [], + "UnlockedAchievements": [], + "UnlockedResearchs": [], + "GameTimeModifiers": { + "DayDurationInSeconds": 1080.0, + "DayStartHour": 9, + "DayStartMinute": 0, + "DayEndHour": 17, + "DayEndMinute": 0, + "BloodMoonFrequency_Min": 10, + "BloodMoonFrequency_Max": 18, + "BloodMoonBuff": 0.2 + }, + "VampireStatModifiers": { + "MaxHealthModifier": 1.0, + "PhysicalPowerModifier": 1.0, + "SpellPowerModifier": 1.0, + "ResourcePowerModifier": 1.0, + "SiegePowerModifier": 1.0, + "DamageReceivedModifier": 1.0, + "ReviveCancelDelay": 5.0 + }, + "UnitStatModifiers_Global": { + "MaxHealthModifier": 1.0, + "PowerModifier": 1.0, + "LevelIncrease": 0 + }, + "UnitStatModifiers_VBlood": { + "MaxHealthModifier": 1.0, + "PowerModifier": 1.0, + "LevelIncrease": 0 + }, + "EquipmentStatModifiers_Global": { + "MaxHealthModifier": 1.0, + "ResourceYieldModifier": 1.0, + "PhysicalPowerModifier": 1.0, + "SpellPowerModifier": 1.0, + "SiegePowerModifier": 1.0, + "MovementSpeedModifier": 1.0 + }, + "CastleStatModifiers_Global": { + "TickPeriod": 5.0, + "SafetyBoxLimit": 1, + "EyeStructuresLimit": 1, + "TombLimit": 12, + "VerminNestLimit": 4, + "PrisonCellLimit": 16, + "HeartLimits": { + "Level1": { + "FloorLimit": 50, + "ServantLimit": 4, + "BuildLimits": 2, + "HeightLimit": 3 + }, + "Level2": { + "FloorLimit": 140, + "ServantLimit": 5, + "BuildLimits": 2, + "HeightLimit": 3 + }, + "Level3": { + "FloorLimit": 240, + "ServantLimit": 6, + "BuildLimits": 2, + "HeightLimit": 3 + }, + "Level4": { + "FloorLimit": 360, + "ServantLimit": 7, + "BuildLimits": 2, + "HeightLimit": 3 + }, + "Level5": { + "FloorLimit": 550, + "ServantLimit": 8, + "BuildLimits": 2, + "HeightLimit": 3 + } + }, + "CastleLimit": 2, + "NetherGateLimit": 1, + "ThroneOfDarknessLimit": 1 + }, + "PlayerInteractionSettings": { + "TimeZone": "Local", + "VSPlayerWeekdayTime": { + "StartHour": 20, + "StartMinute": 0, + "EndHour": 22, + "EndMinute": 0 + }, + "VSPlayerWeekendTime": { + "StartHour": 20, + "StartMinute": 0, + "EndHour": 22, + "EndMinute": 0 + }, + "VSCastleWeekdayTime": { + "StartHour": 20, + "StartMinute": 0, + "EndHour": 22, + "EndMinute": 0 + }, + "VSCastleWeekendTime": { + "StartHour": 20, + "StartMinute": 0, + "EndHour": 22, + "EndMinute": 0 + } + }, + "TraderModifiers": { + "StockModifier": 1.0, + "PriceModifier": 1.0, + "RestockTimerModifier": 1.0 + }, + "WarEventGameSettings": { + "Interval": 1, + "MajorDuration": 1, + "MinorDuration": 1, + "WeekdayTime": { + "StartHour": 0, + "StartMinute": 0, + "EndHour": 23, + "EndMinute": 59 + }, + "WeekendTime": { + "StartHour": 0, + "StartMinute": 0, + "EndHour": 23, + "EndMinute": 59 + }, + "ScalingPlayers1": { + "PointsModifier": 1.0, + "DropModifier": 1.0 + }, + "ScalingPlayers2": { + "PointsModifier": 0.5, + "DropModifier": 0.5 + }, + "ScalingPlayers3": { + "PointsModifier": 0.25, + "DropModifier": 0.25 + }, + "ScalingPlayers4": { + "PointsModifier": 0.25, + "DropModifier": 0.25 + } + } +} \ No newline at end of file diff --git a/files/config_templates/ServerHostSettings.json.template b/files/config_templates/ServerHostSettings.json.template new file mode 100755 index 0000000..f7ef909 --- /dev/null +++ b/files/config_templates/ServerHostSettings.json.template @@ -0,0 +1,29 @@ +{ + "Name": "${HOST_SETTINGS_NAME}", + "Description": "${HOST_SETTINGS_DESCRIPTION}", + "Port": ${GAME_PORT}, + "QueryPort": ${QUERY_PORT}, + "MaxConnectedUsers": ${HOST_SETTINGS_MAX_CONNECTED_USERS}, + "MaxConnectedAdmins": ${HOST_SETTINGS_MAX_CONNECTED_ADMINS}, + "ServerFps": ${HOST_SETTINGS_SERVER_FPS}, + "SaveName": "${SAVE_NAME}", + "Password": "${HOST_SETTINGS_PASSWORD}", + "Secure": true, + "ListOnSteam": ${HOST_SETTINGS_LISTEN_ON_STEAM}, + "ListOnEOS": ${HOST_SETTINGS_LISTEN_ON_EOS}, + "AutoSaveCount": ${HOST_SETTINGS_AUTOSAVE_COUNT}, + "AutoSaveInterval": ${HOST_SETTINGS_AUTOSAVE_INTERVAL}, + "CompressSaveFiles": true, + "GameSettingsPreset": "${GAME_SETTINGS_PRESET}", + "GameDifficultyPreset": "", + "AdminOnlyDebugEvents": true, + "DisableDebugEvents": false, + "API": { + "Enabled": false + }, + "Rcon": { + "Enabled": ${HOST_SETTINGS_RCON_ENABLE}, + "Port": ${HOST_SETTINGS_RCON_PORT}, + "Password": "${HOST_SETTINGS_RCON_PASSWORD}" + } +} \ No newline at end of file diff --git a/files/configs/crontab b/files/configs/crontab new file mode 100644 index 0000000..700abd0 --- /dev/null +++ b/files/configs/crontab @@ -0,0 +1 @@ +00 00 * * * /bin/bash -c /home/steam/files/scripts/cleanlogs.sh \ No newline at end of file diff --git a/files/configs/supervisord.conf b/files/configs/supervisord.conf new file mode 100644 index 0000000..f64158f --- /dev/null +++ b/files/configs/supervisord.conf @@ -0,0 +1,32 @@ +[supervisord] +logfile=%(ENV_PERSISTENT_DATA_PATH)s/%(ENV_logfile)s +nodaemon=true +logfile_maxbytes = 0 + +[program:supercronic] +command=/usr/local/bin/supercronic /home/steam/files/configs/crontab +autorestart=true +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 + +[program:vrisingserver] +command=xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' wine "%(ENV_SERVER_DATA_PATH)s/VRisingServer.exe" -persistentDataPath "%(ENV_PERSISTENT_DATA_PATH)s" -logFile "%(ENV_PERSISTENT_DATA_PATH)s/%(ENV_logfile)s" %(ENV_GAME_PORT)s %(ENV_QUERY_PORT)s 2>&1 +autorestart=false +numprocs=1 +startsecs=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 + +[program:tailtostdout] +command=tail -f "%(ENV_PERSISTENT_DATA_PATH)s/%(ENV_logfile)s" +autorestart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 + +[eventlistener:processes] +command=bash -c "echo READY && read line && kill -SIGQUIT $PPID" +events=PROCESS_STATE_STOPPED,PROCESS_STATE_EXITED,PROCESS_STATE_FATAL diff --git a/files/scripts/cleanlogs.sh.template b/files/scripts/cleanlogs.sh.template new file mode 100644 index 0000000..5849fb3 --- /dev/null +++ b/files/scripts/cleanlogs.sh.template @@ -0,0 +1,7 @@ +#!/bin/bash +echo "$(date) === Rotating logs" +cp "$(cat /home/steam/currentlog_path.txt)" "$PERSISTENT_DATA_PATH/$(date +%d-%m-%y)-VRisingServer.log" +truncate -s 0 "$(cat /home/steam/currentlog_path.txt)" +echo "$(date) === Cleaning up logs older than ${LOGDAYS} days" +find "${PERSISTENT_DATA_PATH}" -name "*.log" -type f -mtime +"${LOGDAYS}" -exec rm {} \; +echo "$(date) === Cleaned up Logfiles" | tee -a "$(cat /home/steam/currentlog_path.txt)" diff --git a/files/scripts/entrypoint.sh b/files/scripts/entrypoint.sh new file mode 100755 index 0000000..a6a3ef0 --- /dev/null +++ b/files/scripts/entrypoint.sh @@ -0,0 +1,108 @@ +#!/bin/bash +set -eu + +echo " " +echo " ================================================================ " +echo " Welcome to V Rising Docker " +echo " This Server is running a Wine Session " +echo " Please refer to the documentation to see config options " +echo " ================================================================ " +echo " " + +# Print Environment when debugging +if [[ "$DEBUG_ENV" == "true" ]]; then + echo " " + echo " ================================================================ " + echo " Showing Environment Variables " + echo " ================================================================ " + echo " " + env +fi + +echo " " +echo " ================================================================ " +echo " Creating folders and installing Gameserver " +echo " ================================================================ " +echo " " + +mkdir -v -p "$SERVER_DATA_PATH" +mkdir -v -p "$PERSISTENT_DATA_PATH" +/home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType windows +force_install_dir "$SERVER_DATA_PATH" +login anonymous +app_update 1829350 validate +quit + +echo "steam_appid: $(cat "${SERVER_DATA_PATH}"/steam_appid.txt)" + +echo " " +echo " ================================================================ " +echo " Checking AVX CPU Support " +echo " ================================================================ " +echo " " + +if grep -q -o 'avx[^ ]*' /proc/cpuinfo; then + unsupported_file="VRisingServer_Data/Plugins/x86_64/lib_burst_generated.dll" + echo "AVX or AVX2 not supported; Check if unsupported ${unsupported_file} exists" + if [ -f "$SERVER_DATA_PATH/${unsupported_file}" ]; then + echo "Changing ${unsupported_file} as attempt to fix issues..." + mv "$SERVER_DATA_PATH/${unsupported_file}" "$SERVER_DATA_PATH/${unsupported_file}.bak" + fi +else + echo "CPU supporting AVX, continuing..." +fi + +echo " " +echo " ================================================================ " +echo " Creating Config Files " +echo " ================================================================ " +echo " " + +mkdir -p "$PERSISTENT_DATA_PATH/Settings" + +if [[ "${OVERRIDE_CONFIG}" == "true" ]]; then + echo "Replacing config files. If you want to change this behaviour, set OVERRIDE_CONFIG to false" + envsubst < /home/steam/files/config_templates/ServerGameSettings.json.template > "$PERSISTENT_DATA_PATH/Settings/ServerGameSettings.json" + envsubst < /home/steam/files/config_templates/ServerHostSettings.json.template > "$PERSISTENT_DATA_PATH/Settings/ServerHostSettings.json" +elif [[ "${OVERRIDE_CONFIG}" == "false" ]]; then + if [[ ! -f "$PERSISTENT_DATA_PATH/Settings/ServerGameSettings.json" ]]; then + echo "Couldn't find $PERSISTENT_DATA_PATH/Settings/ServerGameSettings.json, creating..." + envsubst < /home/steam/files/config_templates/ServerGameSettings.json.template > "$PERSISTENT_DATA_PATH/Settings/ServerGameSettings.json" + fi + if [[ ! -f "$PERSISTENT_DATA_PATH/Settings/ServerHostSettings.json" ]]; then + echo "Couldn't find $PERSISTENT_DATA_PATH/Settings/ServerHostSettings.json, creating..." + envsubst < /home/steam/files/config_templates/ServerHostSettings.json.template > "$PERSISTENT_DATA_PATH/Settings/ServerHostSettings.json" + fi +fi + +echo " " +echo " ================================================================ " +echo " Creating Cron Scripts " +echo " ================================================================ " +echo " " + +envsubst < /home/steam/files/scripts/cleanlogs.sh.template > /home/steam/files/scripts/cleanlogs.sh +chmod +x /home/steam/files/scripts/cleanlogs.sh + +# Checks if log file exists, if not creates it +echo " " +echo " ================================================================ " +echo " Creating Log File " +echo " ================================================================ " +echo " " + +export logfile="VRisingServer.log" +if ! [ -f "$PERSISTENT_DATA_PATH/$logfile" ]; then + echo "Creating $PERSISTENT_DATA_PATH/$logfile" + touch "$PERSISTENT_DATA_PATH"/"$logfile" + echo "$PERSISTENT_DATA_PATH/$logfile" > /home/steam/currentlog_path.txt +fi +echo "$PERSISTENT_DATA_PATH/$logfile" > /home/steam/currentlog_path.txt + + +cd "$SERVER_DATA_PATH" + + +echo " " +echo " ================================================================ " +echo " Starting Server via Wine " +echo " ================================================================ " +echo " " + +/usr/bin/supervisord -c /home/steam/files/configs/supervisord.conf diff --git a/files/scripts/healthcheck.sh b/files/scripts/healthcheck.sh new file mode 100755 index 0000000..03e0edf --- /dev/null +++ b/files/scripts/healthcheck.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -eu + +pgrep -a "xvfb-run" -r "D|R|S" \ No newline at end of file diff --git a/kubernetes/kustomize/base/configMap.yaml b/kubernetes/kustomize/base/configMap.yaml new file mode 100644 index 0000000..7381376 --- /dev/null +++ b/kubernetes/kustomize/base/configMap.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: vrisingcm +data: + SERVER_DATA_PATH: "/home/steam/vrising/server" + PERSISTENT_DATA_PATH: "/home/steam/vrising/persistentdata" + HOST_SETTINGS_NAME: "My Kubernetes V-Rising Server" + HOST_SETTINGS_DESCRIPTION: "V Rising Server hosted by Kubernetes" + HOST_SETTINGS_PASSWORD: "" + HOST_SETTINGS_MAX_CONNECTED_USERS: "10" + HOST_SETTINGS_MAX_CONNECTED_ADMINS: "4" + HOST_SETTINGS_SERVER_ADMIN_LIST: "" + HOST_SETTINGS_SERVER_FPS: "30" + HOST_SETTINGS_RCON_ENABLE: "true" + HOST_SETTINGS_RCON_PORT: "9876" + HOST_SETTINGS_AUTOSAVE_COUNT: "40" + HOST_SETTINGS_AUTOSAVE_INTERVAL: "120" + HOST_SETTINGS_LISTEN_ON_STEAM: "false" + HOST_SETTINGS_LISTEN_ON_EOS: "false" + GAME_SETTINGS_PRESET: "StandardPvP" + GAME_SETTINGS_DIFFICULTY: "Normal" + LIST_ON_MASTER_SERVER: "true" + SERVER_IP: "127.0.0.1" + SAVE_NAME: "default_world" + GAME_PORT: "9876" + QUERY_PORT: "9877" + STEAM_USER_UID: "1000" + STEAM_USER_GID: "1000" + DEBUG_ENV: "true" diff --git a/kubernetes/kustomize/base/deployment.yaml b/kubernetes/kustomize/base/deployment.yaml new file mode 100644 index 0000000..328973d --- /dev/null +++ b/kubernetes/kustomize/base/deployment.yaml @@ -0,0 +1,59 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: vrisingserverdeployment +spec: + selector: + matchLabels: + app: vRisingServer + template: + metadata: + labels: + app: vRisingServer + spec: + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + volumes: + - name: persistentdata + persistentVolumeClaim: + claimName: vrisingpersistentdata + - name: serverdata + persistentVolumeClaim: + claimName: vrisingserverdata + containers: + - name: vrisingservercontainer + image: example.com/path/to/image:tag + volumeMounts: + - name: persistentdata + mountPath: /home/steam/vrising/persistentdata + - name: serverdata + mountPath: /home/steam/vrising/server + envFrom: + - configMapRef: + name: vrisingcm + - secretRef: + name: vrisingsecret + resources: + limits: + memory: "4Gi" + cpu: "4" + requests: + memory: "4Gi" + cpu: "1" + livenessProbe: + exec: + command: + - /bin/bash + - -c + - /home/steam/files/scripts/healthcheck.sh + initialDelaySeconds: 360 + periodSeconds: 20 + ports: + - protocol: UDP + containerPort: 9876 + - protocol: TCP + containerPort: 9876 + - protocol: UDP + containerPort: 9877 diff --git a/kubernetes/kustomize/base/kustomization.yaml b/kubernetes/kustomize/base/kustomization.yaml new file mode 100644 index 0000000..afd6094 --- /dev/null +++ b/kubernetes/kustomize/base/kustomization.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: vrising +commonLabels: + app: vRisingServer +resources: + - configMap.yaml + - deployment.yaml + - secret.yaml + - nodePort.yaml + - networkPolicy.yaml + - pvc.yaml \ No newline at end of file diff --git a/kubernetes/kustomize/base/networkPolicy.yaml b/kubernetes/kustomize/base/networkPolicy.yaml new file mode 100644 index 0000000..37a6fee --- /dev/null +++ b/kubernetes/kustomize/base/networkPolicy.yaml @@ -0,0 +1,63 @@ +--- +kind: NetworkPolicy +apiVersion: networking.k8s.io/v1 +metadata: + name: vrisingdenyall +spec: + podSelector: + matchLabels: + app: vRisingServer + policyTypes: + - Ingress + - Egress + +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: vrisinginternetegress +spec: + podSelector: + matchLabels: + app: vRisingServer + policyTypes: + - Egress + egress: + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + - podSelector: + matchLabels: + k8s-app: kube-dns + ports: + - protocol: UDP + port: 53 + + - to: + - ipBlock: + cidr: 0.0.0.0/0 + except: + - 10.0.0.0/8 + - 192.168.0.0/16 + - 172.16.0.0/12 + +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: vrisinginternetingress +spec: + podSelector: + matchLabels: + app: vRisingServer + policyTypes: + - Ingress + ingress: + - ports: + - port: 9876 + protocol: UDP + - port: 9876 + - port: 9877 + protocol: UDP + diff --git a/kubernetes/kustomize/base/nodePort.yaml b/kubernetes/kustomize/base/nodePort.yaml new file mode 100644 index 0000000..52ba3da --- /dev/null +++ b/kubernetes/kustomize/base/nodePort.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + name: vrisingnodeport +spec: + type: NodePort + selector: + app: vRisingServer + ports: + - name: gameport + port: 9876 + protocol: UDP + nodePort: 30876 + targetPort: 9876 + - name: rconport + port: 9876 + protocol: TCP + nodePort: 30876 + targetPort: 9876 + - name: queryport + port: 9877 + protocol: UDP + nodePort: 30877 + targetPort: 9877 \ No newline at end of file diff --git a/kubernetes/kustomize/base/pvc.yaml b/kubernetes/kustomize/base/pvc.yaml new file mode 100644 index 0000000..85bd8b5 --- /dev/null +++ b/kubernetes/kustomize/base/pvc.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: vrisingpersistentdata +spec: + resources: + requests: + storage: 5Gi + volumeMode: Filesystem + storageClassName: my-storage-class + accessModes: + - ReadWriteOnce + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: vrisingserverdata +spec: + resources: + requests: + storage: 10Gi + volumeMode: Filesystem + storageClassName: my-storage-class + accessModes: + - ReadWriteOnce \ No newline at end of file diff --git a/kubernetes/kustomize/base/secret.yaml b/kubernetes/kustomize/base/secret.yaml new file mode 100644 index 0000000..9a9d483 --- /dev/null +++ b/kubernetes/kustomize/base/secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: vrisingsecret +type: Opaque +data: + HOST_SETTINGS_RCON_PASSWORD: Q2g4bmczbTNQbDNAczMh diff --git a/kubernetes/kustomize/overlays/exampleorg/configMap.yaml b/kubernetes/kustomize/overlays/exampleorg/configMap.yaml new file mode 100644 index 0000000..278dde6 --- /dev/null +++ b/kubernetes/kustomize/overlays/exampleorg/configMap.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: vrisingcm +data: + SERVER_DATA_PATH: "/home/steam/vrising/server" + PERSISTENT_DATA_PATH: "/home/steam/vrising/persistentdata" + HOST_SETTINGS_NAME: "My Kubernetes V-Rising Server" + HOST_SETTINGS_DESCRIPTION: "V Rising Server hosted by Kubernetes" + HOST_SETTINGS_PASSWORD: "start123" + HOST_SETTINGS_MAX_CONNECTED_USERS: "10" + HOST_SETTINGS_MAX_CONNECTED_ADMINS: "4" + HOST_SETTINGS_SERVER_ADMIN_LIST: "" + HOST_SETTINGS_SERVER_FPS: "30" + HOST_SETTINGS_RCON_ENABLE: "true" + HOST_SETTINGS_RCON_PORT: "9876" + HOST_SETTINGS_AUTOSAVE_COUNT: "40" + HOST_SETTINGS_AUTOSAVE_INTERVAL: "120" + HOST_SETTINGS_LISTEN_ON_STEAM: "false" + HOST_SETTINGS_LISTEN_ON_EOS: "false" + GAME_SETTINGS_PRESET: "StandardPvP" + GAME_SETTINGS_DIFFICULTY: "Normal" + LIST_ON_MASTER_SERVER: "true" + SERVER_IP: "127.0.0.1" + SAVE_NAME: "default_world" + GAME_PORT: "9876" + QUERY_PORT: "9877" + STEAM_USER_UID: "1000" + STEAM_USER_GID: "1000" + DEBUG_ENV: "true" \ No newline at end of file diff --git a/kubernetes/kustomize/overlays/exampleorg/deployment.yaml b/kubernetes/kustomize/overlays/exampleorg/deployment.yaml new file mode 100644 index 0000000..fad1ed3 --- /dev/null +++ b/kubernetes/kustomize/overlays/exampleorg/deployment.yaml @@ -0,0 +1,10 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: vrisingserverdeployment +spec: + template: + spec: + containers: + - name: vrisingservercontainer + image: example.org/path/to/image:tag diff --git a/kubernetes/kustomize/overlays/exampleorg/kustomization.yaml b/kubernetes/kustomize/overlays/exampleorg/kustomization.yaml new file mode 100644 index 0000000..78024ab --- /dev/null +++ b/kubernetes/kustomize/overlays/exampleorg/kustomization.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: vRisingServerExampleOrg +commonLabels: + variant: exampleorg + app: vRisingServer +resources: + - ../../base +patches: + - path: configMap.yaml + - path: secret.yaml + - path: deployment.yaml +patchesStrategicMerge: # This might be deprecated, but there is no actual fix for multi-part yaml files like the pvc.yml https://github.com/kubernetes-sigs/kustomize/issues/5052 + - pvc.yaml # I don't want to split this into two files... + # Kustomize should support this in the future: https://github.com/kubernetes-sigs/kustomize/issues/5049 + # This can then be moved back to patches: - path: pvc.yaml diff --git a/kubernetes/kustomize/overlays/exampleorg/pvc.yaml b/kubernetes/kustomize/overlays/exampleorg/pvc.yaml new file mode 100644 index 0000000..029b2a2 --- /dev/null +++ b/kubernetes/kustomize/overlays/exampleorg/pvc.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: vrisingpersistentdata +spec: + resources: + requests: + storage: 5Gi + volumeMode: Filesystem + storageClassName: my-longhorn-storage-class + accessModes: + - ReadWriteOnce + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: vrisingserverdata +spec: + resources: + requests: + storage: 15Gi + volumeMode: Filesystem + storageClassName: my-longhorn-storage-class + accessModes: + - ReadWriteOnce diff --git a/kubernetes/kustomize/overlays/exampleorg/secret.yaml b/kubernetes/kustomize/overlays/exampleorg/secret.yaml new file mode 100644 index 0000000..9db500f --- /dev/null +++ b/kubernetes/kustomize/overlays/exampleorg/secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: vrisingsecret +type: Opaque +data: + HOST_SETTINGS_RCON_PASSWORD: U2VyaW91c2x5Q2hhbmdlVGhpcz8= diff --git a/src/debian.sources b/src/debian.sources new file mode 100644 index 0000000..353adfa --- /dev/null +++ b/src/debian.sources @@ -0,0 +1,13 @@ +Types: deb +# http://snapshot.debian.org/archive/debian/20240513T000000Z +URIs: http://deb.debian.org/debian +Suites: bookworm bookworm-updates +Components: main contrib non-free non-free-firmware +Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg + +Types: deb +# http://snapshot.debian.org/archive/debian-security/20240513T000000Z +URIs: http://deb.debian.org/debian-security +Suites: bookworm-security +Components: main contrib non-free non-free-firmware +Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg diff --git a/start.sh b/start.sh deleted file mode 100644 index 350a8f5..0000000 --- a/start.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -s=/mnt/vrising/server -p=/mnt/vrising/persistentdata - -term_handler() { - echo "Shutting down Server" - - PID=$(pgrep -f "^${s}/VRisingServer.exe") - if [[ -z $PID ]]; then - echo "Could not find VRisingServer.exe pid. Assuming server is dead..." - else - kill -n 15 "$PID" - wait "$PID" - fi - wineserver -k - sleep 1 - exit -} - -cleanup_logs() { - echo "Cleaning up logs older than $LOGDAYS days" - find "$p" -name "*.log" -type f -mtime +$LOGDAYS -exec rm {} \; -} - -trap 'term_handler' SIGTERM - -if [ -z "$LOGDAYS" ]; then - LOGDAYS=30 -fi -if [[ -n $UID ]]; then - usermod -u "$UID" docker 2>&1 -fi -if [[ -n $GID ]]; then - groupmod -g "$GID" docker 2>&1 -fi -if [ -z "$SERVERNAME" ]; then - SERVERNAME="trueosiris-V" -fi -override_savename="" -if [[ -n "$WORLDNAME" ]]; then - override_savename="-saveName $WORLDNAME" -fi -game_port="" -if [[ -n $GAMEPORT ]]; then - game_port=" -gamePort $GAMEPORT" -fi -query_port="" -if [[ -n $QUERYPORT ]]; then - query_port=" -queryPort $QUERYPORT" -fi - -cleanup_logs - -mkdir -p /root/.steam 2>/dev/null -chmod -R 777 /root/.steam 2>/dev/null -echo " " -echo "Updating V-Rising Dedicated Server files..." -echo " " -/usr/bin/steamcmd +@sSteamCmdForcePlatformType windows +force_install_dir "$s" +login anonymous +app_update 1829350 validate +quit -printf "steam_appid: " -cat "$s/steam_appid.txt" - -echo " " -if ! grep -q -o 'avx[^ ]*' /proc/cpuinfo; then - unsupported_file="VRisingServer_Data/Plugins/x86_64/lib_burst_generated.dll" - echo "AVX or AVX2 not supported; Check if unsupported ${unsupported_file} exists" - if [ -f "${s}/${unsupported_file}" ]; then - echo "Changing ${unsupported_file} as attempt to fix issues..." - mv "${s}/${unsupported_file}" "${s}/${unsupported_file}.bak" - fi -fi - -echo " " -mkdir "$p/Settings" 2>/dev/null -if [ ! -f "$p/Settings/ServerGameSettings.json" ]; then - echo "$p/Settings/ServerGameSettings.json not found. Copying default file." - cp "$s/VRisingServer_Data/StreamingAssets/Settings/ServerGameSettings.json" "$p/Settings/" 2>&1 -fi -if [ ! -f "$p/Settings/ServerHostSettings.json" ]; then - echo "$p/Settings/ServerHostSettings.json not found. Copying default file." - cp "$s/VRisingServer_Data/StreamingAssets/Settings/ServerHostSettings.json" "$p/Settings/" 2>&1 -fi - -# Checks if log file exists, if not creates it -current_date=$(date +"%Y%m%d-%H%M") -logfile="$current_date-VRisingServer.log" -if ! [ -f "${p}/$logfile" ]; then - echo "Creating ${p}/$logfile" - touch "$p/$logfile" -fi - -cd "$s" || { - echo "Failed to cd to $s" - exit 1 -} -echo "Starting V Rising Dedicated Server with name $SERVERNAME" -echo "Trying to remove /tmp/.X0-lock" -rm /tmp/.X0-lock 2>&1 -echo " " -echo "Starting Xvfb" -Xvfb :0 -screen 0 1024x768x16 & -echo "Launching wine64 V Rising" -echo " " -v() { - DISPLAY=:0.0 wine64 /mnt/vrising/server/VRisingServer.exe -persistentDataPath $p -serverName "$SERVERNAME" "$override_savename" -logFile "$p/$logfile" "$game_port" "$query_port" 2>&1 & -} -v -# Gets the PID of the last command -ServerPID=$! - -# Tail log file and waits for Server PID to exit -/usr/bin/tail -n 0 -f "$p/$logfile" & -wait $ServerPID