Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set palworldsettings via envsubst and templating #207

Merged
merged 15 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LABEL maintainer="[email protected]" \
RUN apt-get update && apt-get install -y --no-install-recommends \
procps=2:3.3.17-5 \
wget=1.21-1+deb11u1 \
gettext-base=0.21-4 \
xdg-user-dirs=0.17-2 \
jo=1.3-2 \
&& apt-get clean \
Expand Down Expand Up @@ -75,7 +76,7 @@ ENV PORT= \
DISCORD_PRE_SHUTDOWN_MESSAGE="Server is shutting down..." \
DISCORD_POST_SHUTDOWN_MESSAGE="Server has been stopped!"

COPY ./scripts/* /home/steam/server/
COPY ./scripts /home/steam/server/

RUN chmod +x /home/steam/server/*.sh && \
mv /home/steam/server/backup.sh /usr/local/bin/backup && \
Expand Down
143 changes: 143 additions & 0 deletions scripts/compile-settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash

echo "Compiling PalWorldSettings.ini..."

export DIFFICULTY=${DIFFICULTY:-None}
export DAYTIME_SPEEDRATE=${DAYTIME_SPEEDRATE:-1.000000}
export NIGHTTIME_SPEEDRATE=${NIGHTTIME_SPEEDRATE:-1.000000}
export EXP_RATE=${EXP_RATE:-1.000000}
export PAL_CAPTURE_RATE=${PAL_CAPTURE_RATE:-1.000000}
export PAL_SPAWN_NUM_RATE=${PAL_SPAWN_NUM_RATE:-1.000000}
export PAL_DAMAGE_RATE_ATTACK=${PAL_DAMAGE_RATE_ATTACK:-1.000000}
export PAL_DAMAGE_RATE_DEFENSE=${PAL_DAMAGE_RATE_DEFENSE:-1.000000}
export PLAYER_DAMAGE_RATE_ATTACK=${PLAYER_DAMAGE_RATE_ATTACK:-1.000000}
export PLAYER_DAMAGE_RATE_DEFENSE=${PLAYER_DAMAGE_RATE_DEFENSE:-1.000000}
export PLAYER_STOMACH_DECREACE_RATE=${PLAYER_STOMACH_DECREACE_RATE:-1.000000}
export PLAYER_STAMINA_DECREACE_RATE=${PLAYER_STAMINA_DECREACE_RATE:-1.000000}
export PLAYER_AUTO_HPREGENE_RATE=${PLAYER_AUTO_HPREGENE_RATE:-1.000000}
export PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP=${PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP:-1.000000}
export PAL_STOMACH_DECREACE_RATE=${PAL_STOMACH_DECREACE_RATE:-1.000000}
export PAL_STAMINA_DECREACE_RATE=${PAL_STAMINA_DECREACE_RATE:-1.000000}
export PAL_AUTO_HPREGENE_RATE=${PAL_AUTO_HPREGENE_RATE:-1.000000}
export PAL_AUTO_HP_REGENE_RATE_IN_SLEEP=${PAL_AUTO_HP_REGENE_RATE_IN_SLEEP:-1.000000}
export BUILD_OBJECT_DAMAGE_RATE=${BUILD_OBJECT_DAMAGE_RATE:-1.000000}
export BUILD_OBJECT_DETERIORATION_DAMAGE_RATE=${BUILD_OBJECT_DETERIORATION_DAMAGE_RATE:-1.000000}
export COLLECTION_DROP_RATE=${COLLECTION_DROP_RATE:-1.000000}
export COLLECTION_OBJECT_HP_RATE=${COLLECTION_OBJECT_HP_RATE:-1.000000}
export COLLECTION_OBJECT_RESPAWN_SPEED_RATE=${COLLECTION_OBJECT_RESPAWN_SPEED_RATE:-1.000000}
export ENEMY_DROP_ITEM_RATE=${ENEMY_DROP_ITEM_RATE:-1.000000}
export DEATH_PENALTY=${DEATH_PENALTY:-All}
export ENABLE_PLAYER_TO_PLAYER_DAMAGE=${ENABLE_PLAYER_TO_PLAYER_DAMAGE:-False}
export ENABLE_FRIENDLY_FIRE=${ENABLE_FRIENDLY_FIRE:-False}
export ENABLE_INVADER_ENEMY=${ENABLE_INVADER_ENEMY:-True}
export ACTIVE_UNKO=${ACTIVE_UNKO:-False}
export ENABLE_AIM_ASSIST_PAD=${ENABLE_AIM_ASSIST_PAD:-True}
export ENABLE_AIM_ASSIST_KEYBOARD=${ENABLE_AIM_ASSIST_KEYBOARD:-False}
export DROP_ITEM_MAX_NUM=${DROP_ITEM_MAX_NUM:-3000}
export DROP_ITEM_MAX_NUM_UNKO=${DROP_ITEM_MAX_NUM_UNKO:-100}
export BASE_CAMP_MAX_NUM=${BASE_CAMP_MAX_NUM:-128}
export BASE_CAMP_WORKER_MAX_NUM=${BASE_CAMP_WORKER_MAX_NUM:-15}
export DROP_ITEM_ALIVE_MAX_HOURS=${DROP_ITEM_ALIVE_MAX_HOURS:-1.000000}
export AUTO_RESET_GUILD_NO_ONLINE_PLAYERS=${AUTO_RESET_GUILD_NO_ONLINE_PLAYERS:-False}
export AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS=${AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS:-72.000000}
export GUILD_PLAYER_MAX_NUM=${GUILD_PLAYER_MAX_NUM:-20}
export PAL_EGG_DEFAULT_HATCHING_TIME=${PAL_EGG_DEFAULT_HATCHING_TIME:-72.000000}
export WORK_SPEED_RATE=${WORK_SPEED_RATE:-1.000000}
export IS_MULTIPLAY=${IS_MULTIPLAY:-False}
export IS_PVP=${IS_PVP:-False}
export CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP=${CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP:-False}
export ENABLE_NON_LOGIN_PENALTY=${ENABLE_NON_LOGIN_PENALTY:-True}
export ENABLE_FAST_TRAVEL=${ENABLE_FAST_TRAVEL:-True}
export IS_START_LOCATION_SELECT_BY_MAP=${IS_START_LOCATION_SELECT_BY_MAP:-True}
export EXIST_PLAYER_AFTER_LOGOUT=${EXIST_PLAYER_AFTER_LOGOUT:-False}
export ENABLE_DEFENSE_OTHER_GUILD_PLAYER=${ENABLE_DEFENSE_OTHER_GUILD_PLAYER:-False}
export COOP_PLAYER_MAX_NUM=${COOP_PLAYER_MAX_NUM:-4}
export SERVER_PLAYER_MAX_NUM=${PLAYERS:-32}
export SERVER_NAME=\"${SERVER_NAME:-"Default Palworld Server"}\"
export SERVER_DESCRIPTION=\"${SERVER_DESCRIPTION:-""}\"
export ADMIN_PASSWORD=\"${ADMIN_PASSWORD:-""}\"
export SERVER_PASSWORD=\"${SERVER_PASSWORD:-""}\"
export PUBLIC_PORT=${PORT:-8211}
export PUBLIC_IP=\"${PUBLIC_IP:-""}\"
export RCON_ENABLED=${RCON_ENABLED:-False}
export RCON_PORT=${RCON_PORT:-25575}
export REGION=\"${REGION:-""}\"
export USEAUTH=${USEAUTH:-True}
export BAN_LIST_URL=\"${BAN_LIST_URL:-https://api.palworldgame.com/api/banlist.txt}\"

if [ "${DEBUG,,}" = true ]; then
cat <<EOF
====Debug====
DIFFICULTY = $DIFFICULTY
DAYTIME_SPEEDRATE = $DAYTIME_SPEEDRATE
NIGHTTIME_SPEEDRATE = $NIGHTTIME_SPEEDRATE
EXP_RATE = $EXP_RATE
PAL_CAPTURE_RATE = $PAL_CAPTURE_RATE
PAL_SPAWN_NUM_RATE = $PAL_SPAWN_NUM_RATE
PAL_DAMAGE_RATE_ATTACK = $PAL_DAMAGE_RATE_ATTACK
PAL_DAMAGE_RATE_DEFENSE = $PAL_DAMAGE_RATE_DEFENSE
PLAYER_DAMAGE_RATE_ATTACK = $PLAYER_DAMAGE_RATE_ATTACK
PLAYER_DAMAGE_RATE_DEFENSE = $PLAYER_DAMAGE_RATE_DEFENSE
PLAYER_STOMACH_DECREACE_RATE = $PLAYER_STOMACH_DECREACE_RATE
PLAYER_STAMINA_DECREACE_RATE = $PLAYER_STAMINA_DECREACE_RATE
PLAYER_AUTO_HPREGENE_RATE = $PLAYER_AUTO_HPREGENE_RATE
PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP = $PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP
PAL_STOMACH_DECREACE_RATE = $PAL_STOMACH_DECREACE_RATE
PAL_STAMINA_DECREACE_RATE = $PAL_STAMINA_DECREACE_RATE
PAL_AUTO_HPREGENE_RATE = $PAL_AUTO_HPREGENE_RATE
PAL_AUTO_HP_REGENE_RATE_IN_SLEEP = $PAL_AUTO_HP_REGENE_RATE_IN_SLEEP
BUILD_OBJECT_DAMAGE_RATE = $BUILD_OBJECT_DAMAGE_RATE
BUILD_OBJECT_DETERIORATION_DAMAGE_RATE = $BUILD_OBJECT_DETERIORATION_DAMAGE_RATE
COLLECTION_DROP_RATE = $COLLECTION_DROP_RATE
COLLECTION_OBJECT_HP_RATE = $COLLECTION_OBJECT_HP_RATE
COLLECTION_OBJECT_RESPAWN_SPEED_RATE = $COLLECTION_OBJECT_RESPAWN_SPEED_RATE
ENEMY_DROP_ITEM_RATE = $ENEMY_DROP_ITEM_RATE
DEATH_PENALTY = $DEATH_PENALTY
ENABLE_PLAYER_TO_PLAYER_DAMAGE = $ENABLE_PLAYER_TO_PLAYER_DAMAGE
ENABLE_FRIENDLY_FIRE = $ENABLE_FRIENDLY_FIRE
ENABLE_INVADER_ENEMY = $ENABLE_INVADER_ENEMY
ACTIVE_UNKO = $ACTIVE_UNKO
ENABLE_AIM_ASSIST_PAD = $ENABLE_AIM_ASSIST_PAD
ENABLE_AIM_ASSIST_KEYBOARD = $ENABLE_AIM_ASSIST_KEYBOARD
DROP_ITEM_MAX_NUM = $DROP_ITEM_MAX_NUM
DROP_ITEM_MAX_NUM_UNKO = $DROP_ITEM_MAX_NUM_UNKO
BASE_CAMP_MAX_NUM = $BASE_CAMP_MAX_NUM
BASE_CAMP_WORKER_MAX_NUM = $BASE_CAMP_WORKER_MAX_NUM
DROP_ITEM_ALIVE_MAX_HOURS = $DROP_ITEM_ALIVE_MAX_HOURS
AUTO_RESET_GUILD_NO_ONLINE_PLAYERS = $AUTO_RESET_GUILD_NO_ONLINE_PLAYERS
AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS = $AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS
GUILD_PLAYER_MAX_NUM = $GUILD_PLAYER_MAX_NUM
PAL_EGG_DEFAULT_HATCHING_TIME = $PAL_EGG_DEFAULT_HATCHING_TIME
WORK_SPEED_RATE = $WORK_SPEED_RATE
IS_MULTIPLAY = $IS_MULTIPLAY
IS_PVP = $IS_PVP
CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP = $CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP
ENABLE_NON_LOGIN_PENALTY = $ENABLE_NON_LOGIN_PENALTY
ENABLE_FAST_TRAVEL = $ENABLE_FAST_TRAVEL
IS_START_LOCATION_SELECT_BY_MAP = $IS_START_LOCATION_SELECT_BY_MAP
EXIST_PLAYER_AFTER_LOGOUT = $EXIST_PLAYER_AFTER_LOGOUT
ENABLE_DEFENSE_OTHER_GUILD_PLAYER = $ENABLE_DEFENSE_OTHER_GUILD_PLAYER
COOP_PLAYER_MAX_NUM = $COOP_PLAYER_MAX_NUM
SERVER_PLAYER_MAX_NUM = $SERVER_PLAYER_MAX_NUM
SERVER_NAME = $SERVER_NAME
SERVER_DESCRIPTION = $SERVER_DESCRIPTION
ADMIN_PASSWORD = $ADMIN_PASSWORD
SERVER_PASSWORD = $SERVER_PASSWORD
PUBLIC_PORT = $PUBLIC_PORT
PUBLIC_IP = $PUBLIC_IP
RCON_ENABLED = $RCON_ENABLED
RCON_PORT = $RCON_PORT
REGION = $REGION
USEAUTH = $USEAUTH
BAN_LIST_URL = $BAN_LIST_URL
====Debug====
EOF
fi

mkdir -p /palworld/Pal/Saved/Config/LinuxServer
cat > /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini <<EOF
[/Script/Pal.PalGameWorldSettings]
$(envsubst < ./files/PalWorldSettings.ini.template | tr -d "\n\r")
EOF

echo "Compiling PalWorldSettings.ini done!"
64 changes: 64 additions & 0 deletions scripts/files/PalWorldSettings.ini.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
OptionSettings=(
Difficulty=$DIFFICULTY,
DayTimeSpeedRate=$DAYTIME_SPEEDRATE,
NightTimeSpeedRate=$NIGHTTIME_SPEEDRATE,
ExpRate=$EXP_RATE,
PalCaptureRate=$PAL_CAPTURE_RATE,
PalSpawnNumRate=$PAL_SPAWN_NUM_RATE,
PalDamageRateAttack=$PAL_DAMAGE_RATE_ATTACK,
PalDamageRateDefense=$PAL_DAMAGE_RATE_DEFENSE,
PlayerDamageRateAttack=$PLAYER_DAMAGE_RATE_ATTACK,
PlayerDamageRateDefense=$PLAYER_DAMAGE_RATE_DEFENSE,
PlayerStomachDecreaceRate=$PLAYER_STOMACH_DECREACE_RATE,
PlayerStaminaDecreaceRate=$PLAYER_STAMINA_DECREACE_RATE,
PlayerAutoHPRegeneRate=$PLAYER_AUTO_HPREGENE_RATE,
PlayerAutoHpRegeneRateInSleep=$PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP,
PalStomachDecreaceRate=$PAL_STOMACH_DECREACE_RATE,
PalStaminaDecreaceRate=$PAL_STAMINA_DECREACE_RATE,
PalAutoHPRegeneRate=$PAL_AUTO_HPREGENE_RATE,
PalAutoHpRegeneRateInSleep=$PAL_AUTO_HP_REGENE_RATE_IN_SLEEP,
BuildObjectDamageRate=$BUILD_OBJECT_DAMAGE_RATE,
BuildObjectDeteriorationDamageRate=$BUILD_OBJECT_DETERIORATION_DAMAGE_RATE,
CollectionDropRate=$COLLECTION_DROP_RATE,
CollectionObjectHpRate=$COLLECTION_OBJECT_HP_RATE,
CollectionObjectRespawnSpeedRate=$COLLECTION_OBJECT_RESPAWN_SPEED_RATE,
EnemyDropItemRate=$ENEMY_DROP_ITEM_RATE,
DeathPenalty=$DEATH_PENALTY,
bEnablePlayerToPlayerDamage=$ENABLE_PLAYER_TO_PLAYER_DAMAGE,
bEnableFriendlyFire=$ENABLE_FRIENDLY_FIRE,
bEnableInvaderEnemy=$ENABLE_INVADER_ENEMY,
bActiveUNKO=$ACTIVE_UNKO,
bEnableAimAssistPad=$ENABLE_AIM_ASSIST_PAD,
bEnableAimAssistKeyboard=$ENABLE_AIM_ASSIST_KEYBOARD,
DropItemMaxNum=$DROP_ITEM_MAX_NUM,
DropItemMaxNum_UNKO=$DROP_ITEM_MAX_NUM_UNKO,
BaseCampMaxNum=$BASE_CAMP_MAX_NUM,
BaseCampWorkerMaxNum=$BASE_CAMP_WORKER_MAX_NUM,
DropItemAliveMaxHours=$DROP_ITEM_ALIVE_MAX_HOURS,
bAutoResetGuildNoOnlinePlayers=$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS,
AutoResetGuildTimeNoOnlinePlayers=$AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS,
GuildPlayerMaxNum=$GUILD_PLAYER_MAX_NUM,
PalEggDefaultHatchingTime=$PAL_EGG_DEFAULT_HATCHING_TIME,
WorkSpeedRate=$WORK_SPEED_RATE,
bIsMultiplay=$IS_MULTIPLAY,
bIsPvP=$IS_PVP,
bCanPickupOtherGuildDeathPenaltyDrop=$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP,
bEnableNonLoginPenalty=$ENABLE_NON_LOGIN_PENALTY,
bEnableFastTravel=$ENABLE_FAST_TRAVEL,
bIsStartLocationSelectByMap=$IS_START_LOCATION_SELECT_BY_MAP,
bExistPlayerAfterLogout=$EXIST_PLAYER_AFTER_LOGOUT,
bEnableDefenseOtherGuildPlayer=$ENABLE_DEFENSE_OTHER_GUILD_PLAYER,
CoopPlayerMaxNum=$COOP_PLAYER_MAX_NUM,
ServerPlayerMaxNum=$SERVER_PLAYER_MAX_NUM,
ServerName=$SERVER_NAME,
ServerDescription=$SERVER_DESCRIPTION,
AdminPassword=$ADMIN_PASSWORD,
ServerPassword=$SERVER_PASSWORD,
PublicPort=$PUBLIC_PORT,
PublicIP=$PUBLIC_IP,
RCONEnabled=$RCON_ENABLED,
RCONPort=$RCON_PORT,
Region=$REGION,
bUseAuth=$USEAUTH,
BanListURL=$BAN_LIST_URL
)
Loading