diff --git a/README.md b/README.md index eb05d26c7..8e66428b7 100644 --- a/README.md +++ b/README.md @@ -57,15 +57,15 @@ services: - PGID=1000 - PORT=8211 # Optional but recommended - PLAYERS=16 # Optional but recommended - - SERVER_PASSWORD="worldofpals" # Optional but recommended + - SERVER_PASSWORD=worldofpals # Optional but recommended - MULTITHREADING=true - RCON_ENABLED=true - RCON_PORT=25575 - TZ=UTC - - ADMIN_PASSWORD="adminPasswordHere" + - ADMIN_PASSWORD=adminPasswordHere - COMMUNITY=false # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! - - SERVER_NAME="World of Pals" - - SERVER_DESCRIPTION="Awesome World of Pal" + - SERVER_NAME=World of Pals + - SERVER_DESCRIPTION=palworld-server-docker by Thijs van Loef volumes: - ./palworld:/palworld/ ``` @@ -108,11 +108,11 @@ docker run -d \ -e RCON_ENABLED=true \ -e RCON_PORT=25575 \ -e TZ=UTC \ - -e ADMIN_PASSWORD="adminPasswordHere" \ - -e SERVER_PASSWORD="worldofpals" \ + -e ADMIN_PASSWORD=adminPasswordHere \ + -e SERVER_PASSWORD=worldofpals \ -e COMMUNITY=false \ - -e SERVER_NAME="World of Pals" \ - -e SERVER_DESCRIPTION="Awesome World of Pal" \ + -e SERVER_NAME=World of Pals \ + -e SERVER_DESCRIPTION=palworld-server-docker by Thijs van Loef \ --restart unless-stopped \ --stop-timeout 30 \ thijsvanloef/palworld-server-docker:latest diff --git a/docker-compose.yml b/docker-compose.yml index ef5491aae..90c2b84eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,14 +12,14 @@ services: - PGID=1000 - PORT=8211 # Optional but recommended - PLAYERS=16 # Optional but recommended - - SERVER_PASSWORD="worldofpals" # Optional but recommended + - SERVER_PASSWORD=worldofpals # Optional but recommended - MULTITHREADING=true - RCON_ENABLED=true - RCON_PORT=25575 - TZ=UTC - - ADMIN_PASSWORD="adminPasswordHere" + - ADMIN_PASSWORD=adminPasswordHere - COMMUNITY=false # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! - - SERVER_NAME="World of Pals" - - SERVER_DESCRIPTION="" + - SERVER_NAME=World of Pals + - SERVER_DESCRIPTION=palworld-server-docker by Thijs van Loef volumes: - ./palworld:/palworld/ diff --git a/scripts/start.sh b/scripts/start.sh index 40edf2ff8..2b8f53132 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -40,27 +40,36 @@ if [ ! "$(grep -s '[^[:space:]]' /palworld/Pal/Saved/Config/LinuxServer/PalWorld cp /palworld/DefaultPalWorldSettings.ini /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi +escape_sed() { + printf '%s\n' "$1" | sed -e 's:[][\/.^$*]:\\&:g' +} + if [ -n "${SERVER_NAME}" ]; then + SERVER_NAME=$(escape_sed "$SERVER_NAME" | sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/") echo "SERVER_NAME=${SERVER_NAME}" - sed -E -i "s/ServerName=\"[^\"]*\"/ServerName=$SERVER_NAME/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + sed -E -i "s/ServerName=\"[^\"]*\"/ServerName=\"$SERVER_NAME\"/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi if [ -n "${SERVER_DESCRIPTION}" ]; then + SERVER_DESCRIPTION=$(escape_sed "$SERVER_DESCRIPTION" | sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/") echo "SERVER_DESCRIPTION=${SERVER_DESCRIPTION}" - sed -E -i "s/ServerDescription=\"[^\"]*\"/ServerDescription=$SERVER_DESCRIPTION/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + sed -E -i "s/ServerDescription=\"[^\"]*\"/ServerDescription=\"$SERVER_DESCRIPTION\"/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi if [ -n "${SERVER_PASSWORD}" ]; then + SERVER_PASSWORD=$(sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/" <<< "$SERVER_PASSWORD") echo "SERVER_PASSWORD=${SERVER_PASSWORD}" - sed -E -i "s/ServerPassword=\"[^\"]*\"/ServerPassword=$SERVER_PASSWORD/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + sed -E -i "s/ServerPassword=\"[^\"]*\"/ServerPassword=\"$SERVER_PASSWORD\"/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi if [ -n "${ADMIN_PASSWORD}" ]; then + ADMIN_PASSWORD=$(sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/" <<< "$ADMIN_PASSWORD") echo "ADMIN_PASSWORD=${ADMIN_PASSWORD}" - sed -E -i "s/AdminPassword=\"[^\"]*\"/AdminPassword=$ADMIN_PASSWORD/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + sed -E -i "s/AdminPassword=\"[^\"]*\"/AdminPassword=\"$ADMIN_PASSWORD\"/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi if [ -n "${PLAYERS}" ]; then echo "PLAYERS=${PLAYERS}" sed -E -i "s/ServerPlayerMaxNum=[0-9]*/ServerPlayerMaxNum=$PLAYERS/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi if [ -n "${PUBLIC_IP}" ]; then + PUBLIC_IP=$(sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/" <<< "$PUBLIC_IP") echo "PUBLIC_IP=${PUBLIC_IP}" sed -E -i "s/PublicIP=\"[^\"]*\"/PublicIP=\"$PUBLIC_IP\"/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi @@ -269,6 +278,7 @@ if [ -n "${COOP_PLAYER_MAX_NUM}" ]; then sed -E -i "s/CoopPlayerMaxNum=[0-9]*/CoopPlayerMaxNum=$COOP_PLAYER_MAX_NUM/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi if [ -n "${REGION}" ]; then + REGION=$(sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/" <<< "$REGION") echo "REGION=$REGION" sed -E -i "s/Region=\"[^\"]*\"/Region=\"$REGION\"/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi @@ -277,6 +287,7 @@ if [ -n "${USEAUTH}" ]; then sed -E -i "s/bUseAuth=[a-zA-Z]*/bUseAuth=$USEAUTH/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi if [ -n "${BAN_LIST_URL}" ]; then + BAN_LIST_URL=$(sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/" <<< "$BAN_LIST_URL") echo "BAN_LIST_URL=$BAN_LIST_URL" sed -E -i "s~BanListURL=\"[^\"]*\"~BanListURL=\"$BAN_LIST_URL\"~" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi