Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize Root Processes #167

Merged
merged 9 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN wget -q https://github.com/gorcon/rcon-cli/releases/download/v0.10.3/rcon-0.10.3-amd64_linux.tar.gz -O - | tar -xz && \
mv rcon-0.10.3-amd64_linux/rcon /usr/bin/rcon-cli
mv rcon-0.10.3-amd64_linux/rcon /usr/bin/rcon-cli && \
rmdir /tmp/dumps

ENV PORT= \
PUID=1000 \
Expand Down
5 changes: 5 additions & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ FILE_PATH="/palworld/backups/palworld-save-${DATE}.tar.gz"
cd /palworld/Pal/ || exit

tar -zcf "$FILE_PATH" "Saved/"

if [ "$(id -u)" -eq 0 ]; then
chown steam:steam "$FILE_PATH"
fi

echo "backup created at $FILE_PATH"
10 changes: 3 additions & 7 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ else
fi

mkdir -p /palworld/backups
chown -R steam:steam /palworld

if [ "${UPDATE_ON_BOOT}" = true ]; then
printf "\e[0;32m*****STARTING INSTALL/UPDATE*****\e[0m\n"
su steam -c '/home/steam/steamcmd/steamcmd.sh +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit'
fi
chown -R steam:steam /palworld /home/steam/

term_handler() {
if [ "${RCON_ENABLED}" = true ]; then
Expand All @@ -29,6 +24,7 @@ term_handler() {

trap 'term_handler' SIGTERM

./start.sh &
su steam -c ./start.sh &
# Process ID of su
killpid="$!"
wait $killpid
11 changes: 8 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if [ "${UPDATE_ON_BOOT}" = true ]; then
printf "\e[0;32m*****STARTING INSTALL/UPDATE*****\e[0m\n"
/home/steam/steamcmd/steamcmd.sh +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit
fi

STARTCOMMAND=("./PalServer.sh")

if [ -n "${PORT}" ]; then
Expand Down Expand Up @@ -56,7 +61,7 @@ if [ ! "$(grep -s '[^[:space:]]' /palworld/Pal/Saved/Config/LinuxServer/PalWorld
printf "\e[0;32m*****GENERATING CONFIG*****\e[0m\n"

# Server will generate all ini files after first run.
su steam -c "timeout --preserve-status 15s ./PalServer.sh 1> /dev/null "
timeout --preserve-status 15s ./PalServer.sh 1> /dev/null

# Wait for shutdown
sleep 5
Expand All @@ -80,6 +85,6 @@ default:
EOL

printf "\e[0;32m*****STARTING SERVER*****\e[0m\n"
echo "bash -c '${STARTCOMMAND[*]}'"
su steam -c "bash -c '${STARTCOMMAND[*]}'"
echo "${STARTCOMMAND[*]}"
"${STARTCOMMAND[@]}"
thijsvanloef marked this conversation as resolved.
Show resolved Hide resolved