From 45149b329011f733dbec95d327c284f6a0b9c3d5 Mon Sep 17 00:00:00 2001 From: Gabe Date: Tue, 30 Jan 2024 23:11:25 -0500 Subject: [PATCH 1/3] Fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c69906..713a752 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ You can try to insert in your docker-compose file this parameter `platform: linu ### I have changed the `BaseCampWorkerMaxNum` settings, why are changes un-affected on the server? -It is a confirm bug, that changing `BaseCampWorkerMaxNum` in the `PalWorldSettings.ini` has no affect on the server. There are tools out there to help with this, like this one: +It is a confirm bug, that changing `BaseCampWorkerMaxNum` in the `PalWorldSettings.ini` has no affect on the server. There are tools out there to help with this, like this one: **PLEASE NOTE** that adding `WorldOption.sav` will breaking `PalWorldSetting.ini` and if that happens all the other settings won't be changeable anymore unless that specific tool is used everytime. From 74668d81b55bdc1b6c1c955e5dacc1c76bc51627 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com> Date: Wed, 31 Jan 2024 17:16:06 +0100 Subject: [PATCH 2/3] Refactoring of shell-scripts and docker-based files, #120 also added the ability to send start and stop webhook notifies --- Dockerfile | 21 ++- backupmanager.sh | 20 +-- default.env | 11 ++ includes/config.sh | 311 ++++++++++++++++++++++++++++++++++ includes/cron.sh | 8 + includes/install.sh | 27 +++ includes/rcon.sh | 0 includes/security.sh | 12 ++ includes/webhook.sh | 28 ++++ servermanager.sh | 386 +++---------------------------------------- 10 files changed, 445 insertions(+), 379 deletions(-) create mode 100644 includes/config.sh create mode 100644 includes/cron.sh create mode 100644 includes/install.sh create mode 100644 includes/rcon.sh create mode 100644 includes/security.sh create mode 100644 includes/webhook.sh diff --git a/Dockerfile b/Dockerfile index a9701b5..2f917d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,12 +35,12 @@ RUN curl -fsSLO "$RCON_URL" \ && ln -s "/usr/local/bin/${RCON_BINARY}" /usr/local/bin/rconcli \ && rm -Rf rcon-0.10.3-amd64_linux rcon-0.10.3-amd64_linux.tar.gz -ADD --chown=steam:steam --chmod=755 servermanager.sh /servermanager.sh -ADD --chown=steam:steam --chmod=755 backupmanager.sh /backupmanager.sh +COPY --chown=steam:steam --chmod=755 backupmanager.sh servermanager.sh includes/* / EXPOSE 8211/udp EXPOSE 25575/tcp +# Workaround for 'Named Volumes' RUN mkdir /palworld \ && chown steam:steam /palworld @@ -53,7 +53,7 @@ ADD --chown=steam:steam --chmod=440 rcon.yaml ./rcon.yaml ENV DEBIAN_FRONTEND=noninteractive \ PUID=1000 \ PGID=1000 \ - # Container setttings + ### Container-setttings TZ="Europe/Berlin" \ ALWAYS_UPDATE_ON_START=true \ MULTITHREAD_ENABLED=true \ @@ -63,8 +63,19 @@ ENV DEBIAN_FRONTEND=noninteractive \ BACKUP_RETENTION_POLICY=false \ BACKUP_RETENTION_AMOUNT_TO_KEEP=30 \ STEAMCMD_VALIDATE_FILES=true \ - SERVER_SETTINGS_MODE=auto \ - # Server-setting + SERVER_SETTINGS_MODE=manual \ + WEBHOOK_ENABLED=false \ + WEBHOOK_URL= \ + WEBHOOK_START_TITLE="Server is starting" \ + WEBHOOK_START_DESCRIPTION="The gameserver is starting" \ + WEBHOOK_START_COLOR="2328576" \ + WEBHOOK_STOP_TITLE="Server has been stopped" \ + WEBHOOK_STOP_DESCRIPTION="The gameserver has been stopped" \ + WEBHOOK_STOP_COLOR="7413016" \ + WEBHOOK_INFO_TITLE="Info" \ + WEBHOOK_INFO_DESCRIPTION="This is an info from the server" \ + WEBHOOK_INFO_COLOR="2849520" \ + ### Server-setting NETSERVERMAXTICKRATE=120 \ DIFFICULTY=None \ DAYTIME_SPEEDRATE=1.000000 \ diff --git a/backupmanager.sh b/backupmanager.sh index 43a28a3..431b02b 100644 --- a/backupmanager.sh +++ b/backupmanager.sh @@ -6,21 +6,17 @@ TIME=$(date +%H-%M-%S) mkdir -p /palworld/backups if [[ -n $BACKUP_RETENTION_POLICY ]] && [[ $BACKUP_RETENTION_POLICY == "true" ]]; then cd /palworld/backups - echo ">>> The Backup retention policy is enabled" - echo "> Keeping latest $BACKUP_RETENTION_AMOUNT_TO_KEEP backups" + echo ">>> The Backup retention policy is enabled - Keeping latest $BACKUP_RETENTION_AMOUNT_TO_KEEP backups" ls -1t saved-*.tar.gz | tail -n +$(($BACKUP_RETENTION_AMOUNT_TO_KEEP + 1)) | xargs -d '\n' rm -f -- - echo ">>> Cleanup finished" fi -echo ">>> Creating backup" -echo "> Sending message to gameserver" cd ~/steamcmd/ -rconcli "broadcast $TIME-Backup-in-progress" -sleep 1 -rconcli 'broadcast Saving...' +rconcli "broadcast $TIME-Saving-in-5-seconds" +sleep 5 rconcli 'save' -rconcli 'broadcast Done...' -sleep 15 -# Create backup dir and change into it +rconcli 'broadcast Saving-done' +sleep 1 +rconcli 'broadcast Creating-backup' cd /palworld/Pal tar cfz /palworld/backups/saved-$DATE.tar.gz Saved/ -echo ">>> Done" +cd ~/steamcmd/ +rconcli 'broadcast Backup-done' diff --git a/default.env b/default.env index 68af08f..24ef3b1 100644 --- a/default.env +++ b/default.env @@ -10,6 +10,17 @@ BACKUP_RETENTION_AMOUNT_TO_KEEP=30 STEAMCMD_VALIDATE_FILES=true # Change this to manual if you want to edit your configs yourself SERVER_SETTINGS_MODE=auto +WEBHOOK_ENABLED=false +WEBHOOK_URL="YOUR-URL-IN-HERE" +WEBHOOK_START_TITLE="Server is starting" +WEBHOOK_START_DESCRIPTION="The gameserver is starting" +WEBHOOK_START_COLOR="2328576" +WEBHOOK_STOP_TITLE="Server has been stopped" +WEBHOOK_STOP_DESCRIPTION="The gameserver has been stopped" +WEBHOOK_STOP_COLOR="7413016" +WEBHOOK_INFO_TITLE="Info" +WEBHOOK_INFO_DESCRIPTION="This is an info from the server" +WEBHOOK_INFO_COLOR="2849520" NETSERVERMAXTICKRATE=120 DIFFICULTY=None DAYTIME_SPEEDRATE=1.000000 diff --git a/includes/config.sh b/includes/config.sh new file mode 100644 index 0000000..653e7ad --- /dev/null +++ b/includes/config.sh @@ -0,0 +1,311 @@ +# Function to setup the Engine.ini +function setup_engine_ini() { + echo ">>> Setting up Engine.ini ..." + if [[ -n $SERVER_SETTINGS_MODE ]] && [[ $SERVER_SETTINGS_MODE == "auto" ]]; then + echo "> SERVER_SETTINGS_MODE is set to auto, using environment variables to configure the server!" + + config_file="${GAME_PATH}/Pal/Saved/Config/LinuxServer/Engine.ini" + pattern1="OnlineSubsystemUtils.IpNetDriver" + pattern2="^NetServerMaxTickRate=[0-9]*" + + if grep -qE "$pattern1" "$config_file"; then + echo ">Found [/Script/OnlineSubsystemUtils.IpNetDriver] section" + else + echo ">Found no [/Script/OnlineSubsystemUtils.IpNetDriver], adding it" + echo -e "\n[/Script/OnlineSubsystemUtils.IpNetDriver]" >> "$config_file" + fi + if grep -qE "$pattern2" "$config_file"; then + echo ">Found NetServerMaxTickRate parameter, changing it to $NETSERVERMAXTICKRATE" + sed -E -i "s/$pattern2/NetServerMaxTickRate=$NETSERVERMAXTICKRATE/" "$config_file" + else + echo ">Found no NetServerMaxTickRate parameter, adding it to $NETSERVERMAXTICKRATE" + echo "NetServerMaxTickRate=$NETSERVERMAXTICKRATE" >> "$config_file" + fi + else + echo "> SERVER_SETTINGS_MODE is set to manual, NOT using environment variables to configure the server!" + echo "> File ${GAME_PATH}/Pal/Saved/Config/LinuxServer/Engine.ini has to be manually set by user" + fi + echo ">>> Finished setting up Engine.ini ..." +} + +# Function to setup the PalWorldSettings.ini +function setup_pal_world_settings_ini() { + # setup the server config file + echo ">>> Setting up PalWorldSettings.ini ..." + echo "> Checking if config already exists" + if [ ! -f ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini ]; then + echo "> No config found, generating one" + if [ ! -d ${GAME_PATH}/Pal/Saved/Config/LinuxServer ]; then + mkdir -p ${GAME_PATH}/Pal/Saved/Config/LinuxServer + fi + # Copy default-config, which comes with the server to gameserver-save location + cp ${GAME_PATH}/DefaultPalWorldSettings.ini ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + else + echo "> Found existing config" + fi + + if [[ -n $SERVER_SETTINGS_MODE ]] && [[ $SERVER_SETTINGS_MODE == "auto" ]]; then + echo "> SERVER_SETTINGS_MODE is set to auto, using environment variables to configure the server!" + if [[ ! -z ${DIFFICULTY+x} ]]; then + echo "> Setting Difficulty to $DIFFICULTY" + sed -E -i "s/Difficulty=[a-zA-Z]*/Difficulty=$DIFFICULTY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${DAYTIME_SPEEDRATE+x} ]]; then + echo "> Setting DayTimeSpeedRate to $DAYTIME_SPEEDRATE" + sed -E -i "s/DayTimeSpeedRate=[+-]?([0-9]*[.])?[0-9]+/DayTimeSpeedRate=$DAYTIME_SPEEDRATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${NIGHTTIME_SPEEDRATE+x} ]]; then + echo "> Setting NightTimeSpeedRate to $NIGHTTIME_SPEEDRATE" + sed -E -i "s/NightTimeSpeedRate=[+-]?([0-9]*[.])?[0-9]+/NightTimeSpeedRate=$NIGHTTIME_SPEEDRATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${EXP_RATE+x} ]]; then + echo "> Setting ExpRate to $EXP_RATE" + sed -E -i "s/ExpRate=[+-]?([0-9]*[.])?[0-9]+/ExpRate=$EXP_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_CAPTURE_RATE+x} ]]; then + echo "> Setting PalCaptureRate to $PAL_CAPTURE_RATE" + sed -E -i "s/PalCaptureRate=[+-]?([0-9]*[.])?[0-9]+/PalCaptureRate=$PAL_CAPTURE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_SPAWN_NUM_RATE+x} ]]; then + echo "> Setting PalSpawnNumRate to $PAL_SPAWN_NUM_RATE" + sed -E -i "s/PalSpawnNumRate=[+-]?([0-9]*[.])?[0-9]+/PalSpawnNumRate=$PAL_SPAWN_NUM_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_DAMAGE_RATE_ATTACK+x} ]]; then + echo "> Setting PalDamageRateAttack to $PAL_DAMAGE_RATE_ATTACK" + sed -E -i "s/PalDamageRateAttack=[+-]?([0-9]*[.])?[0-9]+/PalDamageRateAttack=$PAL_DAMAGE_RATE_ATTACK/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_DAMAGE_RATE_DEFENSE+x} ]]; then + echo "> Setting PalDamageRateDefense to $PAL_DAMAGE_RATE_DEFENSE" + sed -E -i "s/PalDamageRateDefense=[+-]?([0-9]*[.])?[0-9]+/PalDamageRateDefense=$PAL_DAMAGE_RATE_DEFENSE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PLAYER_DAMAGE_RATE_ATTACK+x} ]]; then + echo "> Setting PlayerDamageRateAttack to $PLAYER_DAMAGE_RATE_ATTACK" + sed -E -i "s/PlayerDamageRateAttack=[+-]?([0-9]*[.])?[0-9]+/PlayerDamageRateAttack=$PLAYER_DAMAGE_RATE_ATTACK/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PLAYER_DAMAGE_RATE_DEFENSE+x} ]]; then + echo "> Setting PlayerDamageRateDefense to $PLAYER_DAMAGE_RATE_DEFENSE" + sed -E -i "s/PlayerDamageRateDefense=[+-]?([0-9]*[.])?[0-9]+/PlayerDamageRateDefense=$PLAYER_DAMAGE_RATE_DEFENSE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PLAYER_STOMACH_DECREASE_RATE+x} ]]; then + echo "> Setting PlayerStomachDecreaceRate to $PLAYER_STOMACH_DECREASE_RATE" + sed -E -i "s/PlayerStomachDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PlayerStomachDecreaceRate=$PLAYER_STOMACH_DECREASE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PLAYER_STAMINA_DECREACE_RATE+x} ]]; then + echo "> Setting PlayerStaminaDecreaceRate to $PLAYER_STAMINA_DECREACE_RATE" + sed -E -i "s/PlayerStaminaDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PlayerStaminaDecreaceRate=$PLAYER_STAMINA_DECREACE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PLAYER_AUTO_HP_REGENE_RATE+x} ]]; then + echo "> Setting PlayerAutoHPRegeneRate to $PLAYER_AUTO_HP_REGENE_RATE" + sed -E -i "s/PlayerAutoHPRegeneRate=[+-]?([0-9]*[.])?[0-9]+/PlayerAutoHPRegeneRate=$PLAYER_AUTO_HP_REGENE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP+x} ]]; then + echo "> Setting PlayerAutoHpRegeneRateInSleep to $PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP" + sed -E -i "s/PlayerAutoHpRegeneRateInSleep=[+-]?([0-9]*[.])?[0-9]+/PlayerAutoHpRegeneRateInSleep=$PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_STOMACH_DECREACE_RATE+x} ]]; then + echo "> Setting PalStomachDecreaceRate to $PAL_STOMACH_DECREACE_RATE" + sed -E -i "s/PalStomachDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PalStomachDecreaceRate=$PAL_STOMACH_DECREACE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_STAMINA_DECREACE_RATE+x} ]]; then + echo "> Setting PalStaminaDecreaceRate to $X" + sed -E -i "s/PalStaminaDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PalStaminaDecreaceRate=$PAL_STAMINA_DECREACE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_AUTO_HP_REGENE_RATE+x} ]]; then + echo "> Setting PalAutoHPRegeneRate to $PAL_AUTO_HP_REGENE_RATE" + sed -E -i "s/PalAutoHPRegeneRate=[+-]?([0-9]*[.])?[0-9]+/PalAutoHPRegeneRate=$PAL_AUTO_HP_REGENE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_AUTO_HP_REGENE_RATE_IN_SLEEP+x} ]]; then + echo "> Setting PalAutoHpRegeneRateInSleep to $PAL_AUTO_HP_REGENE_RATE_IN_SLEEP" + sed -E -i "s/PalAutoHpRegeneRateInSleep=[+-]?([0-9]*[.])?[0-9]+/PalAutoHpRegeneRateInSleep=$PAL_AUTO_HP_REGENE_RATE_IN_SLEEP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${BUILD_OBJECT_DAMAGE_RATE+x} ]]; then + echo "> Setting BuildObjectDamageRate to $BUILD_OBJECT_DAMAGE_RATE" + sed -E -i "s/BuildObjectDamageRate=[+-]?([0-9]*[.])?[0-9]+/BuildObjectDamageRate=$BUILD_OBJECT_DAMAGE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${BUILD_OBJECT_DETERIORATION_DAMAGE_RATE+x} ]]; then + echo "> Setting BuildObjectDeteriorationDamageRate to $BUILD_OBJECT_DETERIORATION_DAMAGE_RATE" + sed -E -i "s/BuildObjectDeteriorationDamageRate=[+-]?([0-9]*[.])?[0-9]+/BuildObjectDeteriorationDamageRate=$BUILD_OBJECT_DETERIORATION_DAMAGE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${COLLECTION_DROP_RATE+x} ]]; then + echo "> Setting CollectionDropRate to $COLLECTION_DROP_RATE" + sed -E -i "s/CollectionDropRate=[+-]?([0-9]*[.])?[0-9]+/CollectionDropRate=$COLLECTION_DROP_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${COLLECTION_OBJECT_HP_RATE+x} ]]; then + echo "> Setting CollectionObjectHpRate to $COLLECTION_OBJECT_HP_RATE" + sed -E -i "s/CollectionObjectHpRate=[+-]?([0-9]*[.])?[0-9]+/CollectionObjectHpRate=$COLLECTION_OBJECT_HP_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${COLLECTION_OBJECT_RESPAWN_SPEED_RATE+x} ]]; then + echo "> Setting CollectionObjectRespawnSpeedRate to $COLLECTION_OBJECT_RESPAWN_SPEED_RATE" + sed -E -i "s/CollectionObjectRespawnSpeedRate=[+-]?([0-9]*[.])?[0-9]+/CollectionObjectRespawnSpeedRate=$COLLECTION_OBJECT_RESPAWN_SPEED_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENEMY_DROP_ITEM_RATE+x} ]]; then + echo "> Setting EnemyDropItemRate to $ENEMY_DROP_ITEM_RATE" + sed -E -i "s/EnemyDropItemRate=[+-]?([0-9]*[.])?[0-9]+/EnemyDropItemRate=$ENEMY_DROP_ITEM_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${DEATH_PENALTY+x} ]]; then + echo "> Setting DeathPenalty to $DEATH_PENALTY" + sed -E -i "s/DeathPenalty=[a-zA-Z]*/DeathPenalty=$DEATH_PENALTY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_PLAYER_TO_PLAYER_DAMAGE+x} ]]; then + echo "> Setting bEnablePlayerToPlayerDamage to $ENABLE_PLAYER_TO_PLAYER_DAMAGE" + sed -E -i "s/bEnablePlayerToPlayerDamage=[a-zA-Z]*/bEnablePlayerToPlayerDamage=$ENABLE_PLAYER_TO_PLAYER_DAMAGE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_FRIENDLY_FIRE+x} ]]; then + echo "> Setting bEnableFriendlyFire to $ENABLE_FRIENDLY_FIRE" + sed -E -i "s/bEnableFriendlyFire=[a-zA-Z]*/bEnableFriendlyFire=$ENABLE_FRIENDLY_FIRE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_INVADER_ENEMY+x} ]]; then + echo "> Setting bEnableInvaderEnemy to $ENABLE_INVADER_ENEMY" + sed -E -i "s/bEnableInvaderEnemy=[a-zA-Z]*/bEnableInvaderEnemy=$ENABLE_INVADER_ENEMY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ACTIVE_UNKO+x} ]]; then + echo "> Setting bActiveUNKO to $ACTIVE_UNKO" + sed -E -i "s/bActiveUNKO=[a-zA-Z]*/bActiveUNKO=$ACTIVE_UNKO/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_AIM_ASSIST_PAD+x} ]]; then + echo "> Setting bEnableAimAssistPad to $ENABLE_AIM_ASSIST_PAD" + sed -E -i "s/bEnableAimAssistPad=[a-zA-Z]*/bEnableAimAssistPad=$ENABLE_AIM_ASSIST_PAD/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_AIM_ASSIST_KEYBOARD+x} ]]; then + echo "> Setting bEnableAimAssistKeyboard to $ENABLE_AIM_ASSIST_KEYBOARD" + sed -E -i "s/bEnableAimAssistKeyboard=[a-zA-Z]*/bEnableAimAssistKeyboard=$ENABLE_AIM_ASSIST_KEYBOARD/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${DROP_ITEM_MAX_NUM+x} ]]; then + echo "> Setting DropItemMaxNum to $DROP_ITEM_MAX_NUM" + sed -E -i "s/DropItemMaxNum=[0-9]*/DropItemMaxNum=$DROP_ITEM_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${DROP_ITEM_MAX_NUM_UNKO+x} ]]; then + echo "> Setting DropItemMaxNum_UNKO to $DROP_ITEM_MAX_NUM_UNKO" + sed -E -i "s/DropItemMaxNum_UNKO=[0-9]*/DropItemMaxNum_UNKO=$DROP_ITEM_MAX_NUM_UNKO/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${BASE_CAMP_MAX_NUM+x} ]]; then + echo "> Setting BaseCampMaxNum to $BASE_CAMP_MAX_NUM" + sed -E -i "s/BaseCampMaxNum=[0-9]*/BaseCampMaxNum=$BASE_CAMP_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${BASE_CAMP_WORKER_MAXNUM+x} ]]; then + echo "> Setting BaseCampWorkerMaxNum to $BASE_CAMP_WORKER_MAXNUM" + sed -E -i "s/BaseCampWorkerMaxNum=[0-9]*/BaseCampWorkerMaxNum=$BASE_CAMP_WORKER_MAXNUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${DROP_ITEM_ALIVE_MAX_HOURS+x} ]]; then + echo "> Setting DropItemAliveMaxHours to $DROP_ITEM_ALIVE_MAX_HOURS" + sed -E -i "s/DropItemAliveMaxHours=[+-]?([0-9]*[.])?[0-9]+/DropItemAliveMaxHours=$DROP_ITEM_ALIVE_MAX_HOURS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${AUTO_RESET_GUILD_NO_ONLINE_PLAYERS+x} ]]; then + echo "> Setting bAutoResetGuildNoOnlinePlayers to $AUTO_RESET_GUILD_NO_ONLINE_PLAYERS" + sed -E -i "s/bAutoResetGuildNoOnlinePlayers=[a-zA-Z]*/bAutoResetGuildNoOnlinePlayers=$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS+x} ]]; then + echo "> Setting AutoResetGuildTimeNoOnlinePlayers to $AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS" + sed -E -i "s/AutoResetGuildTimeNoOnlinePlayers=[+-]?([0-9]*[.])?[0-9]+/AutoResetGuildTimeNoOnlinePlayers=$AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${GUILD_PLAYER_MAX_NUM+x} ]]; then + echo "> Setting GuildPlayerMaxNum to $GUILD_PLAYER_MAX_NUM" + sed -E -i "s/GuildPlayerMaxNum=[0-9]*/GuildPlayerMaxNum=$GUILD_PLAYER_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PAL_EGG_DEFAULT_HATCHING_TIME+x} ]]; then + echo "> Setting PalEggDefaultHatchingTime to $PAL_EGG_DEFAULT_HATCHING_TIME" + sed -E -i "s/PalEggDefaultHatchingTime=[+-]?([0-9]*[.])?[0-9]+/PalEggDefaultHatchingTime=$PAL_EGG_DEFAULT_HATCHING_TIME/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${WORK_SPEED_RATE+x} ]]; then + echo "> Setting WorkSpeedRate to $WORK_SPEED_RATE" + sed -E -i "s/WorkSpeedRate=[+-]?([0-9]*[.])?[0-9]+/WorkSpeedRate=$WORK_SPEED_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${IS_MULTIPLAY+x} ]]; then + echo "> Setting bIsMultiplay to $IS_MULTIPLAY" + sed -E -i "s/bIsMultiplay=[a-zA-Z]*/bIsMultiplay=$IS_MULTIPLAY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${IS_PVP+x} ]]; then + echo "> Setting bIsPvP to $IS_PVP" + sed -E -i "s/bIsPvP=[a-zA-Z]*/bIsPvP=$IS_PVP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP+x} ]]; then + echo "> Setting bCanPickupOtherGuildDeathPenaltyDrop to $CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP" + sed -E -i "s/bCanPickupOtherGuildDeathPenaltyDrop=[a-zA-Z]*/bCanPickupOtherGuildDeathPenaltyDrop=$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_NON_LOGIN_PENALTY+x} ]]; then + echo "> Setting bEnableNonLoginPenalty to $ENABLE_NON_LOGIN_PENALTY" + sed -E -i "s/bEnableNonLoginPenalty=[a-zA-Z]*/bEnableNonLoginPenalty=$ENABLE_NON_LOGIN_PENALTY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_FAST_TRAVEL+x} ]]; then + echo "> Setting bEnableFastTravel to $ENABLE_FAST_TRAVEL" + sed -E -i "s/bEnableFastTravel=[a-zA-Z]*/bEnableFastTravel=$ENABLE_FAST_TRAVEL/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${IS_START_LOCATION_SELECT_BY_MAP+x} ]]; then + echo "> Setting bIsStartLocationSelectByMap to $IS_START_LOCATION_SELECT_BY_MAP" + sed -E -i "s/bIsStartLocationSelectByMap=[a-zA-Z]*/bIsStartLocationSelectByMap=$IS_START_LOCATION_SELECT_BY_MAP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${EXIST_PLAYER_AFTER_LOGOUT+x} ]]; then + echo "> Setting bExistPlayerAfterLogout to $EXIST_PLAYER_AFTER_LOGOUT" + sed -E -i "s/bExistPlayerAfterLogout=[a-zA-Z]*/bExistPlayerAfterLogout=$EXIST_PLAYER_AFTER_LOGOUT/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ENABLE_DEFENSE_OTHER_GUILD_PLAYER+x} ]]; then + echo "> Setting bEnableDefenseOtherGuildPlayer to $ENABLE_DEFENSE_OTHER_GUILD_PLAYER" + sed -E -i "s/bEnableDefenseOtherGuildPlayer=[a-zA-Z]*/bEnableDefenseOtherGuildPlayer=$ENABLE_DEFENSE_OTHER_GUILD_PLAYER/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${COOP_PLAYER_MAX_NUM+x} ]]; then + echo "> Setting CoopPlayerMaxNum to $COOP_PLAYER_MAX_NUM" + sed -E -i "s/CoopPlayerMaxNum=[0-9]*/CoopPlayerMaxNum=$COOP_PLAYER_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${MAX_PLAYERS+x} ]]; then + echo "> Setting max-players to $MAX_PLAYERS" + sed -E -i "s/ServerPlayerMaxNum=[0-9]*/ServerPlayerMaxNum=$MAX_PLAYERS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${SERVER_NAME+x} ]]; then + echo "> Setting server name to $SERVER_NAME" + sed -E -i "s/ServerName=\"[^\"]*\"/ServerName=\"$SERVER_NAME\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + if [[ "$SERVER_NAME" == *"###RANDOM###"* ]]; then + RAND_VALUE=$RANDOM + echo "> Found standard template, using random numbers in server name" + sed -E -i -e "s/###RANDOM###/$RAND_VALUE/g" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + echo "> Server name is now jammsen-docker-generated-$RAND_VALUE" + fi + fi + if [[ ! -z ${SERVER_DESCRIPTION+x} ]]; then + echo "> Setting server description to $SERVER_DESCRIPTION" + sed -E -i "s/ServerDescription=\"[^\"]*\"/ServerDescription=\"$SERVER_DESCRIPTION\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${ADMIN_PASSWORD+x} ]]; then + echo "> Setting server admin password to $ADMIN_PASSWORD" + sed -E -i "s/AdminPassword=\"[^\"]*\"/AdminPassword=\"$ADMIN_PASSWORD\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${SERVER_PASSWORD+x} ]]; then + echo "> Setting server password to $SERVER_PASSWORD" + sed -E -i "s/ServerPassword=\"[^\"]*\"/ServerPassword=\"$SERVER_PASSWORD\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PUBLIC_PORT+x} ]]; then + echo "> Setting public port to $PUBLIC_PORT" + sed -E -i "s/PublicPort=[0-9]*/PublicPort=$PUBLIC_PORT/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${PUBLIC_IP+x} ]]; then + echo "> Setting public ip to $PUBLIC_IP" + sed -E -i "s/PublicIP=\"[^\"]*\"/PublicIP=\"$PUBLIC_IP\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${RCON_ENABLED+x} ]]; then + echo "> Setting rcon-enabled to $RCON_ENABLED" + sed -E -i "s/RCONEnabled=[a-zA-Z]*/RCONEnabled=$RCON_ENABLED/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + echo "> Because rcon is enabled, setting rcon.yml config file" + sed -i "s/###RCON_PORT###/$RCON_PORT/" ~/steamcmd/rcon.yaml + sed -i "s/###ADMIN_PASSWORD###/$ADMIN_PASSWORD/" ~/steamcmd/rcon.yaml + fi + if [[ ! -z ${RCON_PORT+x} ]]; then + echo "> Setting RCONPort to $RCON_PORT" + sed -E -i "s/RCONPort=[0-9]*/RCONPort=$RCON_PORT/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${REGION+x} ]]; then + echo "> Setting Region to $REGION" + sed -E -i "s/Region=\"[^\"]*\"/Region=\"$REGION\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${USEAUTH+x} ]]; then + echo "> Setting bUseAuth to $USEAUTH" + sed -E -i "s/bUseAuth=[a-zA-Z]*/bUseAuth=$USEAUTH/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + if [[ ! -z ${BAN_LIST_URL+x} ]]; then + echo "> Setting BanListURL to $BAN_LIST_URL" + sed -E -i "s~BanListURL=\"[^\"]*\"~BanListURL=\"$BAN_LIST_URL\"~" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini + fi + else + echo "> SERVER_SETTINGS_MODE is set to manual, NOT using environment variables to configure the server!" + echo "> File ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini has to be manually set by user" + fi + echo ">>> Finished setting up PalWorldSettings.ini ..." +} \ No newline at end of file diff --git a/includes/cron.sh b/includes/cron.sh new file mode 100644 index 0000000..c086dc8 --- /dev/null +++ b/includes/cron.sh @@ -0,0 +1,8 @@ +# Function to start supercronic and load crons from cronlist +function setup_crons() { + touch cronlist + if [[ -n $BACKUP_ENABLED ]] && [[ $BACKUP_ENABLED == "true" ]]; then + echo "$BACKUP_CRON_EXPRESSION /backupmanager.sh" >> cronlist + fi + /usr/local/bin/supercronic cronlist & +} diff --git a/includes/install.sh b/includes/install.sh new file mode 100644 index 0000000..a5f9573 --- /dev/null +++ b/includes/install.sh @@ -0,0 +1,27 @@ +# Function to install the gameserver +function install_server() { + # force a fresh install of all + echo ">>> Doing a fresh install of the gameserver" + if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then + send_webhook_notification "Installing server" "Server is beeing installed" "$WEBHOOK_INFO_COLOR" + fi + /home/steam/steamcmd/steamcmd.sh +force_install_dir "$GAME_PATH" +login anonymous +app_update 2394010 validate +quit +} + +# Function to update the gameserver +function update_server() { + # force an update and validation + if [[ -n $STEAMCMD_VALIDATE_FILES ]] && [[ $STEAMCMD_VALIDATE_FILES == "true" ]]; then + echo ">>> Doing an update and validate of the gameserver files" + if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then + send_webhook_notification "Updating server" "Server is beeing updated and validated" "$WEBHOOK_INFO_COLOR" + fi + /home/steam/steamcmd/steamcmd.sh +force_install_dir "$GAME_PATH" +login anonymous +app_update 2394010 validate +quit + else + echo ">>> Doing an update of the gameserver files" + if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then + send_webhook_notification "Updating server" "Server is beeing updated" "$WEBHOOK_INFO_COLOR" + fi + /home/steam/steamcmd/steamcmd.sh +force_install_dir "$GAME_PATH" +login anonymous +app_update 2394010 +quit + fi +} \ No newline at end of file diff --git a/includes/rcon.sh b/includes/rcon.sh new file mode 100644 index 0000000..e69de29 diff --git a/includes/security.sh b/includes/security.sh new file mode 100644 index 0000000..2c86d83 --- /dev/null +++ b/includes/security.sh @@ -0,0 +1,12 @@ +# Function to check if the default passwords are replaced +function check_for_default_credentials() { + echo ">>> Checking for existence of default credentials" + if [[ -n $ADMIN_PASSWORD ]] && [[ $ADMIN_PASSWORD == "adminPasswordHere" ]]; then + echo ">>> Error: Security thread detected: Please change the default admin password. Aborting server start ..." + exit 1 + fi + if [[ -n $SERVER_PASSWORD ]] && [[ $SERVER_PASSWORD == "serverPasswordHere" ]]; then + echo ">>> Error: Security thread detected: Please change the default server password. Aborting server start ..." + exit 1 + fi +} diff --git a/includes/webhook.sh b/includes/webhook.sh new file mode 100644 index 0000000..a51038c --- /dev/null +++ b/includes/webhook.sh @@ -0,0 +1,28 @@ +# Function to generate JSON data for the Discord message +# Webpage for COLOR-Calculation - https://www.spycolor.com/ +# IMPORTANT: Dont use Hex-Colors! Go to the page search for the Hex-Color. +# After that add the DECIMAL-Represenetation to the color field or it will break! +generate_post_data() { + cat <>> Doing a fresh install of the gameserver" - /home/steam/steamcmd/steamcmd.sh +force_install_dir "$GAME_PATH" +login anonymous +app_update 2394010 validate +quit -} - -function updateServer() { - # force an update and validation - if [[ -n $STEAMCMD_VALIDATE_FILES ]] && [[ $STEAMCMD_VALIDATE_FILES == "true" ]]; then - echo ">>> Doing an update and validate of the gameserver files" - /home/steam/steamcmd/steamcmd.sh +force_install_dir "$GAME_PATH" +login anonymous +app_update 2394010 validate +quit - else - echo ">>> Doing an update of the gameserver files" - /home/steam/steamcmd/steamcmd.sh +force_install_dir "$GAME_PATH" +login anonymous +app_update 2394010 +quit - fi -} - -function setupEngineIni() { - - echo ">>> Setting up Engine.ini ..." - if [[ -n $SERVER_SETTINGS_MODE ]] && [[ $SERVER_SETTINGS_MODE == "auto" ]]; then - echo "> SERVER_SETTINGS_MODE is set to auto, using environment variables to configure the server!" - - config_file="${GAME_PATH}/Pal/Saved/Config/LinuxServer/Engine.ini" - pattern1="OnlineSubsystemUtils.IpNetDriver" - pattern2="^NetServerMaxTickRate=[0-9]*" - - if grep -qE "$pattern1" "$config_file"; then - echo ">Found [/Script/OnlineSubsystemUtils.IpNetDriver] section" - else - echo ">Found no [/Script/OnlineSubsystemUtils.IpNetDriver], adding it" - echo -e "\n[/Script/OnlineSubsystemUtils.IpNetDriver]" >> "$config_file" - fi - if grep -qE "$pattern2" "$config_file"; then - echo ">Found NetServerMaxTickRate parameter, changing it to $NETSERVERMAXTICKRATE" - sed -E -i "s/$pattern2/NetServerMaxTickRate=$NETSERVERMAXTICKRATE/" "$config_file" - else - echo ">Found no NetServerMaxTickRate parameter, adding it to $NETSERVERMAXTICKRATE" - echo "NetServerMaxTickRate=$NETSERVERMAXTICKRATE" >> "$config_file" - fi - else - echo "> SERVER_SETTINGS_MODE is set to manual, NOT using environment variables to configure the server!" - echo "> File ${GAME_PATH}/Pal/Saved/Config/LinuxServer/Engine.ini has to be manually set by user" - fi - echo ">>> Finished setting up Engine.ini ..." -} - -function setupPalWorldSettingsIni() { - # setup the server config file - echo ">>> Setting up PalWorldSettings.ini ..." - echo "> Checking if config already exists" - if [ ! -f ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini ]; then - echo "> No config found, generating one" - if [ ! -d ${GAME_PATH}/Pal/Saved/Config/LinuxServer ]; then - mkdir -p ${GAME_PATH}/Pal/Saved/Config/LinuxServer - fi - # Copy default-config, which comes with the server to gameserver-save location - cp ${GAME_PATH}/DefaultPalWorldSettings.ini ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - else - echo "> Found existing config" - fi - - if [[ -n $SERVER_SETTINGS_MODE ]] && [[ $SERVER_SETTINGS_MODE == "auto" ]]; then - echo "> SERVER_SETTINGS_MODE is set to auto, using environment variables to configure the server!" - if [[ ! -z ${DIFFICULTY+x} ]]; then - echo "> Setting Difficulty to $DIFFICULTY" - sed -E -i "s/Difficulty=[a-zA-Z]*/Difficulty=$DIFFICULTY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${DAYTIME_SPEEDRATE+x} ]]; then - echo "> Setting DayTimeSpeedRate to $DAYTIME_SPEEDRATE" - sed -E -i "s/DayTimeSpeedRate=[+-]?([0-9]*[.])?[0-9]+/DayTimeSpeedRate=$DAYTIME_SPEEDRATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${NIGHTTIME_SPEEDRATE+x} ]]; then - echo "> Setting NightTimeSpeedRate to $NIGHTTIME_SPEEDRATE" - sed -E -i "s/NightTimeSpeedRate=[+-]?([0-9]*[.])?[0-9]+/NightTimeSpeedRate=$NIGHTTIME_SPEEDRATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${EXP_RATE+x} ]]; then - echo "> Setting ExpRate to $EXP_RATE" - sed -E -i "s/ExpRate=[+-]?([0-9]*[.])?[0-9]+/ExpRate=$EXP_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_CAPTURE_RATE+x} ]]; then - echo "> Setting PalCaptureRate to $PAL_CAPTURE_RATE" - sed -E -i "s/PalCaptureRate=[+-]?([0-9]*[.])?[0-9]+/PalCaptureRate=$PAL_CAPTURE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_SPAWN_NUM_RATE+x} ]]; then - echo "> Setting PalSpawnNumRate to $PAL_SPAWN_NUM_RATE" - sed -E -i "s/PalSpawnNumRate=[+-]?([0-9]*[.])?[0-9]+/PalSpawnNumRate=$PAL_SPAWN_NUM_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_DAMAGE_RATE_ATTACK+x} ]]; then - echo "> Setting PalDamageRateAttack to $PAL_DAMAGE_RATE_ATTACK" - sed -E -i "s/PalDamageRateAttack=[+-]?([0-9]*[.])?[0-9]+/PalDamageRateAttack=$PAL_DAMAGE_RATE_ATTACK/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_DAMAGE_RATE_DEFENSE+x} ]]; then - echo "> Setting PalDamageRateDefense to $PAL_DAMAGE_RATE_DEFENSE" - sed -E -i "s/PalDamageRateDefense=[+-]?([0-9]*[.])?[0-9]+/PalDamageRateDefense=$PAL_DAMAGE_RATE_DEFENSE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PLAYER_DAMAGE_RATE_ATTACK+x} ]]; then - echo "> Setting PlayerDamageRateAttack to $PLAYER_DAMAGE_RATE_ATTACK" - sed -E -i "s/PlayerDamageRateAttack=[+-]?([0-9]*[.])?[0-9]+/PlayerDamageRateAttack=$PLAYER_DAMAGE_RATE_ATTACK/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PLAYER_DAMAGE_RATE_DEFENSE+x} ]]; then - echo "> Setting PlayerDamageRateDefense to $PLAYER_DAMAGE_RATE_DEFENSE" - sed -E -i "s/PlayerDamageRateDefense=[+-]?([0-9]*[.])?[0-9]+/PlayerDamageRateDefense=$PLAYER_DAMAGE_RATE_DEFENSE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PLAYER_STOMACH_DECREASE_RATE+x} ]]; then - echo "> Setting PlayerStomachDecreaceRate to $PLAYER_STOMACH_DECREASE_RATE" - sed -E -i "s/PlayerStomachDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PlayerStomachDecreaceRate=$PLAYER_STOMACH_DECREASE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PLAYER_STAMINA_DECREACE_RATE+x} ]]; then - echo "> Setting PlayerStaminaDecreaceRate to $PLAYER_STAMINA_DECREACE_RATE" - sed -E -i "s/PlayerStaminaDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PlayerStaminaDecreaceRate=$PLAYER_STAMINA_DECREACE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PLAYER_AUTO_HP_REGENE_RATE+x} ]]; then - echo "> Setting PlayerAutoHPRegeneRate to $PLAYER_AUTO_HP_REGENE_RATE" - sed -E -i "s/PlayerAutoHPRegeneRate=[+-]?([0-9]*[.])?[0-9]+/PlayerAutoHPRegeneRate=$PLAYER_AUTO_HP_REGENE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP+x} ]]; then - echo "> Setting PlayerAutoHpRegeneRateInSleep to $PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP" - sed -E -i "s/PlayerAutoHpRegeneRateInSleep=[+-]?([0-9]*[.])?[0-9]+/PlayerAutoHpRegeneRateInSleep=$PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_STOMACH_DECREACE_RATE+x} ]]; then - echo "> Setting PalStomachDecreaceRate to $PAL_STOMACH_DECREACE_RATE" - sed -E -i "s/PalStomachDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PalStomachDecreaceRate=$PAL_STOMACH_DECREACE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_STAMINA_DECREACE_RATE+x} ]]; then - echo "> Setting PalStaminaDecreaceRate to $X" - sed -E -i "s/PalStaminaDecreaceRate=[+-]?([0-9]*[.])?[0-9]+/PalStaminaDecreaceRate=$PAL_STAMINA_DECREACE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_AUTO_HP_REGENE_RATE+x} ]]; then - echo "> Setting PalAutoHPRegeneRate to $PAL_AUTO_HP_REGENE_RATE" - sed -E -i "s/PalAutoHPRegeneRate=[+-]?([0-9]*[.])?[0-9]+/PalAutoHPRegeneRate=$PAL_AUTO_HP_REGENE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_AUTO_HP_REGENE_RATE_IN_SLEEP+x} ]]; then - echo "> Setting PalAutoHpRegeneRateInSleep to $PAL_AUTO_HP_REGENE_RATE_IN_SLEEP" - sed -E -i "s/PalAutoHpRegeneRateInSleep=[+-]?([0-9]*[.])?[0-9]+/PalAutoHpRegeneRateInSleep=$PAL_AUTO_HP_REGENE_RATE_IN_SLEEP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${BUILD_OBJECT_DAMAGE_RATE+x} ]]; then - echo "> Setting BuildObjectDamageRate to $BUILD_OBJECT_DAMAGE_RATE" - sed -E -i "s/BuildObjectDamageRate=[+-]?([0-9]*[.])?[0-9]+/BuildObjectDamageRate=$BUILD_OBJECT_DAMAGE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${BUILD_OBJECT_DETERIORATION_DAMAGE_RATE+x} ]]; then - echo "> Setting BuildObjectDeteriorationDamageRate to $BUILD_OBJECT_DETERIORATION_DAMAGE_RATE" - sed -E -i "s/BuildObjectDeteriorationDamageRate=[+-]?([0-9]*[.])?[0-9]+/BuildObjectDeteriorationDamageRate=$BUILD_OBJECT_DETERIORATION_DAMAGE_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${COLLECTION_DROP_RATE+x} ]]; then - echo "> Setting CollectionDropRate to $COLLECTION_DROP_RATE" - sed -E -i "s/CollectionDropRate=[+-]?([0-9]*[.])?[0-9]+/CollectionDropRate=$COLLECTION_DROP_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${COLLECTION_OBJECT_HP_RATE+x} ]]; then - echo "> Setting CollectionObjectHpRate to $COLLECTION_OBJECT_HP_RATE" - sed -E -i "s/CollectionObjectHpRate=[+-]?([0-9]*[.])?[0-9]+/CollectionObjectHpRate=$COLLECTION_OBJECT_HP_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${COLLECTION_OBJECT_RESPAWN_SPEED_RATE+x} ]]; then - echo "> Setting CollectionObjectRespawnSpeedRate to $COLLECTION_OBJECT_RESPAWN_SPEED_RATE" - sed -E -i "s/CollectionObjectRespawnSpeedRate=[+-]?([0-9]*[.])?[0-9]+/CollectionObjectRespawnSpeedRate=$COLLECTION_OBJECT_RESPAWN_SPEED_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENEMY_DROP_ITEM_RATE+x} ]]; then - echo "> Setting EnemyDropItemRate to $ENEMY_DROP_ITEM_RATE" - sed -E -i "s/EnemyDropItemRate=[+-]?([0-9]*[.])?[0-9]+/EnemyDropItemRate=$ENEMY_DROP_ITEM_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${DEATH_PENALTY+x} ]]; then - echo "> Setting DeathPenalty to $DEATH_PENALTY" - sed -E -i "s/DeathPenalty=[a-zA-Z]*/DeathPenalty=$DEATH_PENALTY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_PLAYER_TO_PLAYER_DAMAGE+x} ]]; then - echo "> Setting bEnablePlayerToPlayerDamage to $ENABLE_PLAYER_TO_PLAYER_DAMAGE" - sed -E -i "s/bEnablePlayerToPlayerDamage=[a-zA-Z]*/bEnablePlayerToPlayerDamage=$ENABLE_PLAYER_TO_PLAYER_DAMAGE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_FRIENDLY_FIRE+x} ]]; then - echo "> Setting bEnableFriendlyFire to $ENABLE_FRIENDLY_FIRE" - sed -E -i "s/bEnableFriendlyFire=[a-zA-Z]*/bEnableFriendlyFire=$ENABLE_FRIENDLY_FIRE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_INVADER_ENEMY+x} ]]; then - echo "> Setting bEnableInvaderEnemy to $ENABLE_INVADER_ENEMY" - sed -E -i "s/bEnableInvaderEnemy=[a-zA-Z]*/bEnableInvaderEnemy=$ENABLE_INVADER_ENEMY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ACTIVE_UNKO+x} ]]; then - echo "> Setting bActiveUNKO to $ACTIVE_UNKO" - sed -E -i "s/bActiveUNKO=[a-zA-Z]*/bActiveUNKO=$ACTIVE_UNKO/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_AIM_ASSIST_PAD+x} ]]; then - echo "> Setting bEnableAimAssistPad to $ENABLE_AIM_ASSIST_PAD" - sed -E -i "s/bEnableAimAssistPad=[a-zA-Z]*/bEnableAimAssistPad=$ENABLE_AIM_ASSIST_PAD/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_AIM_ASSIST_KEYBOARD+x} ]]; then - echo "> Setting bEnableAimAssistKeyboard to $ENABLE_AIM_ASSIST_KEYBOARD" - sed -E -i "s/bEnableAimAssistKeyboard=[a-zA-Z]*/bEnableAimAssistKeyboard=$ENABLE_AIM_ASSIST_KEYBOARD/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${DROP_ITEM_MAX_NUM+x} ]]; then - echo "> Setting DropItemMaxNum to $DROP_ITEM_MAX_NUM" - sed -E -i "s/DropItemMaxNum=[0-9]*/DropItemMaxNum=$DROP_ITEM_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${DROP_ITEM_MAX_NUM_UNKO+x} ]]; then - echo "> Setting DropItemMaxNum_UNKO to $DROP_ITEM_MAX_NUM_UNKO" - sed -E -i "s/DropItemMaxNum_UNKO=[0-9]*/DropItemMaxNum_UNKO=$DROP_ITEM_MAX_NUM_UNKO/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${BASE_CAMP_MAX_NUM+x} ]]; then - echo "> Setting BaseCampMaxNum to $BASE_CAMP_MAX_NUM" - sed -E -i "s/BaseCampMaxNum=[0-9]*/BaseCampMaxNum=$BASE_CAMP_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${BASE_CAMP_WORKER_MAXNUM+x} ]]; then - echo "> Setting BaseCampWorkerMaxNum to $BASE_CAMP_WORKER_MAXNUM" - sed -E -i "s/BaseCampWorkerMaxNum=[0-9]*/BaseCampWorkerMaxNum=$BASE_CAMP_WORKER_MAXNUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${DROP_ITEM_ALIVE_MAX_HOURS+x} ]]; then - echo "> Setting DropItemAliveMaxHours to $DROP_ITEM_ALIVE_MAX_HOURS" - sed -E -i "s/DropItemAliveMaxHours=[+-]?([0-9]*[.])?[0-9]+/DropItemAliveMaxHours=$DROP_ITEM_ALIVE_MAX_HOURS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${AUTO_RESET_GUILD_NO_ONLINE_PLAYERS+x} ]]; then - echo "> Setting bAutoResetGuildNoOnlinePlayers to $AUTO_RESET_GUILD_NO_ONLINE_PLAYERS" - sed -E -i "s/bAutoResetGuildNoOnlinePlayers=[a-zA-Z]*/bAutoResetGuildNoOnlinePlayers=$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS+x} ]]; then - echo "> Setting AutoResetGuildTimeNoOnlinePlayers to $AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS" - sed -E -i "s/AutoResetGuildTimeNoOnlinePlayers=[+-]?([0-9]*[.])?[0-9]+/AutoResetGuildTimeNoOnlinePlayers=$AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${GUILD_PLAYER_MAX_NUM+x} ]]; then - echo "> Setting GuildPlayerMaxNum to $GUILD_PLAYER_MAX_NUM" - sed -E -i "s/GuildPlayerMaxNum=[0-9]*/GuildPlayerMaxNum=$GUILD_PLAYER_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PAL_EGG_DEFAULT_HATCHING_TIME+x} ]]; then - echo "> Setting PalEggDefaultHatchingTime to $PAL_EGG_DEFAULT_HATCHING_TIME" - sed -E -i "s/PalEggDefaultHatchingTime=[+-]?([0-9]*[.])?[0-9]+/PalEggDefaultHatchingTime=$PAL_EGG_DEFAULT_HATCHING_TIME/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${WORK_SPEED_RATE+x} ]]; then - echo "> Setting WorkSpeedRate to $WORK_SPEED_RATE" - sed -E -i "s/WorkSpeedRate=[+-]?([0-9]*[.])?[0-9]+/WorkSpeedRate=$WORK_SPEED_RATE/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${IS_MULTIPLAY+x} ]]; then - echo "> Setting bIsMultiplay to $IS_MULTIPLAY" - sed -E -i "s/bIsMultiplay=[a-zA-Z]*/bIsMultiplay=$IS_MULTIPLAY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${IS_PVP+x} ]]; then - echo "> Setting bIsPvP to $IS_PVP" - sed -E -i "s/bIsPvP=[a-zA-Z]*/bIsPvP=$IS_PVP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP+x} ]]; then - echo "> Setting bCanPickupOtherGuildDeathPenaltyDrop to $CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP" - sed -E -i "s/bCanPickupOtherGuildDeathPenaltyDrop=[a-zA-Z]*/bCanPickupOtherGuildDeathPenaltyDrop=$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_NON_LOGIN_PENALTY+x} ]]; then - echo "> Setting bEnableNonLoginPenalty to $ENABLE_NON_LOGIN_PENALTY" - sed -E -i "s/bEnableNonLoginPenalty=[a-zA-Z]*/bEnableNonLoginPenalty=$ENABLE_NON_LOGIN_PENALTY/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_FAST_TRAVEL+x} ]]; then - echo "> Setting bEnableFastTravel to $ENABLE_FAST_TRAVEL" - sed -E -i "s/bEnableFastTravel=[a-zA-Z]*/bEnableFastTravel=$ENABLE_FAST_TRAVEL/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${IS_START_LOCATION_SELECT_BY_MAP+x} ]]; then - echo "> Setting bIsStartLocationSelectByMap to $IS_START_LOCATION_SELECT_BY_MAP" - sed -E -i "s/bIsStartLocationSelectByMap=[a-zA-Z]*/bIsStartLocationSelectByMap=$IS_START_LOCATION_SELECT_BY_MAP/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${EXIST_PLAYER_AFTER_LOGOUT+x} ]]; then - echo "> Setting bExistPlayerAfterLogout to $EXIST_PLAYER_AFTER_LOGOUT" - sed -E -i "s/bExistPlayerAfterLogout=[a-zA-Z]*/bExistPlayerAfterLogout=$EXIST_PLAYER_AFTER_LOGOUT/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ENABLE_DEFENSE_OTHER_GUILD_PLAYER+x} ]]; then - echo "> Setting bEnableDefenseOtherGuildPlayer to $ENABLE_DEFENSE_OTHER_GUILD_PLAYER" - sed -E -i "s/bEnableDefenseOtherGuildPlayer=[a-zA-Z]*/bEnableDefenseOtherGuildPlayer=$ENABLE_DEFENSE_OTHER_GUILD_PLAYER/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${COOP_PLAYER_MAX_NUM+x} ]]; then - echo "> Setting CoopPlayerMaxNum to $COOP_PLAYER_MAX_NUM" - sed -E -i "s/CoopPlayerMaxNum=[0-9]*/CoopPlayerMaxNum=$COOP_PLAYER_MAX_NUM/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${MAX_PLAYERS+x} ]]; then - echo "> Setting max-players to $MAX_PLAYERS" - sed -E -i "s/ServerPlayerMaxNum=[0-9]*/ServerPlayerMaxNum=$MAX_PLAYERS/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${SERVER_NAME+x} ]]; then - echo "> Setting server name to $SERVER_NAME" - sed -E -i "s/ServerName=\"[^\"]*\"/ServerName=\"$SERVER_NAME\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - if [[ "$SERVER_NAME" == *"###RANDOM###"* ]]; then - RAND_VALUE=$RANDOM - echo "> Found standard template, using random numbers in server name" - sed -E -i -e "s/###RANDOM###/$RAND_VALUE/g" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - echo "> Server name is now jammsen-docker-generated-$RAND_VALUE" - fi - fi - if [[ ! -z ${SERVER_DESCRIPTION+x} ]]; then - echo "> Setting server description to $SERVER_DESCRIPTION" - sed -E -i "s/ServerDescription=\"[^\"]*\"/ServerDescription=\"$SERVER_DESCRIPTION\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${ADMIN_PASSWORD+x} ]]; then - echo "> Setting server admin password to $ADMIN_PASSWORD" - sed -E -i "s/AdminPassword=\"[^\"]*\"/AdminPassword=\"$ADMIN_PASSWORD\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${SERVER_PASSWORD+x} ]]; then - echo "> Setting server password to $SERVER_PASSWORD" - sed -E -i "s/ServerPassword=\"[^\"]*\"/ServerPassword=\"$SERVER_PASSWORD\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PUBLIC_PORT+x} ]]; then - echo "> Setting public port to $PUBLIC_PORT" - sed -E -i "s/PublicPort=[0-9]*/PublicPort=$PUBLIC_PORT/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${PUBLIC_IP+x} ]]; then - echo "> Setting public ip to $PUBLIC_IP" - sed -E -i "s/PublicIP=\"[^\"]*\"/PublicIP=\"$PUBLIC_IP\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${RCON_ENABLED+x} ]]; then - echo "> Setting rcon-enabled to $RCON_ENABLED" - sed -E -i "s/RCONEnabled=[a-zA-Z]*/RCONEnabled=$RCON_ENABLED/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - echo "> Because rcon is enabled, setting rcon.yml config file" - sed -i "s/###RCON_PORT###/$RCON_PORT/" ~/steamcmd/rcon.yaml - sed -i "s/###ADMIN_PASSWORD###/$ADMIN_PASSWORD/" ~/steamcmd/rcon.yaml - fi - if [[ ! -z ${RCON_PORT+x} ]]; then - echo "> Setting RCONPort to $RCON_PORT" - sed -E -i "s/RCONPort=[0-9]*/RCONPort=$RCON_PORT/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${REGION+x} ]]; then - echo "> Setting Region to $REGION" - sed -E -i "s/Region=\"[^\"]*\"/Region=\"$REGION\"/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${USEAUTH+x} ]]; then - echo "> Setting bUseAuth to $USEAUTH" - sed -E -i "s/bUseAuth=[a-zA-Z]*/bUseAuth=$USEAUTH/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - if [[ ! -z ${BAN_LIST_URL+x} ]]; then - echo "> Setting BanListURL to $BAN_LIST_URL" - sed -E -i "s~BanListURL=\"[^\"]*\"~BanListURL=\"$BAN_LIST_URL\"~" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini - fi - else - echo "> SERVER_SETTINGS_MODE is set to manual, NOT using environment variables to configure the server!" - echo "> File ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini has to be manually set by user" - fi - echo ">>> Finished setting up PalWorldSettings.ini ..." - -} - -function startServer() { +function start_server() { # IF Bash extension used: # https://stackoverflow.com/a/13864829 # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 @@ -342,8 +18,8 @@ function startServer() { echo ">>> Starting the gameserver" cd $GAME_PATH - setupEngineIni - setupPalWorldSettingsIni + setup_engine_ini + setup_pal_world_settings_ini START_OPTIONS="" if [[ -n $COMMUNITY_SERVER ]] && [[ $COMMUNITY_SERVER == "true" ]]; then @@ -354,40 +30,23 @@ function startServer() { echo "> Setting Multi-Core-Enchancements to enabled" START_OPTIONS="$START_OPTIONS -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS" fi - ./PalServer.sh "$START_OPTIONS" -} - -function checkForDefaultCredentials() { - echo ">>> Checking for existence of default credentials" - if [[ -n $ADMIN_PASSWORD ]] && [[ $ADMIN_PASSWORD == "adminPasswordHere" ]]; then - echo ">>> Error: Security thread detected: Please change the default admin password. Aborting server start ..." - exit 1 + if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then + send_webhook_notification "$WEBHOOK_START_TITLE" "$WEBHOOK_START_DESCRIPTION" "$WEBHOOK_START_COLOR" fi - if [[ -n $SERVER_PASSWORD ]] && [[ $SERVER_PASSWORD == "serverPasswordHere" ]]; then - echo ">>> Error: Security thread detected: Please change the default server password. Aborting server start ..." - exit 1 - fi -} - -function setupCrons() { - touch cronlist - if [[ -n $BACKUP_ENABLED ]] && [[ $BACKUP_ENABLED == "true" ]]; then - echo "$BACKUP_CRON_EXPRESSION /backupmanager.sh" >> cronlist - fi - /usr/local/bin/supercronic cronlist & + ./PalServer.sh "$START_OPTIONS" } -function startMain() { - checkForDefaultCredentials - setupCrons +function start_main() { + check_for_default_credentials + setup_crons # Check if server is installed, if not try again if [ ! -f "$GAME_PATH/PalServer.sh" ]; then - installServer + install_server fi if [ $ALWAYS_UPDATE_ON_START == "true" ]; then - updateServer + update_server fi - startServer + start_server } term_handler() { @@ -400,15 +59,18 @@ term_handler() { fi kill -SIGTERM $(pidof PalServer-Linux-Test) tail --pid=$(pidof PalServer-Linux-Test) -f 2>/dev/null + if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then + send_webhook_notification "$WEBHOOK_STOP_TITLE" "$WEBHOOK_STOP_DESCRIPTION" "$WEBHOOK_STOP_COLOR" + fi exit 143; } trap 'kill ${!}; term_handler' SIGTERM -startMain & +start_main & killpid="$!" while true do - wait $killpid - exit 0; + wait $killpid + exit 0; done From c306d1c83cd2d94826731bcd57050aff7e547b3d Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com> Date: Wed, 31 Jan 2024 17:40:09 +0100 Subject: [PATCH 3/3] #120 added documentation about webhook-integration --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 713a752..b62f6eb 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,15 @@ ___ - [Environment variables](#environment-variables) - [Docker-Compose examples](#docker-compose-examples) - [Gameserver with RCON-CLI-Tool](#gameserver-with-rcon-cli-tool) - - [Run RCON commands](#run-rcon-commands) + - [Run RCON commands](#run-rcon-commands) + - [Webhook integration](#webhook-integration) + - [Supported events](#supported-events) - [FAQ](#faq) - [How can I use the interactive console in Portainer with this image?](#how-can-i-use-the-interactive-console-in-portainer-with-this-image) - [How can I look into the config of my Palworld container?](#how-can-i-look-into-the-config-of-my-palworld-container) - [Im seeing S\_API errors in my logs when I start the container?](#im-seeing-s_api-errors-in-my-logs-when-i-start-the-container) - [Im using Apple silicon type of hardware, can I run this?](#im-using-apple-silicon-type-of-hardware-can-i-run-this) - - [I have changed the BaseCampWorkerMaxNum settings, why are changes un-affected on the server?](#i-have-changed-the-basecampworkermaxnum-settings-why-are-changes-un-affected-on-the-server) + - [I have changed the `BaseCampWorkerMaxNum` settings, why are changes un-affected on the server?](#i-have-changed-the-basecampworkermaxnum-settings-why-are-changes-un-affected-on-the-server) - [Planned features in the future](#planned-features-in-the-future) - [Software used](#software-used) @@ -80,14 +82,13 @@ To run this Docker image, you need a basic understanding of Docker, Docker-Compo See [this file](README_ENV.md) for the documentation - ## Docker-Compose examples ### Gameserver with RCON-CLI-Tool See [example docker-compose.yml](docker-compose.yml). -#### Run RCON commands +## Run RCON commands Open a shell into your container via `docker exec -ti palworld-dedicated-server bash`, then you can run commands against the gameserver via the command `rcon` or `rconcli` ```shell @@ -100,6 +101,20 @@ Complete Save ``` > **Important:** Please research the RCON-Commands on the official source: https://tech.palworldgame.com/server-commands +## Webhook integration + +To enable webhook integration, you need to set the following environment variables in the `default.env`: + +```shell +WEBHOOK_ENABLED=true +WEBHOOK_URL="https://your.webhook.url" +``` +After that the server should send messages in a Discord-Compatible way to your webhook. + +### Supported events +* Server starting +* Server stopped + ## FAQ ### How can I use the interactive console in Portainer with this image?