Skip to content

Commit

Permalink
fixed: auto update/reboot, broadcast/countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kimzuni committed Apr 30, 2024
1 parent 77cc8f4 commit 7f94a24
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 110 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ ENV TZ="UTC" \
AUTO_UPDATE_CRON_EXPRESSION="0 * * * *" \
AUTO_UPDATE_WARN_MINUTES=15 \
AUTO_UPDATE_WARN_MESSAGE="Server will update in remaining_time minutes." \
AUTO_UPDATE_WARN_REMAINING_TIMES="1 5 10" \
AUTO_REBOOT_ENABLED=false \
AUTO_REBOOT_CRON_EXPRESSION="0 0 * * *" \
AUTO_REBOOT_WARN_MINUTES=15 \
AUTO_REBOOT_WARN_MESSAGE="Server will reboot in remaining_time minutes." \
AUTO_REBOOT_WARN_REMAINING_TIMES="1 5 10" \
AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE=false \
BROADCAST_COUNTDOWN_MTIMES="1 5 10 15 30 60" \
BROADCAST_COUNTDOWN_SUSPEND_MESSAGE="Suspends countdown because there are no players." \
BROADCAST_COUNTDOWN_SUSPEND_MESSAGE_ENABLE=true \
TARGET_COMMIT_ID= \
DISCORD_WEBHOOK_URL="" \
DISCORD_SUPPRESS_NOTIFICATIONS=false \
Expand Down
171 changes: 88 additions & 83 deletions docs/en/README.md

Large diffs are not rendered by default.

44 changes: 24 additions & 20 deletions docs/kr/README.md

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions scripts/helper_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ shutdown_server() {
countdown_message() {
local mtime="$1"
local message="$2"
local remaining_times="$3"
local return_val=0

if [[ "${mtime}" =~ ^[0-9]+$ ]]; then
Expand All @@ -164,7 +165,7 @@ countdown_message() {
# Checking for players every minute
player_check || break

if [ "$mtime" -eq "$i" ] || [[ " $BROADCAST_COUNTDOWN_MTIMES " == *" $i "* ]]; then
if [ "$mtime" -eq "$i" ] || [[ " $remaining_times " == *" $i "* ]]; then
if [ "$i" -eq 1 ]; then
message="${message//minutes/minute}"
fi
Expand All @@ -177,7 +178,9 @@ countdown_message() {
if [ "$i" -eq 0 ]; then
sleep 1s
elif [ "$1" -ne "$mtime" ]; then
broadcast_command "${BROADCAST_COUNTDOWN_SUSPEND_MESSAGE}" "warn"
if [ "$BROADCAST_COUNTDOWN_SUSPEND_MESSAGE_ENABLE" = true ]; then
broadcast_command "${BROADCAST_COUNTDOWN_SUSPEND_MESSAGE}" "warn"
fi
fi
# If there are players but mtime is empty
elif [ -z "${mtime}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/reboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ "${AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE,,}" != true ]; then
fi
fi

countdown_message "${AUTO_REBOOT_WARN_MINUTES}" "${AUTO_REBOOT_WARN_MESSAGE}"
countdown_message "${AUTO_REBOOT_WARN_MINUTES}" "${AUTO_REBOOT_WARN_MESSAGE}" "${AUTO_UPDATE_WARN_REMAINING_TIMES}"
countdown_exit_code=$?
case "${countdown_exit_code}" in
0 )
Expand Down
3 changes: 1 addition & 2 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ fi
LogAction "Checking for available container updates"
container_version_check

LogAction "GENERATING CONFIG"
if [ "${DISABLE_GENERATE_SETTINGS,,}" = true ]; then
LogAction "GENERATING CONFIG"
LogWarn "Env vars will not be applied due to DISABLE_GENERATE_SETTINGS being set to TRUE!"
if [ ! -f "$CONFIG_FILE_FULL_PATH" ]; then
cp "$CONFIG_FILE_FULL_PATH".default "$CONFIG_FILE_FULL_PATH"
fi
else
LogAction "GENERATING CONFIG"
LogInfo "Using Env vars to create Game.ini"
/home/steam/server/compile-settings.sh || exit
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi

TARGET_COMMIT="${TARGET_COMMIT_ID:-$LATEST_COMMIT}"

countdown_message "${AUTO_UPDATE_WARN_MINUTES}" "${AUTO_UPDATE_WARN_MESSAGE}"
countdown_message "${AUTO_UPDATE_WARN_MINUTES}" "${AUTO_UPDATE_WARN_MESSAGE}" "${AUTO_UPDATE_WARN_REMAINING_TIMES}"
countdown_exit_code=$?
case "${countdown_exit_code}" in
0 )
Expand Down

0 comments on commit 7f94a24

Please sign in to comment.