Skip to content

Commit

Permalink
Merge branch 'main' into Fix-docker-run
Browse files Browse the repository at this point in the history
  • Loading branch information
Dashboy1998 committed Feb 9, 2024
2 parents d528f65 + 57d96a4 commit 6e620af
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG RCON_VERSION="0.10.3"
ARG SUPERCRONIC_VERSION="0.2.29"

# build rcon-cli for arm64-linux
FROM arm64v8/golang:1.19.3-bullseye as rcon-cli_builder
FROM arm64v8/golang:1.22.0-bullseye as rcon-cli_builder

ARG RCON_VERSION

Expand Down
8 changes: 7 additions & 1 deletion docs/zh-CN/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
这是一个 [Docker](https://docs.docker.com/engine/install/) 容器,可帮助您创建自己的
[幻兽帕鲁](https://store.steampowered.com/app/1623730/Palworld/) 专用服务器。

此容器经测试可正常在 (Ubuntu/Debian)、 Windows 10 、macOS (包括使用 Silicon 芯片的 M1 设备,通过 Rosseta2 转译)。
此 Docker 容器经过测试,可在以下操作系统上运作:

* Linux (Ubuntu/Debian)
* Windows 10,11
* MacOS (包括 Apple Silicon M1/M2/M3).

此容器也经过测试,可在 `x64``ARM64` 基于的 CPU 架构上运作。

> [!IMPORTANT]
> 目前,Xbox Game Pass/Xbox 主机玩家无法加入专用服务器。
Expand Down
22 changes: 20 additions & 2 deletions scripts/compile-settings.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
#!/bin/bash
# shellcheck source=/dev/null
source "/home/steam/server/helper_functions.sh"

config_file="/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini"
config_dir=$(dirname "$config_file")

mkdir -p "$config_dir" || exit
# If file exists then check if it is writable
if [ -f "$config_file" ]; then
if ! isWritable "$config_file"; then
echo "Unable to create $config_file"
exit 1
fi
# If file does not exist then check if the directory is writable
elif ! isWritable "$config_dir"; then
# Exiting since the file does not exist and the directory is not writable.
echo "Unable to create $config_file"
exit 1
fi

echo "Compiling PalWorldSettings.ini..."

Expand Down Expand Up @@ -134,8 +153,7 @@ BAN_LIST_URL = $BAN_LIST_URL
EOF
fi

mkdir -p /palworld/Pal/Saved/Config/LinuxServer
cat > /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini <<EOF
cat > "$config_file" <<EOF
[/Script/Pal.PalGameWorldSettings]
$(envsubst < ./files/PalWorldSettings.ini.template | tr -d "\n\r")
EOF
Expand Down
67 changes: 67 additions & 0 deletions scripts/helper_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
# This file contains functions which can be used in multiple scripts

# Checks if a given path is a directory
# Returns 0 if the path is a directory
# Returns 1 if the path is not a directory or does not exists and produces an output message
dirExists() {
local path="$1"
local return_val=0
if ! [ -d "${path}" ]; then
echo "${path} does not exist."
return_val=1
fi
return "$return_val"
}

# Checks if a given path is a regular file
# Returns 0 if the path is a regular file
# Returns 1 if the path is not a regular file or does not exists and produces an output message
fileExists() {
local path="$1"
local return_val=0
if ! [ -f "${path}" ]; then
echo "${path} does not exist."
return_val=1
fi
return "$return_val"
}

# Checks if a given path exists and is readable
# Returns 0 if the path exists and is readable
# Returns 1 if the path is not readable or does not exists and produces an output message
isReadable() {
local path="$1"
local return_val=0
if ! [ -e "${path}" ]; then
echo "${path} is not readable."
return_val=1
fi
return "$return_val"
}

# Checks if a given path is writable
# Returns 0 if the path is writable
# Returns 1 if the path is not writable or does not exists and produces an output message
isWritable() {
local path="$1"
local return_val=0
if ! [ -w "${path}" ]; then
echo "${path} is not writable."
return_val=1
fi
return "$return_val"
}

# Checks if a given path is executable
# Returns 0 if the path is executable
# Returns 1 if the path is not executable or does not exists and produces an output message
isExecutable() {
local path="$1"
local return_val=0
if ! [ -x "${path}" ]; then
echo "${path} is not executable."
return_val=1
fi
return "$return_val"
}
68 changes: 15 additions & 53 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,65 +1,29 @@
#!/bin/bash

dirExists() {
local path="$1"
local return_val=0
if ! [ -d "${path}" ]; then
echo "${path} does not exist."
return_val=1
fi
return "$return_val"
}

fileExists() {
local path="$1"
local return_val=0
if ! [ -f "${path}" ]; then
echo "${path} does not exist."
return_val=1
fi
return "$return_val"
}

isReadable() {
local path="$1"
local return_val=0
if ! [ -e "${path}" ]; then
echo "${path} is not readable."
return_val=1
fi
return "$return_val"
}

isWritable() {
local path="$1"
local return_val=0
if ! [ -w "${path}" ]; then
echo "${path} is not writable."
return_val=1
fi
return "$return_val"
}

isExecutable() {
local path="$1"
local return_val=0
if ! [ -x "${path}" ]; then
echo "${path} is not executable."
return_val=1
fi
return "$return_val"
}
# shellcheck source=/dev/null
source "/home/steam/server/helper_functions.sh"

dirExists "/palworld" || exit
isWritable "/palworld" || exit
isExecutable "/palworld" || exit

printf "\e[0;32m*****GENERATING CONFIGS*****\e[0m\n"

./compile-settings.sh
./compile-settings.sh || exit

cd /palworld || exit

# Get the architecture using dpkg
architecture=$(dpkg --print-architecture)

# Get host kernel page size
kernel_page_size=$(getconf PAGESIZE)

# Check kernel page size for arm64 hosts before running steamcmd
if [ "$architecture" == "arm64" ] && [ "$kernel_page_size" != "4096" ]; then
echo "Only ARM64 hosts with 4k page size is supported."
exit 1
fi

if [ "${UPDATE_ON_BOOT,,}" = true ]; then
printf "\e[0;32m%s\e[0m\n" "*****STARTING INSTALL/UPDATE*****"

Expand All @@ -74,8 +38,6 @@ if [ "${UPDATE_ON_BOOT,,}" = true ]; then
fi
fi

# Get the architecture using dpkg
architecture=$(dpkg --print-architecture)
# Check if the architecture is arm64
if [ "$architecture" == "arm64" ]; then
# create an arm64 version of ./PalServer.sh
Expand Down

0 comments on commit 6e620af

Please sign in to comment.