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

Release 2024-02-24.1 #232

Merged
merged 4 commits into from
Feb 24, 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

[Back to main](README.md#changelog)

## 2024-02-24

- Added new mechanic for auto-restart, where the player count will be checked, 15 minutes grace-period (for dungeons, boss-fights, etc.) will only used if a player is online, if not the restart will be initiated (#230)
- Renamed/extended webhook messages accordingly

## 2024-02-23

- Added new SERVER_SETTINGS_MODE called "rcononly" this will only setup up RCON, everything else is still manually to set (#221)
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ ENV DEBIAN_FRONTEND=noninteractive \
WEBHOOK_INSTALL_TITLE="Installing server" \
WEBHOOK_INSTALL_DESCRIPTION="Server is being installed" \
WEBHOOK_INSTALL_COLOR="2849520" \
WEBHOOK_RESTART_TITLE="Server is restarting soon" \
WEBHOOK_RESTART_DESCRIPTION="The gameserver is restarting in 15 minutes" \
WEBHOOK_RESTART_TITLE="Automatic restart" \
WEBHOOK_RESTART_DELAYED_DESCRIPTION="The automatic gameserver restart has been triggered, if the server has still players, restart will be in 15 minutes" \
WEBHOOK_RESTART_NOW_DESCRIPTION="The gameserver is empty, restarting now" \
WEBHOOK_RESTART_COLOR="15593515" \
WEBHOOK_START_TITLE="Server is starting" \
WEBHOOK_START_DESCRIPTION="The gameserver is starting" \
Expand Down
5 changes: 5 additions & 0 deletions includes/playerdetection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ compare_players() {

for player_info in "${current_players[@]}"; do
# Extract player name, UID, and Steam ID from player info
# This part sets the Internal Field Separator (IFS) variable to ','.
# In Bash, the IFS variable determines how Bash recognizes word boundaries.
# By default, it includes space, tab, and newline characters.
# By setting it to ',', we're telling Bash to split input lines at commas.
# https://tldp.org/LDP/abs/html/internalvariables.html#IFSREF
IFS=',' read -r -a player_data <<< "$player_info"
local steamid="${player_data[-1]}"
local playeruid="${player_data[-2]}"
Expand Down
10 changes: 9 additions & 1 deletion includes/rcon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function broadcast_automatic_restart() {
rcon "Shutdown 10"
}


function broadcast_backup_start() {
time=$(date '+%H:%M:%S')

Expand Down Expand Up @@ -53,4 +52,13 @@ function broadcast_player_name_change() {
function broadcast_player_leave() {
time=$(date '+%H:%M:%S')
rconcli "broadcast ${time}-$1-left-the-server"
}

function check_is_server_empty() {
num_players=$(rcon -c "$RCON_CONFIG_FILE" showplayers | tail -n +2 | wc -l)
if [ "$num_players" -eq 0 ]; then
return 0 # Server empty
else
return 1 # Server not empty
fi
}
7 changes: 5 additions & 2 deletions includes/webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ send_webhook_notification() {
send_install_notification() {
send_webhook_notification "$WEBHOOK_INSTALL_TITLE" "$WEBHOOK_INSTALL_DESCRIPTION" "$WEBHOOK_INSTALL_COLOR"
}
send_restart_notification() {
send_webhook_notification "$WEBHOOK_RESTART_TITLE" "$WEBHOOK_RESTART_DESCRIPTION" "$WEBHOOK_RESTART_COLOR"
send_restart_planned_notification() {
send_webhook_notification "$WEBHOOK_RESTART_TITLE" "$WEBHOOK_RESTART_DELAYED_DESCRIPTION" "$WEBHOOK_RESTART_COLOR"
}
send_restart_now_notification() {
send_webhook_notification "$WEBHOOK_RESTART_TITLE" "$WEBHOOK_RESTART_NOW_DESCRIPTION" "$WEBHOOK_RESTART_COLOR"
}
send_start_notification() {
send_webhook_notification "$WEBHOOK_START_TITLE" "$WEBHOOK_START_DESCRIPTION" "$WEBHOOK_START_COLOR"
Expand Down
12 changes: 11 additions & 1 deletion scripts/restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ source /includes/server.sh
source /includes/webhook.sh

function schedule_restart() {
ew ">>> Automatic restart was triggered..."
PLAYER_DETECTION_PID=$(<PLAYER_DETECTION.PID)
if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then
send_restart_notification
send_restart_planned_notification
fi

for ((counter=15; counter>=1; counter--)); do
if [[ -n $RCON_ENABLED ]] && [[ $RCON_ENABLED == "true" ]]; then
if check_is_server_empty; then
ew ">>> Server is empty, restarting now"
if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then
send_restart_now_notification
fi
break
else
ew ">>> Server has still players"
fi
time=$(date '+%H:%M:%S')
rconcli "broadcast ${time}-AUTOMATIC-RESTART-IN-$counter-MINUTES"
fi
Expand Down