From 706bc7f85422d2b1f25ef9efa382bc687f345ed4 Mon Sep 17 00:00:00 2001 From: StaleLoafOfBread <45444205+StaleLoafOfBread@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:39:01 -0500 Subject: [PATCH 1/2] feat(error): throw when not running as root --- entrypoint.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 897ec82..6760f25 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,6 +9,11 @@ APP_HOME=/home/$APP_USER source /includes/colors.sh +if [[ "${EUID}" -ne 0 ]]; then + ee ">>> Docker user must be root! Please adjust how you started the container." + exit 1 +fi + if [[ "${PUID}" -eq 0 ]] || [[ "${PGID}" -eq 0 ]]; then ee ">>> Running Palworld as root is not supported, please fix your PUID and PGID!" exit 1 @@ -16,7 +21,7 @@ elif [[ "$(id -u steam)" -ne "${PUID}" ]] || [[ "$(id -g steam)" -ne "${PGID}" ] ew "> Current $APP_USER user PUID is '$(id -u steam)' and PGID is '$(id -g steam)'" ew "> Setting new $APP_USER user PUID to '${PUID}' and PGID to '${PGID}'" groupmod -g "${PGID}" "$APP_GROUP" && usermod -u "${PUID}" -g "${PGID}" "$APP_USER" -else +else ew "> Current $APP_USER user PUID is '$(id -u steam)' and PGID is '$(id -g steam)'" ew "> PUID and PGID matching what is requested for user $APP_USER" fi @@ -28,6 +33,7 @@ chown "$APP_USER":"$APP_GROUP" /PalWorldSettings.ini.template chown -R "$APP_USER":"$APP_GROUP" /scripts chown -R "$APP_USER":"$APP_GROUP" /includes -ew_nn "> id steam: " ; e "$(id steam)" +ew_nn "> id steam: " +e "$(id steam)" exec gosu $APP_USER:$APP_GROUP "$@" From c6bbf7ea0ecb53f87bc1fbff4da2cb1577602d56 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:01:15 +0200 Subject: [PATCH 2/2] finalising the pr --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6760f25..7561e49 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,6 @@ #!/bin/bash # shellcheck disable=SC1091 +# https://stackoverflow.com/questions/27669950/difference-between-euid-and-uid set -e @@ -10,7 +11,7 @@ APP_HOME=/home/$APP_USER source /includes/colors.sh if [[ "${EUID}" -ne 0 ]]; then - ee ">>> Docker user must be root! Please adjust how you started the container." + ee ">>> This Docker-Container must be run as root! Please adjust how you started the container, to fix this error." exit 1 fi @@ -33,7 +34,6 @@ chown "$APP_USER":"$APP_GROUP" /PalWorldSettings.ini.template chown -R "$APP_USER":"$APP_GROUP" /scripts chown -R "$APP_USER":"$APP_GROUP" /includes -ew_nn "> id steam: " -e "$(id steam)" +ew_nn "> id steam: " ; e "$(id steam)" exec gosu $APP_USER:$APP_GROUP "$@"