diff --git a/Dockerfile b/Dockerfile index 137cf38b2..5fd8106f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ diff --git a/scripts/backup.sh b/scripts/backup.sh index 82e75eb19..43eecb460 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -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" diff --git a/scripts/init.sh b/scripts/init.sh index bbf91a455..24c3fac10 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -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 @@ -29,6 +24,7 @@ term_handler() { trap 'term_handler' SIGTERM -./start.sh & +su steam -c ./start.sh & +# Process ID of su killpid="$!" wait $killpid diff --git a/scripts/start.sh b/scripts/start.sh index 2d83c36f4..c60c58b4f 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -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 @@ -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 @@ -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[@]}"