Skip to content

Commit

Permalink
Modified to support PUID/PGID by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Dashboy1998 committed Jan 31, 2024
1 parent 3d8fd4f commit 0390f60
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TZ="UTC"
PLAYERS="16"
PORT="8211"
PUID="1000"
PGID="1000"
MULTITHREADING="false"
COMMUNITY="false"
PUBLIC_IP=""
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RUN wget -q "$SUPERCRONIC_URL" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

ENV PORT= \
PUID=1000 \
PGID=1000 \
PLAYERS= \
MULTITHREADING=false \
COMMUNITY=false \
Expand Down Expand Up @@ -55,5 +57,4 @@ HEALTHCHECK --start-period=5m \
CMD pgrep "PalServer-Linux" > /dev/null || exit 1

EXPOSE ${PORT} ${RCON_PORT}
USER steam
ENTRYPOINT ["/home/steam/server/init.sh"]
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ services:
restart: unless-stopped
container_name: palworld-server
stop_grace_period: 30s # Set to however long you are willing to wait for the container to gracefully stop
user: 1000:1000
ports:
- 8211:8211/udp
- 27015:27015/udp # Required if you want your server to show up in the community servers tab
environment:
- PUID=1000
- PGID=1000
- PORT=8211 # Optional but recommended
- PLAYERS=16 # Optional but recommended
- SERVER_PASSWORD="worldofpals" # Optional but recommended
Expand Down
3 changes: 0 additions & 3 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ spec:
- name: palworld-server
image: thijsvanloef/palworld-server-docker
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 1000
runAsGroup: 1000
ports:
- containerPort: 8211
name: server
Expand Down
4 changes: 4 additions & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ 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"

if [ "${DELETE_OLD_BACKUPS}" = true ]; then
Expand Down
18 changes: 16 additions & 2 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/bin/bash

if [[ "$(id -u)" -eq 0 ]] || [[ "$(id -g)" -eq 0 ]]; then
if [[ "$(id -u)" -eq 0 ]] && [[ "$(id -g)" -eq 0 ]]; then
if [[ "${PUID}" -ne 0 ]] && [[ "${PGID}" -ne 0 ]]; then
printf "\e[0;32m*****EXECUTING USERMOD*****\e[0m\n"
usermod -o -u "${PUID}" steam
groupmod -o -g "${PGID}" steam
chown -R steam:steam /palworld /home/steam/
else
printf "\033[31mRunning as root is not supported, please fix your PUID and PGID!\n"
exit 1
fi
elif [[ "$(id -u)" -eq 0 ]] || [[ "$(id -g)" -eq 0 ]]; then
printf "\033[31mRunning as root is not supported, please fix your user!\n"
exit 1
fi
Expand All @@ -19,7 +29,11 @@ term_handler() {

trap 'term_handler' SIGTERM

./start.sh &
if [[ "$(id -u)" -eq 0 ]]; then
su steam -c ./start.sh &
else
./start.sh &
fi
# Process ID of su
killpid="$!"
wait $killpid

0 comments on commit 0390f60

Please sign in to comment.