Skip to content

Commit

Permalink
Merge pull request #167 from Dashboy1998/minimize-root-processes
Browse files Browse the repository at this point in the history
Minimize Root Processes
  • Loading branch information
thijsvanloef authored Jan 28, 2024
2 parents d9d62e6 + 9de1b91 commit 5b72e8d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
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[@]}"

0 comments on commit 5b72e8d

Please sign in to comment.