Skip to content

Commit

Permalink
save-work.remote-pc
Browse files Browse the repository at this point in the history
  • Loading branch information
João Carlos Fraqueiro da Palma committed Apr 7, 2024
1 parent 11c703d commit 41c71fe
Show file tree
Hide file tree
Showing 21 changed files with 183 additions and 403 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ palworld/
test/
docker-compose-*.yml
custom.env
test.env
test.env
scripts/api/*
30 changes: 18 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Description: Dockerfile for Palworld Dedicated Server

# Build the rcon binaries (GORCON and custom rcon broadcast built by @thejcpalma)
FROM golang:1.22.0-bookworm as rcon-build
# Build the rcon binary (GORCON) and the steam id 64 to palworld uid binary (by @thejcpalma)
FROM golang:1.22.2-bookworm as golang-build

WORKDIR /build

Expand All @@ -19,11 +19,11 @@ RUN curl -fsSLO "$GORCON_RCONCLI_URL" \
&& rm -Rf "$GORCON_RCONCLI_DIR" \
&& go build -v ./cmd/gorcon

WORKDIR /build/custom_rcon_broadcast/
# Build the steam id 64 to palworld uid binary
WORKDIR /build/steamid64_to_palworlduid_dir/

# Build the custom rcon broadcast binary
COPY /src/custom_rcon_broadcast/ .
RUN go build -v -o /build/rcon_broadcast main.go
COPY /src/steamid64_to_palworlduid/ .
RUN go build -v -o /build/steamid64_to_palworlduid main.go

# Build the supercronic binary
FROM debian:bookworm-slim as supercronic-build
Expand Down Expand Up @@ -68,9 +68,9 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Copy the rcon, custom rcon broadcast (to fix spaces in the message) and supercronic binaries
COPY --from=rcon-build --chmod=755 /build/gorcon /usr/local/bin/rcon
COPY --from=rcon-build --chmod=755 /build/rcon_broadcast /usr/local/bin/rcon_broadcast
COPY --from=supercronic-build --chmod=755 /usr/local/bin/supercronic /usr/local/bin/supercronic
COPY --from=golang-build --chmod=755 /build/gorcon /usr/local/bin/rcon
COPY --from=golang-build --chmod=755 /build/steamid64_to_palworlduid /usr/local/bin/steamid64_to_palworlduid
COPY --from=supercronic-build --chmod=755 /usr/local/bin/supercronic /usr/local/bin/supercronic

ENV APP_ID=2394010
ENV SERVER_DIR=/home/steam/server
Expand Down Expand Up @@ -102,6 +102,8 @@ ENV DEBIAN_FRONTEND=noninteractive \
GAME_CONFIG_PATH="/palworld/Pal/Saved/Config/LinuxServer" \
GAME_SETTINGS_FILE="/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini" \
GAME_ENGINE_FILE="/palworld/Pal/Saved/Config/LinuxServer/Engine.ini" \
GAME_LOG_PATH="/palworld/logs" \
GAME_LOG_FILE="/palworld/logs/Palworld.log" \
BACKUP_PATH="/palworld/backups" \
STEAMCMD_PATH="/home/steam/steamcmd" \
RCON_CONFIG_FILE="/home/steam/server/configs/rcon.yaml" \
Expand All @@ -123,7 +125,6 @@ ENV DEBIAN_FRONTEND=noninteractive \
BACKUP_AUTO_CLEAN_AMOUNT_TO_KEEP=72 \
# Player monitoring settings
PLAYER_MONITOR_ENABLED=true \
PLAYER_MONITOR_INTERVAL=60 \
# Webhook settings
WEBHOOK_ENABLED=false \
WEBHOOK_URL= \
Expand Down Expand Up @@ -246,10 +247,15 @@ ENV DEBIAN_FRONTEND=noninteractive \
REGION= \
USEAUTH=true \
BAN_LIST_URL=https://api.palworldgame.com/api/banlist.txt \
SHOW_PLAYER_LIST=false

REST_API_ENABLED=false \
REST_API_PORT=8212 \
SHOW_PLAYER_LIST=false \
ALLOW_CONNECT_PLATFORM=Steam \
IS_USE_BACKUP_SAVE_DATA=false \
LOG_FORMAT_TYPE=json

EXPOSE 8211/udp
EXPOSE 8212/tcp
EXPOSE 25575/tcp

VOLUME ["${GAME_ROOT}"]
Expand Down
9 changes: 6 additions & 3 deletions default.env
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ BACKUP_AUTO_CLEAN=true
# Keeps 3 days of backups with default value
BACKUP_AUTO_CLEAN_AMOUNT_TO_KEEP=72

# Player monitoring settings (RCON needs to be enabled)
# Player monitoring settings
PLAYER_MONITOR_ENABLED=true
# Interval is in seconds
PLAYER_MONITOR_INTERVAL=10

# Webhook-settings
# Use this guide colors: https://birdie0.github.io/discord-webhooks-guide/structure/embed/color.html
Expand Down Expand Up @@ -178,4 +176,9 @@ RCON_PORT=25575
REGION=
USEAUTH=true
BAN_LIST_URL=https://api.palworldgame.com/api/banlist.txt
REST_API_ENABLED=true
REST_API_PORT=8212
SHOW_PLAYER_LIST=false
ALLOW_CONNECT_PLATFORM=Steam
IS_USE_BACKUP_SAVE_DATA=false
LOG_FORMAT_TYPE=Json
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ services:
published: 8211 # Gamerserver port on your host
protocol: udp
mode: host
- target: 8212 # REST API port inside of the container
published: 8212 # REST API port on your host
protocol: tcp
mode: host
- target: 25575 # RCON port inside of the container
published: 25575 # RCON port on your host
protocol: tcp
Expand Down
19 changes: 12 additions & 7 deletions docs/ENV_VARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ These are the overall settings for the dedicated server.
> [!IMPORTANT]
>
> **RCON** should be enabled for all for them to work as expected.
> Player monitoring will still work without RCON but log format must be set to JSON.
These settings control the special features of the server:

- Auto updates:
- Auto restarts
- Auto backups
- Player monitoring

| Variable | Description | Default value | Allowed value |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------- |
Expand All @@ -71,8 +73,7 @@ These settings control the special features of the server:
| `BACKUP_CRON_EXPRESSION` | The cron expression for the automatic backup function | `0 * * * *` | See [Cron expression](#cron-expression) |
| `BACKUP_AUTO_CLEAN` | Enables automatic cleanup of old backups | `true` | `false`/`true` |
| `BACKUP_AUTO_CLEAN_AMOUNT_TO_KEEP` | The amount of backups to keep | `72` | Integer |
| `PLAYER_MONITOR_ENABLED` | Enables player monitoring for the server | `false` | `false`/`true` |
| `PLAYER_MONITOR_INTERVAL` | The interval in seconds for the player monitoring (lower values means more impact on system resources) | `60` | Integer |
| `PLAYER_MONITOR_ENABLED` | Enables player monitoring for the server | `true` | `false`/`true` |

#### Cron expression

Expand Down Expand Up @@ -178,7 +179,7 @@ Information sources and credits to the following websites:
| Variable | Game setting | Description | Default value | Allowed value |
| ------------------------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | -------------- |
| `DIFFICULTY` | Difficulty | Choose one of the following:<br>`None`<br>`Normal`<br>`Difficult` | `None` | Enum |
| `DAY_TIME_SPEED_RATE` | DayTimeSpeedRate | Day time speed - Smaller number means longer days | `1.000000` | Float |
| `DAY_TIME_SPEED_RATE` | DayTimeSpeedRate | Day time speed - Smaller number means longer days | `1.000000` | Float |
| `NIGHT_TIME_SPEED_RATE` | NightTimeSpeedRate | Night time speed - Bigger 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 |
Expand Down Expand Up @@ -228,19 +229,23 @@ Information sources and credits to the following websites:
| `ENABLE_DEFENSE_OTHER_GUILD_PLAYER` | bEnableDefenseOtherGuildPlayer | Allows defense against other guild players | `false` | `false`/`true` |
| `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 | `thejcpalma-docker-generated-###RANDOM###` | Integer |
| `SERVER_NAME` | ServerName | Server name | `thejcpalma-docker-generated-###RANDOM###` | String |
| `SERVER_DESCRIPTION` | ServerDescription | Server description | `Palworld Dedicated Server running in Docker by thejcpalma` | String |
| `ADMIN_PASSWORD` | AdminPassword | Set the server admin password. | `adminPasswordHere` | String |
| `SERVER_PASSWORD` | ServerPassword | Set the server password. | `serverPasswordHere` | String |
| `PUBLIC_PORT` | PublicPort | Public port number | `8211` | Integer |
| `PUBLIC_PORT` | PublicPort | Public port number | `8211` | `1024`-`65535` |
| `PUBLIC_IP` | PublicIP | Public IP or FQDN | | String |
| `RCON_ENABLED` | RCONEnabled | Enable RCON - Use ADMIN_PASSWORD to login | `false` | `false`/`true` |
| `RCON_PORT` | RCONPort | Port number for RCON | `25575` | Integer |
| `RCON_PORT` | RCONPort | Port number for RCON | `25575` | `1024`-`65535` |
| `REGION` | Region | Area | | String |
| `USEAUTH` | bUseAuth | Use authentication | `true` | `false`/`true` |
| `BAN_LIST_URL` | BanListURL | Which ban list to use | `https://api.palworldgame.com/api/banlist.txt` | String |
| `REST_API_ENABLED` | RESTAPIEnabled | Enable REST API for the palworld server | `false` | `false`/`true` |
| `REST_API_PORT` | RESTAPIPort | REST API port to connect to | `8212` | `1024`-`65535` |
| `SHOW_PLAYER_LIST` | bShowPlayerList | Make the player list public on a community server | `false` | `false`/`true` |

| `ALLOW_CONNECT_PLATFORM` | AllowConnectPlatform | !!Doesn't work this version!! | `Steam` | Unknown values |
| `IS_USE_BACKUP_SAVE_DATA` | bIsUseBackupSaveData | Enable world backup | `true` | `false`/`true` |
| `LOG_FORMAT_TYPE` | LogFormatType | Log format Text or Json | `Text` | `Text`/`Json` |

## Webhook Settings

Expand Down
6 changes: 5 additions & 1 deletion docs/dev/DEV_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ services:
palworld-dedicated-server:
build: .
container_name: palworld-dedicated-server
image: thejcpalma/palworld-dedicated-server:latest
image: palworld-dedicated-server:latest
restart: unless-stopped
stop_grace_period: 30s # Set to however long you are willing to wait for the container to gracefully stop
ports:
- target: 8211 # Gamerserver port inside of the container
published: 8211 # Gamerserver port on your host
protocol: udp
mode: host
- target: 8212 # REST API port inside of the container
published: 8212 # REST API port on your host
protocol: tcp
mode: host
- target: 25575 # RCON port inside of the container
published: 25575 # RCON port on your host
protocol: tcp
Expand Down
4 changes: 3 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ elif [[ "$(id -u steam)" -ne "${PUID}" ]] || [[ "$(id -g steam)" -ne "${PGID}" ]
groupmod -g "${PGID}" steam && usermod -u "${PUID}" -g "${PGID}" steam
fi

mkdir -p /palworld/backups
# Create the necessary directories
mkdir -p ${GAME_LOG_PATH}
mkdir -p ${BACKUP_PATH}
chown -R steam:steam /palworld /home/steam/

# shellcheck disable=SC2317
Expand Down
3 changes: 2 additions & 1 deletion scripts/config/setup_configs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function setup_configs() {
log_warning ">> 'SERVER_SETTINGS_MODE' is set to '${SERVER_SETTINGS_MODE}', environment variables NOT used to configure the server!"

# Copy default-config, which comes with SteamCMD to gameserver save location
cp "${GAME_ROOT}/DefaultPalWorldSettings.ini" "${GAME_SETTINGS_FILE}"
# -n option will not overwrite an already existing file
cp -n "${GAME_ROOT}/DefaultPalWorldSettings.ini" "${GAME_SETTINGS_FILE}"

log_warning ">> File '${GAME_ENGINE_FILE}' has to be manually set by user."
log_warning ">> File '${GAME_SETTINGS_FILE}' has to be manually set by user."
Expand Down
7 changes: 7 additions & 0 deletions scripts/config/setup_palworld_settings_ini.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ function setup_palworld_settings_ini(){
check_and_export "other" "Region" "${REGION}" ""
check_and_export "bool" "bUseAuth" "${USE_AUTH}" "true"
check_and_export "other" "BanListURL" "${BAN_LIST_URL}" ""
check_and_export "bool" "RESTAPIEnabled" "${REST_API_ENABLED}" "false"
check_and_export "int" "RESTAPIPort" "${REST_API_PORT}" "8212"
check_and_export "bool" "bShowPlayerList" "${SHOW_PLAYER_LIST}" "true"
allow_connect_platform_options=("Steam")
check_and_export "list" "AllowConnectPlatform" "${ALLOW_CONNECT_PLATFORM}" "Steam" "${allow_connect_platform_options[@]}"
check_and_export "bool" "bIsUseBackupSaveData" "${IS_USE_BACKUP_SAVE_DATA}" "true"
log_format_type_options=("json" "text")
check_and_export "list" "LogFormatType" "${LOG_FORMAT_TYPE}" "json" "${log_format_type_options[@]}"

envsubst < "${GAME_SETTINGS_FILE}.tmp" > "${GAME_SETTINGS_FILE}" && rm "${GAME_SETTINGS_FILE}.tmp"

Expand Down
7 changes: 6 additions & 1 deletion scripts/config/templates/PalWorldSettings.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ RCONPort=${RCONPort},
Region=${Region},
bUseAuth=${bUseAuth},
BanListURL=${BanListURL},
bShowPlayerList=${bShowPlayerList}
RESTAPIEnabled=${RESTAPIEnabled},
RESTAPIPort=${RESTAPIPort},
bShowPlayerList=${bShowPlayerList},
AllowConnectPlatform=${AllowConnectPlatform},
bIsUseBackupSaveData=${bIsUseBackupSaveData},
LogFormatType=${LogFormatType}
)
Loading

0 comments on commit 41c71fe

Please sign in to comment.