From a6bca4959e0e24f189f0149b4d5705d7536d8ba6 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com> Date: Mon, 12 Feb 2024 09:04:05 +0100 Subject: [PATCH] refactoring of most of the code-base, added changelog, added user-jails for UID/PID swapping, added backupmanager by thejcpalma, updated rcon behavior and documentation --- CHANGELOG.md | 11 ++- Dockerfile | 19 ++--- README.md | 57 ++++++------- default.env | 6 +- docs/ENV_VARS.md | 169 +++++++++++++++++++++------------------ entrypoint.sh | 33 ++++++-- includes/config.sh | 142 ++++++++++++++++---------------- includes/cron.sh | 2 +- includes/security.sh | 3 +- includes/webhook.sh | 4 +- scripts/rconcli.sh | 10 +-- scripts/servermanager.sh | 10 ++- 12 files changed, 258 insertions(+), 208 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb52d30..5117dd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog -## 2024-02-09 +[Back to main](README.md#changelog) + +## 2024-02-12 * **Breaking changes:** * Changed the default BACKUP_RETENTION_POLICY to true and changed BACKUP_RETENTION_AMOUNT_TO_KEEP to 72, meaning 3 days worth of backup are kept in the default configuration * Added the ability to change the PUID and PGID via environment variables, this includes a user-process-jail mechanic including entrypoint-script, which makes sure that the gameserver is always working with the right permissions as only user steam and not root by accident or bug @@ -12,6 +14,11 @@ * Added shell linting * Changed structure of the project and where files like documentation, includes, scripts and config-templates are to find * Fixed typos in various documents +* Requirements - What you need to do: + * **Read the readme, a lot has changed, there is a new part about the backupmanager and how to interact now with rconcli** + * Update to latest image + * Download new docker-compose.yml and new default.env + * Merge your settings and make sure that backup-settings, PGID and PUID are right ## 2024-02-03 @@ -19,3 +26,5 @@ * Added rcon.sh again for having alias function calls that dont bloat the servermanager * Refactored how webhook messages function are called and added alias functions * Added a changelog, from various request resources + +[Back to main](README.md#changelog) diff --git a/Dockerfile b/Dockerfile index cb29d40..b16ec2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,11 +47,11 @@ ENV DEBIAN_FRONTEND=noninteractive \ WEBHOOK_UPDATE_VALIDATION_TITLE="Updating and validating server" \ WEBHOOK_UPDATE_VALIDATION_DESCRIPTION="Server is being updated and validated" \ WEBHOOK_UPDATE_VALIDATION_COLOR="2849520" \ + # Config-setting - Warning: Every setting below here will be affected! + SERVER_SETTINGS_MODE=manual \ # Gameserver-start-settings MULTITHREAD_ENABLED=true \ COMMUNITY_SERVER=true \ - # Config-setting - Warning: Every setting below here will be affected! - SERVER_SETTINGS_MODE=manual \ # Engine.ini settings NETSERVERMAXTICKRATE=120 \ # PalWorldSettings.ini settings @@ -121,19 +121,20 @@ ENV DEBIAN_FRONTEND=noninteractive \ EXPOSE 8211/udp EXPOSE 25575/tcp -COPY --chown=steam:steam --chmod=755 scripts/ /scripts -COPY --chown=steam:steam --chmod=755 includes/ /includes -COPY --chown=steam:steam --chmod=755 configs/rcon.yaml /home/steam/steamcmd/rcon.yaml -COPY --chown=steam:steam --chmod=755 entrypoint.sh / +COPY --chmod=744 entrypoint.sh / +COPY --chmod=755 scripts/ /scripts +COPY --chmod=755 includes/ /includes +COPY --chmod=755 configs/rcon.yaml /home/steam/steamcmd/rcon.yaml -RUN ln -s /scripts/backupmanager.sh /usr/local/bin/backup \ +RUN mkdir -p "$BACKUP_PATH" \ + && ln -s /scripts/backupmanager.sh /usr/local/bin/backup \ && ln -s /scripts/rconcli.sh /usr/local/bin/rconcli # Install minimum required packages for dedicated server RUN apt-get update \ - && apt-get install -y --no-install-recommends --no-install-suggests procps xdg-user-dirs \ + && apt-get install -y --no-install-recommends --no-install-suggests gosu procps xdg-user-dirs \ + && apt-get autoremove -y --purge \ && apt-get clean \ - && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Latest releases available at https://github.com/aptible/supercronic/releases diff --git a/README.md b/README.md index e9878c1..3da98f0 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ ___ - [How to ask for support for this Docker image](#how-to-ask-for-support-for-this-docker-image) - [Requirements](#requirements) - [Minimum system requirements](#minimum-system-requirements) + - [Changelog](#changelog) - [Getting started](#getting-started) - [Environment variables](#environment-variables) - [Docker-Compose examples](#docker-compose-examples) @@ -68,17 +69,26 @@ To run this Docker image, you need a basic understanding of Docker, Docker-Compo | RAM | 8GB RAM Base + 2GB per player | 12GB RAM Base + 2GB per player | | Storage | 30GB | 30GB+ | +## Changelog + +You can find the [changelog here](CHANGELOG.md) + ## Getting started -1. Create a `game` sub-directory on your Docker-Node in your game-server-directory (Example: `/srv/palworld`). - - This directory will be used to store the game server files, including configs and savegames. -2. Set up Port-Forwarding or NAT for the ports in the Docker-Compose file. -3. Pull the latest version of the image with `docker pull jammsen/palworld-dedicated-server:latest`. -4. Download the [docker-compose.yml](docker-compose.yml) and [default.env](default.env). -5. Set up the `docker-compose.yml` and `default.env` to your liking. - - Refer to the [Environment-Variables](#environment-variables) section for more information. -6. Start the container via `docker-compose up -d && docker-compose logs -f`. - - Watch the log, if no errors occur you can close the logs with ctrl+c. +1. Create a `game` sub-directory on your Docker-Node in your game-server-directory + - (Examples: `/srv/palworld`, `/opt/palworld` or `/home/username/palworld`) + - This directory will be used to store the game server files, including configs and savegames + - In older versions we asked you to setup permissions via CHMOD or CHOWN, this should not be needed anymore! +2. Set up Port-Forwarding or NAT for the ports in the Docker-Compose file +3. Pull the latest version of the image with `docker pull jammsen/palworld-dedicated-server:latest` +4. Download the [docker-compose.yml](docker-compose.yml) and [default.env](default.env) +5. Set up the `docker-compose.yml` and `default.env` to your liking + - Make sure you setup PUID and PGID according to the user you want to use + - **PUID and PGID 0 will error out, thats on purpose!** + - if you use Docker as root, then you can just use 1000 inside the container + - Refer to the [Environment-Variables](#environment-variables) section for more information +6. Start the container via `docker-compose up -d && docker-compose logs -f` + - Watch the log, if no errors occur you can close the logs with ctrl+c 7. Now have fun and happy gaming! 🎮😉 ## Environment variables @@ -96,18 +106,7 @@ See [example docker-compose.yml](docker-compose.yml). > [!NOTE] > Please research the RCON-Commands on the official source: https://tech.palworldgame.com/server-commands -Open a shell into your container via `docker exec -ti palworld-dedicated-server bash`, then you can run commands against the gameserver via the command `rconcli` - -```shell -$:~/steamcmd$ rconcli showplayers -name,playeruid,steamid -$:~/steamcmd$ rconcli info -Welcome to Pal Server[v0.1.4.1] jammsen-docker-generated-20384 -$:~/steamcmd$ rconcli save -Complete Save -``` - -You can also use `docker exec palworld-dedicated-server rconcli ` right on your terminal/shell. +You can use `docker exec palworld-dedicated-server rconcli ` right on your terminal/shell. ```shell $ docker exec palworld-dedicated-server rconcli showplayers @@ -123,13 +122,17 @@ Complete Save ## Backup Manager > [!WARNING] -> If RCON is disabled, the backup manager won't do saves via RCON before creating a backup. +> If RCON is disabled, the backup manager won't do saves via RCON before creating a backup and will report warnings. > This means that the backup will be created from the last auto-save of the server. > This can lead to data-loss and/or savegame corruption. > > **Recommendation:** Please make sure that RCON is enabled before using the backup manager. -Usage: `docker exec palworld-dedicated-server backup [command] [arguments]` +> [!WARNING] +> Please use in the following part always the `-user steam` option or your files will written as root + + +Usage: `docker exec -user steam palworld-dedicated-server backup [command] [arguments]` | Command | Argument | Required/Optional | Default Value | Values | Description | | ------- | ------------------ | ----------------- | --------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | @@ -140,24 +143,24 @@ Usage: `docker exec palworld-dedicated-server backup [command] [arguments]` Examples: ```shell -$ docker exec palworld-dedicated-server backup +$ docker exec -user steam palworld-dedicated-server backup > Backup 'saved-20240203_032855.tar.gz' created successfully. ``` ```shell -$ docker exec palworld-dedicated-server backup list +$ docker exec -user steam palworld-dedicated-server backup list > Listing 2 backup file(s)! 2024-02-03 03:28:55 | saved-20240203_032855.tar.gz 2024-02-03 03:28:00 | saved-20240203_032800.tar.gz ``` ```shell -$ docker exec palworld-dedicated-server backup_clean 3 +$ docker exec -user steam palworld-dedicated-server backup_clean 3 > 1 backup(s) cleaned, keeping 2 backups(s). ``` ```shell -$ docker exec palworld-dedicated-server backup_list +$ docker exec -user steam palworld-dedicated-server backup_list > Listing 1 out of backup 2 file(s). 2024-02-03 03:30:00 | saved-20240203_033000.tar.gz ``` diff --git a/default.env b/default.env index af93115..bb45b17 100644 --- a/default.env +++ b/default.env @@ -1,4 +1,6 @@ # Container-setttings +PUID=1000 +PGID=1000 TZ=Europe/Berlin # SteamCMD-settings ALWAYS_UPDATE_ON_START=true @@ -26,11 +28,11 @@ WEBHOOK_UPDATE_COLOR="2849520" WEBHOOK_UPDATE_VALIDATION_TITLE="Updating and validating server" WEBHOOK_UPDATE_VALIDATION_DESCRIPTION="Server is being updated and validated" WEBHOOK_UPDATE_VALIDATION_COLOR="2849520" +# Config-setting - Warning: Every setting below here will be affected! +SERVER_SETTINGS_MODE=auto # Gameserver-start-settings MULTITHREAD_ENABLED=true COMMUNITY_SERVER=true -# Config-setting - Warning: Every setting below here will be affected! -SERVER_SETTINGS_MODE=auto # Engine.ini settings NETSERVERMAXTICKRATE=120 # PalWorldSettings.ini settings diff --git a/docs/ENV_VARS.md b/docs/ENV_VARS.md index 6976ba4..1a5e331 100644 --- a/docs/ENV_VARS.md +++ b/docs/ENV_VARS.md @@ -10,18 +10,31 @@ These settings control the behavior of the Docker container: > **Important:** If you want to change the server settings via environment variables use the default value (`auto`) for the environment variable `SERVER_SETTINGS_MODE`, otherwise change it to `manual` and edit the config file directly. -| Variable | Description | Default value | Allowed values | -| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| TZ | Timezone used for time stamping server backups | Europe/Berlin | See [TZ identifiers](#tz-identifiers) | -| ALWAYS_UPDATE_ON_START | Updates the server on startup | true | false/true | -| MULTITHREAD_ENABLED | Sets options for "Improved multi-threaded CPU performance" | true | false/true | -| COMMUNITY_SERVER | Set to enabled, the server will appear in the Community-Serverlist | true | false/true | -| BACKUP_ENABLED | Backup function, creates backups in your `game` directory | true | false/true | -| BACKUP_CRON_EXPRESSION | Needs a Cron-Expression - See [Cron expression](#cron-expression) | 0 * * * * (meaning every hour) | Cron-Expression | -| BACKUP_RETENTION_POLICY | Set to enabled, will cleanup old backups | false | false/true | -| BACKUP_RETENTION_AMOUNT_TO_KEEP | Defines how many backups in numbers to keep | 30 | Integer | -| SERVER_SETTINGS_MODE | Determines whether settings can be modified via environment variables or via file, except `COMMUNITY_SERVER` and `MULTITHREAD_ENABLED`! | `auto` | `auto`: Settings are modified only by environment variables, manual edits will be ignored
`manual`: Settings are modified only by editing the file directly, environment variables are ignored | -| STEAMCMD_VALIDATE_FILES | Set to enabled SteamCMD will also validate the gameserver files, making sure nothing is corrupted and also overwrite any file changes of the source
See https://developer.valvesoftware.com/wiki/SteamCMD#Downloading_an_App | true | false/true | +| Variable | Description | Default value | Allowed values | +| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| PUID | PUID stands for Process User ID, also known as UID | 1000 | Integer | +| PGID | PGID stands for Process Group ID, also known as GID | 1000 | Integer | +| TZ | Timezone used for time stamping server backups | Europe/Berlin | See [TZ identifiers](#tz-identifiers) | +| ALWAYS_UPDATE_ON_START | Updates the server on startup | true | Boolean | +| STEAMCMD_VALIDATE_FILES | Set to enabled SteamCMD will also validate the gameserver files, making sure nothing is corrupted and also overwrite any file changes of the source
See https://developer.valvesoftware.com/wiki/SteamCMD#Downloading_an_App | true | Boolean | +| BACKUP_ENABLED | Backup function, creates backups in your `game` directory | true | Boolean | +| BACKUP_CRON_EXPRESSION | Needs a Cron-Expression - See [Cron expression](#cron-expression) | 0 * * * * (meaning every hour) | Cron-Expression | +| BACKUP_RETENTION_POLICY | Set to enabled, will cleanup old backups | true | Boolean | +| BACKUP_RETENTION_AMOUNT_TO_KEEP | Defines how many backups in numbers to keep | 72 | Integer | +| WEBHOOK_ENABLED | Set to enabled will send webhook notifications, NEEDS `WEBHOOK_URL` | false | Boolean | +| WEBHOOK_URL | Defines the url the webhook to send data to | | Url | +| WEBHOOK_* | See below the table "Webhook environment variables" | | String | +| SERVER_SETTINGS_MODE | Determines whether settings can be modified via environment variables or via file, except `COMMUNITY_SERVER` and `MULTITHREAD_ENABLED`! | `auto` | Enum
`auto`: Settings are modified only by environment variables, manual edits will be ignored
`manual`: Settings are modified only by editing the file directly, environment variables are ignored | + +### Webhook environment variables + +> [!WARNING] +> **IMPORTANT: Don't use Hex-Colors!** +> +> Go to the page, search for the Hex-Color, after that add the DECIMAL-Representation to the color field or it will break for Discord! +> >https://www.spycolor.com/ + +There are a lot of Variables to setup for messages and colors to send to the webhook url in the `default.env` ### TZ identifiers @@ -44,71 +57,73 @@ Information sources and credits to the following websites: > > To change a setting, you can set the environment variable to the value you want. If the environment variable is not set or is blank, the default value will be used. -| Variable | Game setting | Description | Default value | Allowed value | -| ----------------------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | ------------- | -| NETSERVERMAXTICKRATE | NetServerMaxTickRate | Changes the TickRate of the server, be very careful with this setting! | 120 | 30-120 | -| DIFFICULTY | Difficulty | Choose one of the following:
`None`
`Normal`
`Difficult` | None | Enum | -| DAYTIME_SPEEDRATE | DayTimeSpeedRate | Day time speed - Smaller number means shorter days | 1.000000 | Float | -| NIGHTTIME_SPEEDRATE | NightTimeSpeedRate | Night time speed - Smaller number means shorter nights | 1.000000 | Float | -| EXP_RATE | ExpRate | EXP rate | 1.000000 | Float | -| PAL_CAPTURE_RATE | PalCaptureRate | Pal capture rate | 1.000000 | Float | -| PAL_SPAWN_NUM_RATE | PalSpawnNumRate | Pal appearance rate | 1.000000 | Float | -| PAL_DAMAGE_RATE_ATTACK | PalDamageRateAttack | Damage from pals multiplier | 1.000000 | Float | -| PAL_DAMAGE_RATE_DEFENSE | PalDamageRateDefense | Damage to pals multiplier | 1.000000 | Float | -| PLAYER_DAMAGE_RATE_ATTACK | PlayerDamageRateAttack | Damage from player multiplier | 1.000000 | Float | -| PLAYER_DAMAGE_RATE_DEFENSE | PlayerDamageRateDefense | Damage to player multiplier | 1.000000 | Float | -| PLAYER_STOMACH_DECREASE_RATE | PlayerStomachDecreaceRate | Player hunger depletion rate | 1.000000 | Float | -| PLAYER_STAMINA_DECREACE_RATE | PlayerStaminaDecreaceRate | Player stamina reduction rate | 1.000000 | Float | -| PLAYER_AUTO_HP_REGENE_RATE | PlayerAutoHPRegeneRate | Player auto HP regeneration rate | 1.000000 | Float | -| PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP | PlayerAutoHpRegeneRateInSleep | Player sleep HP regeneration rate | 1.000000 | Float | -| PAL_STOMACH_DECREACE_RATE | PalStomachDecreaceRate | Pal hunger depletion rate | 1.000000 | Float | -| PAL_STAMINA_DECREACE_RATE | PalStaminaDecreaceRate | Pal stamina reduction rate | 1.000000 | Float | -| PAL_AUTO_HP_REGENE_RATE | PalAutoHPRegeneRate | Pal auto HP regeneration rate | 1.000000 | Float | -| PAL_AUTO_HP_REGENE_RATE_IN_SLEEP | PalAutoHpRegeneRateInSleep | Pal sleep health regeneration rate (in Palbox) | 1.000000 | Float | -| BUILD_OBJECT_DAMAGE_RATE | BuildObjectDamageRate | Damage to structure multiplier | 1.000000 | Float | -| BUILD_OBJECT_DETERIORATION_DAMAGE_RATE | BuildObjectDeteriorationDamageRate | Structure deterioration rate | 1.000000 | Float | -| COLLECTION_DROP_RATE | CollectionDropRate | Gatherable items multiplier | 1.000000 | Float | -| COLLECTION_OBJECT_HP_RATE | CollectionObjectHpRate | Gatherable objects HP multiplier | 1.000000 | Float | -| COLLECTION_OBJECT_RESPAWN_SPEED_RATE | CollectionObjectRespawnSpeedRate | Gatherable objects respawn interval | 1.000000 | Float | -| ENEMY_DROP_ITEM_RATE | EnemyDropItemRate | Dropped Items Multiplier | 1.000000 | Float | -| DEATH_PENALTY | DeathPenalty | `None` : No lost
`Item` : Lost item without equipment
`ItemAndEquipment` : Lost item and equipment
`All`: Lost All item, equipment, pal(in inventory) | All | Enum | -| ENABLE_PLAYER_TO_PLAYER_DAMAGE | bEnablePlayerToPlayerDamage | Allows players to cause damage to players | false | Boolean | -| ENABLE_FRIENDLY_FIRE | bEnableFriendlyFire | Allow friendly fire | false | Boolean | -| ENABLE_INVADER_ENEMY | bEnableInvaderEnemy | Enable invaders | true | Boolean | -| ACTIVE_UNKO | bActiveUNKO | Enable UNKO | false | Boolean | -| ENABLE_AIM_ASSIST_PAD | bEnableAimAssistPad | Enable controller aim assist | true | Boolean | -| ENABLE_AIM_ASSIST_KEYBOARD | bEnableAimAssistKeyboard | Enable Keyboard aim assist | false | Boolean | -| DROP_ITEM_MAX_NUM | DropItemMaxNum | Maximum number of drops in the world | 3000 | Integer | -| DROP_ITEM_MAX_NUM_UNKO | DropItemMaxNum | Maximum number of UNKO drops in the world | 100 | Integer | -| BASE_CAMP_MAX_NUM | BaseCampMaxNum | Maximum number of base camps | 128 | Integer | -| BASE_CAMP_WORKER_MAXNUM | BaseCampWorkerMaxNum | Maximum number of workers | 15 | Integer | -| DROP_ITEM_ALIVE_MAX_HOURS | DropItemAliveMaxHours | Time it takes for items to despawn in hours | 1.000000 | Float | -| AUTO_RESET_GUILD_NO_ONLINE_PLAYERS | bAutoResetGuildNoOnlinePlayers | Automatically reset guild when no players are online | false | Bool | -| AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS | AutoResetGuildTimeNoOnlinePlayers | Time to automatically reset guild when no players are online | 72.000000 | Float | -| GUILD_PLAYER_MAX_NUM | GuildPlayerMaxNum | Max player of Guild | 20 | Integer | -| PAL_EGG_DEFAULT_HATCHING_TIME | PalEggDefaultHatchingTime | Time(h) to incubate massive egg | 72.000000 | Float | -| WORK_SPEED_RATE | WorkSpeedRate | Work speed multiplier | 1.000000 | Float | -| IS_MULTIPLAY | bIsMultiplay | Enable multiplayer | false | Boolean | -| IS_PVP | bIsPvP | Enable PVP | false | Boolean | -| CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP | bCanPickupOtherGuildDeathPenaltyDrop | Allow players from other guilds to pick up death penalty items | false | Boolean | -| ENABLE_NON_LOGIN_PENALTY | bEnableNonLoginPenalty | Enable non-login penalty | true | Boolean | -| ENABLE_FAST_TRAVEL | bEnableFastTravel | Enable fast travel | true | Boolean | -| IS_START_LOCATION_SELECT_BY_MAP | bIsStartLocationSelectByMap | Enable selecting of start location | true | Boolean | -| EXIST_PLAYER_AFTER_LOGOUT | bExistPlayerAfterLogout | Toggle for deleting players when they log off | false | Boolean | -| ENABLE_DEFENSE_OTHER_GUILD_PLAYER | bEnableDefenseOtherGuildPlayer | Allows defense against other guild players | false | Boolean | -| COOP_PLAYER_MAX_NUM | CoopPlayerMaxNum | Maximum number of players in a guild | 4 | Integer | -| MAX_PLAYERS | ServerPlayerMaxNum | Maximum number of people who can join the server | 32 | Integer | -| SERVER_NAME | ServerName | Server name | jammsen-docker-generated-###RANDOM### | Integer | -| SERVER_DESCRIPTION | ServerDescription | Server description | Palworld-Dedicated-Server running in Docker by jammsen | String | -| ADMIN_PASSWORD | server admin password | AdminPassword | adminPasswordHere | String | -| SERVER_PASSWORD | AdminPassword | Set the server password. | serverPasswordHere | String | -| PUBLIC_PORT | public port | Public port number | 8211 | Integer | -| PUBLIC_IP | public ip or FQDN | Public IP or FQDN | | String | -| RCON_ENABLED | RCONEnabled | Enable RCON - Use ADMIN_PASSWORD to login | false | Boolean | -| RCON_PORT | RCONPort | Port number for RCON | 25575 | Integer | -| REGION | Region | Area | | String | -| USEAUTH | bUseAuth | Use authentication | true | Boolean | -| BAN_LIST_URL | BanListURL | Which ban list to use | https://api.palworldgame.com/api/banlist.txt | String | +| Variable | Game setting | Description | Default value | Allowed value | +| ----------------------------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | ------------- | +| MULTITHREAD_ENABLED | Sets options for "Improved multi-threaded CPU performance" | true | true | Boolean | +| COMMUNITY_SERVER | Set to enabled, the server will appear in the Community-Serverlist | true | true | Boolean | +| NETSERVERMAXTICKRATE | NetServerMaxTickRate | Changes the TickRate of the server, be very careful with this setting! | 120 | 30-120 | +| DIFFICULTY | Difficulty | Choose one of the following:
`None`
`Normal`
`Difficult` | None | Enum | +| DAYTIME_SPEEDRATE | DayTimeSpeedRate | Day time speed - Smaller number means shorter days | 1.000000 | Float | +| NIGHTTIME_SPEEDRATE | NightTimeSpeedRate | Night time speed - Smaller number means shorter nights | 1.000000 | Float | +| EXP_RATE | ExpRate | EXP rate | 1.000000 | Float | +| PAL_CAPTURE_RATE | PalCaptureRate | Pal capture rate | 1.000000 | Float | +| PAL_SPAWN_NUM_RATE | PalSpawnNumRate | Pal appearance rate | 1.000000 | Float | +| PAL_DAMAGE_RATE_ATTACK | PalDamageRateAttack | Damage from pals multiplier | 1.000000 | Float | +| PAL_DAMAGE_RATE_DEFENSE | PalDamageRateDefense | Damage to pals multiplier | 1.000000 | Float | +| PLAYER_DAMAGE_RATE_ATTACK | PlayerDamageRateAttack | Damage from player multiplier | 1.000000 | Float | +| PLAYER_DAMAGE_RATE_DEFENSE | PlayerDamageRateDefense | Damage to player multiplier | 1.000000 | Float | +| PLAYER_STOMACH_DECREASE_RATE | PlayerStomachDecreaceRate | Player hunger depletion rate | 1.000000 | Float | +| PLAYER_STAMINA_DECREACE_RATE | PlayerStaminaDecreaceRate | Player stamina reduction rate | 1.000000 | Float | +| PLAYER_AUTO_HP_REGENE_RATE | PlayerAutoHPRegeneRate | Player auto HP regeneration rate | 1.000000 | Float | +| PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP | PlayerAutoHpRegeneRateInSleep | Player sleep HP regeneration rate | 1.000000 | Float | +| PAL_STOMACH_DECREACE_RATE | PalStomachDecreaceRate | Pal hunger depletion rate | 1.000000 | Float | +| PAL_STAMINA_DECREACE_RATE | PalStaminaDecreaceRate | Pal stamina reduction rate | 1.000000 | Float | +| PAL_AUTO_HP_REGENE_RATE | PalAutoHPRegeneRate | Pal auto HP regeneration rate | 1.000000 | Float | +| PAL_AUTO_HP_REGENE_RATE_IN_SLEEP | PalAutoHpRegeneRateInSleep | Pal sleep health regeneration rate (in Palbox) | 1.000000 | Float | +| BUILD_OBJECT_DAMAGE_RATE | BuildObjectDamageRate | Damage to structure multiplier | 1.000000 | Float | +| BUILD_OBJECT_DETERIORATION_DAMAGE_RATE | BuildObjectDeteriorationDamageRate | Structure deterioration rate | 1.000000 | Float | +| COLLECTION_DROP_RATE | CollectionDropRate | Gatherable items multiplier | 1.000000 | Float | +| COLLECTION_OBJECT_HP_RATE | CollectionObjectHpRate | Gatherable objects HP multiplier | 1.000000 | Float | +| COLLECTION_OBJECT_RESPAWN_SPEED_RATE | CollectionObjectRespawnSpeedRate | Gatherable objects respawn interval | 1.000000 | Float | +| ENEMY_DROP_ITEM_RATE | EnemyDropItemRate | Dropped Items Multiplier | 1.000000 | Float | +| DEATH_PENALTY | DeathPenalty | `None` : No lost
`Item` : Lost item without equipment
`ItemAndEquipment` : Lost item and equipment
`All`: Lost All item, equipment, pal(in inventory) | All | Enum | +| ENABLE_PLAYER_TO_PLAYER_DAMAGE | bEnablePlayerToPlayerDamage | Allows players to cause damage to players | false | Boolean | +| ENABLE_FRIENDLY_FIRE | bEnableFriendlyFire | Allow friendly fire | false | Boolean | +| ENABLE_INVADER_ENEMY | bEnableInvaderEnemy | Enable invaders | true | Boolean | +| ACTIVE_UNKO | bActiveUNKO | Enable UNKO | false | Boolean | +| ENABLE_AIM_ASSIST_PAD | bEnableAimAssistPad | Enable controller aim assist | true | Boolean | +| ENABLE_AIM_ASSIST_KEYBOARD | bEnableAimAssistKeyboard | Enable Keyboard aim assist | false | Boolean | +| DROP_ITEM_MAX_NUM | DropItemMaxNum | Maximum number of drops in the world | 3000 | Integer | +| DROP_ITEM_MAX_NUM_UNKO | DropItemMaxNum | Maximum number of UNKO drops in the world | 100 | Integer | +| BASE_CAMP_MAX_NUM | BaseCampMaxNum | Maximum number of base camps | 128 | Integer | +| BASE_CAMP_WORKER_MAXNUM | BaseCampWorkerMaxNum | Maximum number of workers | 15 | Integer | +| DROP_ITEM_ALIVE_MAX_HOURS | DropItemAliveMaxHours | Time it takes for items to despawn in hours | 1.000000 | Float | +| AUTO_RESET_GUILD_NO_ONLINE_PLAYERS | bAutoResetGuildNoOnlinePlayers | Automatically reset guild when no players are online | false | Bool | +| AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS | AutoResetGuildTimeNoOnlinePlayers | Time to automatically reset guild when no players are online | 72.000000 | Float | +| GUILD_PLAYER_MAX_NUM | GuildPlayerMaxNum | Max player of Guild | 20 | Integer | +| PAL_EGG_DEFAULT_HATCHING_TIME | PalEggDefaultHatchingTime | Time(h) to incubate massive egg | 72.000000 | Float | +| WORK_SPEED_RATE | WorkSpeedRate | Work speed multiplier | 1.000000 | Float | +| IS_MULTIPLAY | bIsMultiplay | Enable multiplayer | false | Boolean | +| IS_PVP | bIsPvP | Enable PVP | false | Boolean | +| CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP | bCanPickupOtherGuildDeathPenaltyDrop | Allow players from other guilds to pick up death penalty items | false | Boolean | +| ENABLE_NON_LOGIN_PENALTY | bEnableNonLoginPenalty | Enable non-login penalty | true | Boolean | +| ENABLE_FAST_TRAVEL | bEnableFastTravel | Enable fast travel | true | Boolean | +| IS_START_LOCATION_SELECT_BY_MAP | bIsStartLocationSelectByMap | Enable selecting of start location | true | Boolean | +| EXIST_PLAYER_AFTER_LOGOUT | bExistPlayerAfterLogout | Toggle for deleting players when they log off | false | Boolean | +| ENABLE_DEFENSE_OTHER_GUILD_PLAYER | bEnableDefenseOtherGuildPlayer | Allows defense against other guild players | false | Boolean | +| COOP_PLAYER_MAX_NUM | CoopPlayerMaxNum | Maximum number of players in a guild | 4 | Integer | +| MAX_PLAYERS | ServerPlayerMaxNum | Maximum number of people who can join the server | 32 | Integer | +| SERVER_NAME | ServerName | Server name | jammsen-docker-generated-###RANDOM### | Integer | +| SERVER_DESCRIPTION | ServerDescription | Server description | Palworld-Dedicated-Server running in Docker by jammsen | String | +| ADMIN_PASSWORD | server admin password | AdminPassword | adminPasswordHere | String | +| SERVER_PASSWORD | AdminPassword | Set the server password. | serverPasswordHere | String | +| PUBLIC_PORT | public port | Public port number | 8211 | Integer | +| PUBLIC_IP | public ip or FQDN | Public IP or FQDN | | String | +| RCON_ENABLED | RCONEnabled | Enable RCON - Use ADMIN_PASSWORD to login | false | Boolean | +| RCON_PORT | RCONPort | Port number for RCON | 25575 | Integer | +| REGION | Region | Area | | String | +| USEAUTH | bUseAuth | Use authentication | true | Boolean | +| BAN_LIST_URL | BanListURL | Which ban list to use | https://api.palworldgame.com/api/banlist.txt | String | ## Webhook-Settings diff --git a/entrypoint.sh b/entrypoint.sh index 272816d..774160f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,19 +3,36 @@ set -e -source /includes/colors.sh +APP_USER=steam +APP_GROUP=steam +APP_HOME=/home/$APP_USER +source /includes/colors.sh if [[ "${PUID}" -eq 0 ]] || [[ "${PGID}" -eq 0 ]]; then - ew ">>> Running as root is not supported, please fix your PUID and PGID!" + ee ">>> Running as root is not supported, please fix your PUID and PGID!" exit 1 elif [[ "$(id -u steam)" -ne "${PUID}" ]] || [[ "$(id -g steam)" -ne "${PGID}" ]]; then - ei "> Current steam user UID is '$(id -u steam)' and GID is '$(id -g steam)'" - ei "> Setting new steam user UID to '${PUID}' and GID to '${PGID}'" - groupmod -g "${PGID}" steam && usermod -u "${PUID}" -g "${PGID}" steam + ew "> Current $APP_USER user PUID is '$(id -u steam)' and PGID is '$(id -g steam)'" + ew "> Setting new $APP_USER user PUID to '${PUID}' and PGID to '${PGID}'" + groupmod -g "${PGID}" "$APP_GROUP" && usermod -u "${PUID}" -g "${PGID}" "$APP_USER" +else + ew "> Current $APP_USER user PUID is '$(id -u steam)' and PGID is '$(id -g steam)'" + ew "> PUID and PGID matching what is requested for user $APP_USER" fi -mkdir -p /palworld/backups -chown -R steam:steam /palworld /home/steam/ +chown -R "$APP_USER":"$APP_GROUP" "$APP_HOME" +chown -R "$APP_USER":"$APP_GROUP" "$GAME_ROOT" +chown "$APP_USER":"$APP_GROUP" /entrypoint.sh +chown -R "$APP_USER":"$APP_GROUP" /scripts +chown -R "$APP_USER":"$APP_GROUP" /includes + +ls -al / +ls -al /home +ls -al /home/steam +ls -al /home/steam/steamcmd +ls -al /palworld +ls -al /palworld/backups +id steam -su steam -c "$@" +exec gosu $APP_USER:$APP_GROUP "$@" diff --git a/includes/config.sh b/includes/config.sh index 4861b7b..491a21d 100644 --- a/includes/config.sh +++ b/includes/config.sh @@ -6,7 +6,7 @@ function setup_engine_ini() { pattern1="OnlineSubsystemUtils.IpNetDriver" pattern2="^NetServerMaxTickRate=[0-9]*" ei ">>> Setting up Engine.ini ..." - ei "> Checking if config already exists..." + e "> Checking if config already exists..." if [ ! -f "${GAME_ENGINE_FILE}" ]; then ew "> No config found, generating one!" if [ ! -d "${GAME_CONFIG_PATH}" ]; then @@ -15,16 +15,16 @@ function setup_engine_ini() { # Create empty Engine.ini file echo "" > "${GAME_ENGINE_FILE}" else - ei "> Found existing config!" + e "> Found existing config!" fi if grep -qE "${pattern1}" "${GAME_ENGINE_FILE}" 2>/dev/null; then - ei "> Found [/Script/OnlineSubsystemUtils.IpNetDriver] section" + e "> Found [/Script/OnlineSubsystemUtils.IpNetDriver] section" else ew "> Found no [/Script/OnlineSubsystemUtils.IpNetDriver], adding it" echo -e "[/Script/OnlineSubsystemUtils.IpNetDriver]" >> "${GAME_ENGINE_FILE}" fi if grep -qE "${pattern2}" "${GAME_ENGINE_FILE}" 2>/dev/null; then - ei "> Found NetServerMaxTickRate parameter, changing it to '${NETSERVERMAXTICKRATE}'" + e "> Found NetServerMaxTickRate parameter, changing it to '${NETSERVERMAXTICKRATE}'" sed -E -i "s/${pattern2}/NetServerMaxTickRate=${NETSERVERMAXTICKRATE}/" "${GAME_ENGINE_FILE}" else ew "> Found no NetServerMaxTickRate parameter, adding it with value '${NETSERVERMAXTICKRATE}'" @@ -35,7 +35,7 @@ function setup_engine_ini() { function setup_palworld_settings_ini() { ei ">>> Setting up PalWorldSettings.ini ..." - ei "> Checking if config already exists..." + e "> Checking if config already exists..." if [ ! -f "${GAME_SETTINGS_FILE}" ]; then ew "> No config found, generating one" if [ ! -d "${GAME_CONFIG_PATH}" ]; then @@ -44,261 +44,261 @@ function setup_palworld_settings_ini() { # Copy default-config, which comes with SteamCMD to gameserver save location cp "${GAME_ROOT}/DefaultPalWorldSettings.ini" "${GAME_SETTINGS_FILE}" else - ei "> Found existing config!" + e "> Found existing config!" fi if [[ -n ${DIFFICULTY+x} ]]; then - echo "> Setting Difficulty to '$DIFFICULTY'" + e "> Setting Difficulty to '$DIFFICULTY'" sed -E -i "s/Difficulty=[a-zA-Z]*/Difficulty=$DIFFICULTY/" "$GAME_SETTINGS_FILE" fi if [[ -n ${DAYTIME_SPEEDRATE+x} ]]; then - echo "> Setting DayTimeSpeedRate to '$DAYTIME_SPEEDRATE'" + e "> Setting DayTimeSpeedRate to '$DAYTIME_SPEEDRATE'" sed -E -i "s/DayTimeSpeedRate=[+-]?([0-9]*[.])?[0-9]+/DayTimeSpeedRate=$DAYTIME_SPEEDRATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${NIGHTTIME_SPEEDRATE+x} ]]; then - echo "> Setting NightTimeSpeedRate to '$NIGHTTIME_SPEEDRATE'" + e "> Setting NightTimeSpeedRate to '$NIGHTTIME_SPEEDRATE'" sed -E -i "s/NightTimeSpeedRate=[+-]?([0-9]*[.])?[0-9]+/NightTimeSpeedRate=$NIGHTTIME_SPEEDRATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${EXP_RATE+x} ]]; then - echo "> Setting ExpRate to '$EXP_RATE'" + e "> Setting ExpRate to '$EXP_RATE'" sed -E -i "s/ExpRate=[+-]?([0-9]*[.])?[0-9]+/ExpRate=$EXP_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_CAPTURE_RATE+x} ]]; then - echo "> Setting PalCaptureRate to '$PAL_CAPTURE_RATE'" + e "> Setting PalCaptureRate to '$PAL_CAPTURE_RATE'" sed -E -i "s/PalCaptureRate=[+-]?([0-9]*[.])?[0-9]+/PalCaptureRate=$PAL_CAPTURE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_SPAWN_NUM_RATE+x} ]]; then - echo "> Setting PalSpawnNumRate to '$PAL_SPAWN_NUM_RATE'" + e "> Setting PalSpawnNumRate to '$PAL_SPAWN_NUM_RATE'" sed -E -i "s/PalSpawnNumRate=[+-]?([0-9]*[.])?[0-9]+/PalSpawnNumRate=$PAL_SPAWN_NUM_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_DAMAGE_RATE_ATTACK+x} ]]; then - echo "> Setting PalDamageRateAttack to '$PAL_DAMAGE_RATE_ATTACK'" + e "> Setting PalDamageRateAttack to '$PAL_DAMAGE_RATE_ATTACK'" sed -E -i "s/PalDamageRateAttack=[+-]?([0-9]*[.])?[0-9]+/PalDamageRateAttack=$PAL_DAMAGE_RATE_ATTACK/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_DAMAGE_RATE_DEFENSE+x} ]]; then - echo "> Setting PalDamageRateDefense to '$PAL_DAMAGE_RATE_DEFENSE'" + e "> Setting PalDamageRateDefense to '$PAL_DAMAGE_RATE_DEFENSE'" sed -E -i "s/PalDamageRateDefense=[+-]?([0-9]*[.])?[0-9]+/PalDamageRateDefense=$PAL_DAMAGE_RATE_DEFENSE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PLAYER_DAMAGE_RATE_ATTACK+x} ]]; then - echo "> Setting PlayerDamageRateAttack to '$PLAYER_DAMAGE_RATE_ATTACK'" + e "> Setting PlayerDamageRateAttack to '$PLAYER_DAMAGE_RATE_ATTACK'" sed -E -i "s/PlayerDamageRateAttack=[+-]?([0-9]*[.])?[0-9]+/PlayerDamageRateAttack=$PLAYER_DAMAGE_RATE_ATTACK/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PLAYER_DAMAGE_RATE_DEFENSE+x} ]]; then - echo "> Setting PlayerDamageRateDefense to '$PLAYER_DAMAGE_RATE_DEFENSE'" + e "> Setting PlayerDamageRateDefense to '$PLAYER_DAMAGE_RATE_DEFENSE'" sed -E -i "s/PlayerDamageRateDefense=[+-]?([0-9]*[.])?[0-9]+/PlayerDamageRateDefense=$PLAYER_DAMAGE_RATE_DEFENSE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PLAYER_STOMACH_DECREASE_RATE+x} ]]; then - echo "> Setting PlayerStomachDecreaceRate to '$PLAYER_STOMACH_DECREASE_RATE'" + e "> Setting PlayerStomachDecreaceRate to '$PLAYER_STOMACH_DECREASE_RATE'" sed -E -i "s/PlayerStomachDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PlayerStomachDecreaceRate=$PLAYER_STOMACH_DECREASE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PLAYER_STAMINA_DECREACE_RATE+x} ]]; then - echo "> Setting PlayerStaminaDecreaceRate to '$PLAYER_STAMINA_DECREACE_RATE'" + e "> Setting PlayerStaminaDecreaceRate to '$PLAYER_STAMINA_DECREACE_RATE'" sed -E -i "s/PlayerStaminaDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PlayerStaminaDecreaceRate=$PLAYER_STAMINA_DECREACE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PLAYER_AUTO_HP_REGENE_RATE+x} ]]; then - echo "> Setting PlayerAutoHPRegeneRate to '$PLAYER_AUTO_HP_REGENE_RATE'" + e "> Setting PlayerAutoHPRegeneRate to '$PLAYER_AUTO_HP_REGENE_RATE'" sed -E -i "s/PlayerAutoHPRegeneRate=[+-]?([0-9]*[.])?[0-9]+/PlayerAutoHPRegeneRate=$PLAYER_AUTO_HP_REGENE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP+x} ]]; then - echo "> Setting PlayerAutoHpRegeneRateInSleep to '$PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP'" + e "> Setting PlayerAutoHpRegeneRateInSleep to '$PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP'" sed -E -i "s/PlayerAutoHpRegeneRateInSleep=[+-]?([0-9]*[.])?[0-9]+/PlayerAutoHpRegeneRateInSleep=$PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_STOMACH_DECREACE_RATE+x} ]]; then - echo "> Setting PalStomachDecreaceRate to '$PAL_STOMACH_DECREACE_RATE'" + e "> Setting PalStomachDecreaceRate to '$PAL_STOMACH_DECREACE_RATE'" sed -E -i "s/PalStomachDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PalStomachDecreaceRate=$PAL_STOMACH_DECREACE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_STAMINA_DECREACE_RATE+x} ]]; then - echo "> Setting PalStaminaDecreaceRate to '$PAL_STAMINA_DECREACE_RATE'" + e "> Setting PalStaminaDecreaceRate to '$PAL_STAMINA_DECREACE_RATE'" sed -E -i "s/PalStaminaDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PalStaminaDecreaceRate=$PAL_STAMINA_DECREACE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_AUTO_HP_REGENE_RATE+x} ]]; then - echo "> Setting PalAutoHPRegeneRate to '$PAL_AUTO_HP_REGENE_RATE'" + e "> Setting PalAutoHPRegeneRate to '$PAL_AUTO_HP_REGENE_RATE'" sed -E -i "s/PalAutoHPRegeneRate=[+-]?([0-9]*[.])?[0-9]+/PalAutoHPRegeneRate=$PAL_AUTO_HP_REGENE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_AUTO_HP_REGENE_RATE_IN_SLEEP+x} ]]; then - echo "> Setting PalAutoHpRegeneRateInSleep to '$PAL_AUTO_HP_REGENE_RATE_IN_SLEEP'" + e "> Setting PalAutoHpRegeneRateInSleep to '$PAL_AUTO_HP_REGENE_RATE_IN_SLEEP'" sed -E -i "s/PalAutoHpRegeneRateInSleep=[+-]?([0-9]*[.])?[0-9]+/PalAutoHpRegeneRateInSleep=$PAL_AUTO_HP_REGENE_RATE_IN_SLEEP/" "$GAME_SETTINGS_FILE" fi if [[ -n ${BUILD_OBJECT_DAMAGE_RATE+x} ]]; then - echo "> Setting BuildObjectDamageRate to '$BUILD_OBJECT_DAMAGE_RATE'" + e "> Setting BuildObjectDamageRate to '$BUILD_OBJECT_DAMAGE_RATE'" sed -E -i "s/BuildObjectDamageRate=[+-]?([0-9]*[.])?[0-9]+/BuildObjectDamageRate=$BUILD_OBJECT_DAMAGE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${BUILD_OBJECT_DETERIORATION_DAMAGE_RATE+x} ]]; then - echo "> Setting BuildObjectDeteriorationDamageRate to '$BUILD_OBJECT_DETERIORATION_DAMAGE_RATE'" + e "> Setting BuildObjectDeteriorationDamageRate to '$BUILD_OBJECT_DETERIORATION_DAMAGE_RATE'" sed -E -i "s/BuildObjectDeteriorationDamageRate=[+-]?([0-9]*[.])?[0-9]+/BuildObjectDeteriorationDamageRate=$BUILD_OBJECT_DETERIORATION_DAMAGE_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${COLLECTION_DROP_RATE+x} ]]; then - echo "> Setting CollectionDropRate to '$COLLECTION_DROP_RATE'" + e "> Setting CollectionDropRate to '$COLLECTION_DROP_RATE'" sed -E -i "s/CollectionDropRate=[+-]?([0-9]*[.])?[0-9]+/CollectionDropRate=$COLLECTION_DROP_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${COLLECTION_OBJECT_HP_RATE+x} ]]; then - echo "> Setting CollectionObjectHpRate to '$COLLECTION_OBJECT_HP_RATE'" + e "> Setting CollectionObjectHpRate to '$COLLECTION_OBJECT_HP_RATE'" sed -E -i "s/CollectionObjectHpRate=[+-]?([0-9]*[.])?[0-9]+/CollectionObjectHpRate=$COLLECTION_OBJECT_HP_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${COLLECTION_OBJECT_RESPAWN_SPEED_RATE+x} ]]; then - echo "> Setting CollectionObjectRespawnSpeedRate to '$COLLECTION_OBJECT_RESPAWN_SPEED_RATE'" + e "> Setting CollectionObjectRespawnSpeedRate to '$COLLECTION_OBJECT_RESPAWN_SPEED_RATE'" sed -E -i "s/CollectionObjectRespawnSpeedRate=[+-]?([0-9]*[.])?[0-9]+/CollectionObjectRespawnSpeedRate=$COLLECTION_OBJECT_RESPAWN_SPEED_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENEMY_DROP_ITEM_RATE+x} ]]; then - echo "> Setting EnemyDropItemRate to '$ENEMY_DROP_ITEM_RATE'" + e "> Setting EnemyDropItemRate to '$ENEMY_DROP_ITEM_RATE'" sed -E -i "s/EnemyDropItemRate=[+-]?([0-9]*[.])?[0-9]+/EnemyDropItemRate=$ENEMY_DROP_ITEM_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${DEATH_PENALTY+x} ]]; then - echo "> Setting DeathPenalty to '$DEATH_PENALTY'" + e "> Setting DeathPenalty to '$DEATH_PENALTY'" sed -E -i "s/DeathPenalty=[a-zA-Z]*/DeathPenalty=$DEATH_PENALTY/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_PLAYER_TO_PLAYER_DAMAGE+x} ]]; then - echo "> Setting bEnablePlayerToPlayerDamage to '$ENABLE_PLAYER_TO_PLAYER_DAMAGE'" + e "> Setting bEnablePlayerToPlayerDamage to '$ENABLE_PLAYER_TO_PLAYER_DAMAGE'" sed -E -i "s/bEnablePlayerToPlayerDamage=[a-zA-Z]*/bEnablePlayerToPlayerDamage=$ENABLE_PLAYER_TO_PLAYER_DAMAGE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_FRIENDLY_FIRE+x} ]]; then - echo "> Setting bEnableFriendlyFire to '$ENABLE_FRIENDLY_FIRE'" + e "> Setting bEnableFriendlyFire to '$ENABLE_FRIENDLY_FIRE'" sed -E -i "s/bEnableFriendlyFire=[a-zA-Z]*/bEnableFriendlyFire=$ENABLE_FRIENDLY_FIRE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_INVADER_ENEMY+x} ]]; then - echo "> Setting bEnableInvaderEnemy to '$ENABLE_INVADER_ENEMY'" + e "> Setting bEnableInvaderEnemy to '$ENABLE_INVADER_ENEMY'" sed -E -i "s/bEnableInvaderEnemy=[a-zA-Z]*/bEnableInvaderEnemy=$ENABLE_INVADER_ENEMY/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ACTIVE_UNKO+x} ]]; then - echo "> Setting bActiveUNKO to '$ACTIVE_UNKO'" + e "> Setting bActiveUNKO to '$ACTIVE_UNKO'" sed -E -i "s/bActiveUNKO=[a-zA-Z]*/bActiveUNKO=$ACTIVE_UNKO/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_AIM_ASSIST_PAD+x} ]]; then - echo "> Setting bEnableAimAssistPad to '$ENABLE_AIM_ASSIST_PAD'" + e "> Setting bEnableAimAssistPad to '$ENABLE_AIM_ASSIST_PAD'" sed -E -i "s/bEnableAimAssistPad=[a-zA-Z]*/bEnableAimAssistPad=$ENABLE_AIM_ASSIST_PAD/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_AIM_ASSIST_KEYBOARD+x} ]]; then - echo "> Setting bEnableAimAssistKeyboard to '$ENABLE_AIM_ASSIST_KEYBOARD'" + e "> Setting bEnableAimAssistKeyboard to '$ENABLE_AIM_ASSIST_KEYBOARD'" sed -E -i "s/bEnableAimAssistKeyboard=[a-zA-Z]*/bEnableAimAssistKeyboard=$ENABLE_AIM_ASSIST_KEYBOARD/" "$GAME_SETTINGS_FILE" fi if [[ -n ${DROP_ITEM_MAX_NUM+x} ]]; then - echo "> Setting DropItemMaxNum to '$DROP_ITEM_MAX_NUM'" + e "> Setting DropItemMaxNum to '$DROP_ITEM_MAX_NUM'" sed -E -i "s/DropItemMaxNum=[0-9]*/DropItemMaxNum=$DROP_ITEM_MAX_NUM/" "$GAME_SETTINGS_FILE" fi if [[ -n ${DROP_ITEM_MAX_NUM_UNKO+x} ]]; then - echo "> Setting DropItemMaxNum_UNKO to '$DROP_ITEM_MAX_NUM_UNKO'" + e "> Setting DropItemMaxNum_UNKO to '$DROP_ITEM_MAX_NUM_UNKO'" sed -E -i "s/DropItemMaxNum_UNKO=[0-9]*/DropItemMaxNum_UNKO=$DROP_ITEM_MAX_NUM_UNKO/" "$GAME_SETTINGS_FILE" fi if [[ -n ${BASE_CAMP_MAX_NUM+x} ]]; then - echo "> Setting BaseCampMaxNum to '$BASE_CAMP_MAX_NUM'" + e "> Setting BaseCampMaxNum to '$BASE_CAMP_MAX_NUM'" sed -E -i "s/BaseCampMaxNum=[0-9]*/BaseCampMaxNum=$BASE_CAMP_MAX_NUM/" "$GAME_SETTINGS_FILE" fi if [[ -n ${BASE_CAMP_WORKER_MAXNUM+x} ]]; then - echo "> Setting BaseCampWorkerMaxNum to '$BASE_CAMP_WORKER_MAXNUM'" + e "> Setting BaseCampWorkerMaxNum to '$BASE_CAMP_WORKER_MAXNUM'" sed -E -i "s/BaseCampWorkerMaxNum=[0-9]*/BaseCampWorkerMaxNum=$BASE_CAMP_WORKER_MAXNUM/" "$GAME_SETTINGS_FILE" fi if [[ -n ${DROP_ITEM_ALIVE_MAX_HOURS+x} ]]; then - echo "> Setting DropItemAliveMaxHours to '$DROP_ITEM_ALIVE_MAX_HOURS'" + e "> Setting DropItemAliveMaxHours to '$DROP_ITEM_ALIVE_MAX_HOURS'" sed -E -i "s/DropItemAliveMaxHours=[+-]?([0-9]*[.])?[0-9]+/DropItemAliveMaxHours=$DROP_ITEM_ALIVE_MAX_HOURS/" "$GAME_SETTINGS_FILE" fi if [[ -n ${AUTO_RESET_GUILD_NO_ONLINE_PLAYERS+x} ]]; then - echo "> Setting bAutoResetGuildNoOnlinePlayers to '$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS'" + e "> Setting bAutoResetGuildNoOnlinePlayers to '$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS'" sed -E -i "s/bAutoResetGuildNoOnlinePlayers=[a-zA-Z]*/bAutoResetGuildNoOnlinePlayers=$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS/" "$GAME_SETTINGS_FILE" fi if [[ -n ${AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS+x} ]]; then - echo "> Setting AutoResetGuildTimeNoOnlinePlayers to '$AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS'" + e "> Setting AutoResetGuildTimeNoOnlinePlayers to '$AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS'" sed -E -i "s/AutoResetGuildTimeNoOnlinePlayers=[+-]?([0-9]*[.])?[0-9]+/AutoResetGuildTimeNoOnlinePlayers=$AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS/" "$GAME_SETTINGS_FILE" fi if [[ -n ${GUILD_PLAYER_MAX_NUM+x} ]]; then - echo "> Setting GuildPlayerMaxNum to '$GUILD_PLAYER_MAX_NUM'" + e "> Setting GuildPlayerMaxNum to '$GUILD_PLAYER_MAX_NUM'" sed -E -i "s/GuildPlayerMaxNum=[0-9]*/GuildPlayerMaxNum=$GUILD_PLAYER_MAX_NUM/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PAL_EGG_DEFAULT_HATCHING_TIME+x} ]]; then - echo "> Setting PalEggDefaultHatchingTime to '$PAL_EGG_DEFAULT_HATCHING_TIME'" + e "> Setting PalEggDefaultHatchingTime to '$PAL_EGG_DEFAULT_HATCHING_TIME'" sed -E -i "s/PalEggDefaultHatchingTime=[+-]?([0-9]*[.])?[0-9]+/PalEggDefaultHatchingTime=$PAL_EGG_DEFAULT_HATCHING_TIME/" "$GAME_SETTINGS_FILE" fi if [[ -n ${WORK_SPEED_RATE+x} ]]; then - echo "> Setting WorkSpeedRate to '$WORK_SPEED_RATE'" + e "> Setting WorkSpeedRate to '$WORK_SPEED_RATE'" sed -E -i "s/WorkSpeedRate=[+-]?([0-9]*[.])?[0-9]+/WorkSpeedRate=$WORK_SPEED_RATE/" "$GAME_SETTINGS_FILE" fi if [[ -n ${IS_MULTIPLAY+x} ]]; then - echo "> Setting bIsMultiplay to '$IS_MULTIPLAY'" + e "> Setting bIsMultiplay to '$IS_MULTIPLAY'" sed -E -i "s/bIsMultiplay=[a-zA-Z]*/bIsMultiplay=$IS_MULTIPLAY/" "$GAME_SETTINGS_FILE" fi if [[ -n ${IS_PVP+x} ]]; then - echo "> Setting bIsPvP to $IS_PVP" + e "> Setting bIsPvP to $IS_PVP" sed -E -i "s/bIsPvP=[a-zA-Z]*/bIsPvP=$IS_PVP/" "$GAME_SETTINGS_FILE" fi if [[ -n ${CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP+x} ]]; then - echo "> Setting bCanPickupOtherGuildDeathPenaltyDrop to '$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP'" + e "> Setting bCanPickupOtherGuildDeathPenaltyDrop to '$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP'" sed -E -i "s/bCanPickupOtherGuildDeathPenaltyDrop=[a-zA-Z]*/bCanPickupOtherGuildDeathPenaltyDrop=$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_NON_LOGIN_PENALTY+x} ]]; then - echo "> Setting bEnableNonLoginPenalty to '$ENABLE_NON_LOGIN_PENALTY'" + e "> Setting bEnableNonLoginPenalty to '$ENABLE_NON_LOGIN_PENALTY'" sed -E -i "s/bEnableNonLoginPenalty=[a-zA-Z]*/bEnableNonLoginPenalty=$ENABLE_NON_LOGIN_PENALTY/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_FAST_TRAVEL+x} ]]; then - echo "> Setting bEnableFastTravel to '$ENABLE_FAST_TRAVEL'" + e "> Setting bEnableFastTravel to '$ENABLE_FAST_TRAVEL'" sed -E -i "s/bEnableFastTravel=[a-zA-Z]*/bEnableFastTravel=$ENABLE_FAST_TRAVEL/" "$GAME_SETTINGS_FILE" fi if [[ -n ${IS_START_LOCATION_SELECT_BY_MAP+x} ]]; then - echo "> Setting bIsStartLocationSelectByMap to '$IS_START_LOCATION_SELECT_BY_MAP'" + e "> Setting bIsStartLocationSelectByMap to '$IS_START_LOCATION_SELECT_BY_MAP'" sed -E -i "s/bIsStartLocationSelectByMap=[a-zA-Z]*/bIsStartLocationSelectByMap=$IS_START_LOCATION_SELECT_BY_MAP/" "$GAME_SETTINGS_FILE" fi if [[ -n ${EXIST_PLAYER_AFTER_LOGOUT+x} ]]; then - echo "> Setting bExistPlayerAfterLogout to '$EXIST_PLAYER_AFTER_LOGOUT'" + e "> Setting bExistPlayerAfterLogout to '$EXIST_PLAYER_AFTER_LOGOUT'" sed -E -i "s/bExistPlayerAfterLogout=[a-zA-Z]*/bExistPlayerAfterLogout=$EXIST_PLAYER_AFTER_LOGOUT/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ENABLE_DEFENSE_OTHER_GUILD_PLAYER+x} ]]; then - echo "> Setting bEnableDefenseOtherGuildPlayer to '$ENABLE_DEFENSE_OTHER_GUILD_PLAYER'" + e "> Setting bEnableDefenseOtherGuildPlayer to '$ENABLE_DEFENSE_OTHER_GUILD_PLAYER'" sed -E -i "s/bEnableDefenseOtherGuildPlayer=[a-zA-Z]*/bEnableDefenseOtherGuildPlayer=$ENABLE_DEFENSE_OTHER_GUILD_PLAYER/" "$GAME_SETTINGS_FILE" fi if [[ -n ${COOP_PLAYER_MAX_NUM+x} ]]; then - echo "> Setting CoopPlayerMaxNum to '$COOP_PLAYER_MAX_NUM'" + e "> Setting CoopPlayerMaxNum to '$COOP_PLAYER_MAX_NUM'" sed -E -i "s/CoopPlayerMaxNum=[0-9]*/CoopPlayerMaxNum=$COOP_PLAYER_MAX_NUM/" "$GAME_SETTINGS_FILE" fi if [[ -n ${MAX_PLAYERS+x} ]]; then - echo "> Setting max-players to '$MAX_PLAYERS'" + e "> Setting max-players to '$MAX_PLAYERS'" sed -E -i "s/ServerPlayerMaxNum=[0-9]*/ServerPlayerMaxNum=$MAX_PLAYERS/" "$GAME_SETTINGS_FILE" fi if [[ -n ${SERVER_NAME+x} ]]; then - echo "> Setting server name to '$SERVER_NAME'" + e "> Setting server name to '$SERVER_NAME'" sed -E -i "s/ServerName=\"[^\"]*\"/ServerName=\"$SERVER_NAME\"/" "$GAME_SETTINGS_FILE" if [[ "$SERVER_NAME" == *"###RANDOM###"* ]]; then RAND_VALUE=$RANDOM - echo "> Found standard template, using random numbers in server name" + e "> Found standard template, using random numbers in server name" sed -E -i -e "s/###RANDOM###/$RAND_VALUE/g" "$GAME_SETTINGS_FILE" - echo "> Server name is now 'jammsen-docker-generated-$RAND_VALUE'" + e "> Server name is now 'jammsen-docker-generated-$RAND_VALUE'" fi fi if [[ -n ${SERVER_DESCRIPTION+x} ]]; then - echo "> Setting server description to '$SERVER_DESCRIPTION'" + e "> Setting server description to '$SERVER_DESCRIPTION'" sed -E -i "s/ServerDescription=\"[^\"]*\"/ServerDescription=\"$SERVER_DESCRIPTION\"/" "$GAME_SETTINGS_FILE" fi if [[ -n ${ADMIN_PASSWORD+x} ]]; then - echo "> Setting server admin password to '$ADMIN_PASSWORD'" + e "> Setting server admin password to '$ADMIN_PASSWORD'" sed -E -i "s/AdminPassword=\"[^\"]*\"/AdminPassword=\"$ADMIN_PASSWORD\"/" "$GAME_SETTINGS_FILE" fi if [[ -n ${SERVER_PASSWORD+x} ]]; then - echo "> Setting server password to '$SERVER_PASSWORD'" + e "> Setting server password to '$SERVER_PASSWORD'" sed -E -i "s/ServerPassword=\"[^\"]*\"/ServerPassword=\"$SERVER_PASSWORD\"/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PUBLIC_PORT+x} ]]; then - echo "> Setting public port to '$PUBLIC_PORT'" + e "> Setting public port to '$PUBLIC_PORT'" sed -E -i "s/PublicPort=[0-9]*/PublicPort=$PUBLIC_PORT/" "$GAME_SETTINGS_FILE" fi if [[ -n ${PUBLIC_IP+x} ]]; then - echo "> Setting public ip to '$PUBLIC_IP'" + e "> Setting public ip to '$PUBLIC_IP'" sed -E -i "s/PublicIP=\"[^\"]*\"/PublicIP=\"$PUBLIC_IP\"/" "$GAME_SETTINGS_FILE" fi if [[ -n ${RCON_ENABLED+x} ]]; then - echo "> Setting rcon-enabled to '$RCON_ENABLED'" + e "> Setting rcon-enabled to '$RCON_ENABLED'" sed -E -i "s/RCONEnabled=[a-zA-Z]*/RCONEnabled=$RCON_ENABLED/" "$GAME_SETTINGS_FILE" fi if [[ -n ${RCON_PORT+x} ]]; then - echo "> Setting RCONPort to '$RCON_PORT'" + e "> Setting RCONPort to '$RCON_PORT'" sed -E -i "s/RCONPort=[0-9]*/RCONPort=$RCON_PORT/" "$GAME_SETTINGS_FILE" fi if [[ -n ${REGION+x} ]]; then - echo "> Setting Region to '$REGION'" + e "> Setting Region to '$REGION'" sed -E -i "s/Region=\"[^\"]*\"/Region=\"$REGION\"/" "$GAME_SETTINGS_FILE" fi if [[ -n ${USEAUTH+x} ]]; then - echo "> Setting bUseAuth to '$USEAUTH'" + e "> Setting bUseAuth to '$USEAUTH'" sed -E -i "s/bUseAuth=[a-zA-Z]*/bUseAuth=$USEAUTH/" "$GAME_SETTINGS_FILE" fi if [[ -n ${BAN_LIST_URL+x} ]]; then - echo "> Setting BanListURL to '$BAN_LIST_URL'" + e "> Setting BanListURL to '$BAN_LIST_URL'" sed -E -i "s~BanListURL=\"[^\"]*\"~BanListURL=\"$BAN_LIST_URL\"~" "$GAME_SETTINGS_FILE" fi es ">>> Finished setting up PalWorldSettings.ini" @@ -325,7 +325,7 @@ function setup_rcon_yaml () { function setup_configs() { if [[ -n ${SERVER_SETTINGS_MODE} ]] && [[ ${SERVER_SETTINGS_MODE} == "auto" ]]; then - ei ">>> SERVER_SETTINGS_MODE is set to '${SERVER_SETTINGS_MODE}', using environment variables to configure the server!" + ew "> SERVER_SETTINGS_MODE is set to '${SERVER_SETTINGS_MODE}', using environment variables to configure the server" setup_engine_ini setup_palworld_settings_ini setup_rcon_yaml diff --git a/includes/cron.sh b/includes/cron.sh index cbe9349..eab7608 100644 --- a/includes/cron.sh +++ b/includes/cron.sh @@ -7,5 +7,5 @@ function setup_crons() { echo "${BACKUP_CRON_EXPRESSION} backup create" >> cronlist fi /usr/local/bin/supercronic -passthrough-logs cronlist & - ei ">>> Supercronic started" + e "> Supercronic started" } diff --git a/includes/security.sh b/includes/security.sh index 4d63463..7265a74 100644 --- a/includes/security.sh +++ b/includes/security.sh @@ -3,7 +3,7 @@ source /includes/colors.sh function check_for_default_credentials() { - ei "> Checking for existence of default credentials" + e "> Checking for existence of default credentials" if [[ -n $ADMIN_PASSWORD ]] && [[ $ADMIN_PASSWORD == "adminPasswordHere" ]]; then ee ">>> Security thread detected: Please change the default admin password. Aborting server start ..." exit 1 @@ -12,4 +12,5 @@ function check_for_default_credentials() { ee ">>> Security thread detected: Please change the default server password. Aborting server start ..." exit 1 fi + es "> No default passwords found" } diff --git a/includes/webhook.sh b/includes/webhook.sh index 4ef63e9..2ad5088 100644 --- a/includes/webhook.sh +++ b/includes/webhook.sh @@ -1,8 +1,8 @@ # shellcheck disable=SC2148 # Function to generate JSON data for the Discord message # Webpage for COLOR-Calculation - https://www.spycolor.com/ -# IMPORTANT: Don't use Hex-Colors! Go to the page search for the Hex-Color. -# After that add the DECIMAL-Representation to the color field or it will break! +# IMPORTANT: Don't use Hex-Colors! Go to the page, search for the Hex-Color, +# after that add the DECIMAL-Representation to the color field or it will break for Discord! generate_post_data() { cat < # Example: run_rcon_cli "showplayers" run_rcon_cli() { - local cmd=$1 - local message=$2 + local cmd=$* if [[ -z ${RCON_ENABLED+x} ]] || [[ "$RCON_ENABLED" != "true" ]]; then - ee ">>> RCON is not enabled. Aborting RCON command ..." + ew ">>> RCON is not enabled. Aborting RCON command ..." exit fi - ei "> Sending: ${cmd} ${message}" output=$(rcon -c "$RCON_CONFIG_FILE" "${cmd}") - ei "> RCON-Ouput:" - ei "${output}" + ei_nn "> RCON: "; e "${output}" } run_rcon_cli "$@" diff --git a/scripts/servermanager.sh b/scripts/servermanager.sh index 6972d75..bca3d59 100755 --- a/scripts/servermanager.sh +++ b/scripts/servermanager.sh @@ -16,13 +16,14 @@ source /includes/colors.sh function start_server() { cd "$GAME_ROOT" || exit setup_configs + ei ">>> Preparing to start the gameserver" START_OPTIONS=() if [[ -n $COMMUNITY_SERVER ]] && [[ $COMMUNITY_SERVER == "true" ]]; then - ei "> Setting Community-Mode to enabled" + e "> Setting Community-Mode to enabled" START_OPTIONS+=("EpicApp=PalServer") fi if [[ -n $MULTITHREAD_ENABLED ]] && [[ $MULTITHREAD_ENABLED == "true" ]]; then - ei "> Setting Multi-Core-Enhancements to enabled" + e "> Setting Multi-Core-Enhancements to enabled" START_OPTIONS+=("-useperfthreads" "-NoAsyncLoadingThread" "-UseMultithreadForDS") fi if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then @@ -70,11 +71,14 @@ trap 'kill ${!}; term_handler' SIGTERM # Main process loop while true do + current_date=$(date +%Y-%m-%d) + current_time=$(date +%H:%M:%S) ei ">>> Starting server manager" + e "> Started at: $current_date $current_time" start_main & killpid="$!" - ei "> Server main thread started with pid ${killpid}" + e "> Server main thread started with pid ${killpid}" wait ${killpid} if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then