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

Move countdown to function for auto update and auto reboot #392

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
019fe45
Fixed spacing
Dashboy1998 Feb 14, 2024
9d6b106
Added countdown loop
Dashboy1998 Feb 14, 2024
fd1a2de
Added validation for AUTO_UPDATE_WARN_MINUTES
Dashboy1998 Feb 14, 2024
595f0a3
Moved countdown to helper function and added seconds
Dashboy1998 Feb 16, 2024
ed56e0f
Removed/Added extra lines
Dashboy1998 Feb 16, 2024
98f9c1e
Update scripts/helper_functions.sh
Dashboy1998 Feb 16, 2024
2d34179
Update scripts/helper_functions.sh
Dashboy1998 Feb 16, 2024
22683fd
Implemented skip when empty, resolves #393
Dashboy1998 Feb 16, 2024
8bef267
Moved in_ to countdown message
Dashboy1998 Feb 16, 2024
5471fb4
Moved integer validation to countdown
Dashboy1998 Feb 16, 2024
58a611c
Fixed spacing in auto_reboot.sh
Dashboy1998 Feb 16, 2024
7e54379
Update auto_reboot so AUTO_REBOOT_WARN_MINUTES needs to only be valid…
Dashboy1998 Feb 16, 2024
b79edce
Split messages in update
Dashboy1998 Feb 16, 2024
80d4b1c
No longer creating update discord message if AUTO_UPDATE_WARN_MINUTES…
Dashboy1998 Feb 16, 2024
e73c9f2
Updated messages in update.sh
Dashboy1998 Feb 16, 2024
098818a
Updated messages in update and reboot
Dashboy1998 Feb 16, 2024
600313f
Merge branch 'main' into update-countdown
Dashboy1998 Feb 16, 2024
25450e2
Added save function
Dashboy1998 Feb 17, 2024
5fe4b8d
Added shutdown function
Dashboy1998 Feb 17, 2024
fa9735c
Added save to shutdown function
Dashboy1998 Feb 17, 2024
2c8dbf6
Changed mtime, message_prefix, return_val to local vars
Dashboy1998 Feb 17, 2024
396a9fb
Removed rcon-cli save/shutdown in init.sh
Dashboy1998 Feb 17, 2024
ace7b18
Fixed shutdown
Dashboy1998 Feb 17, 2024
5962579
Merge branch 'Add-save-and-shutdown-functions' into update-countdown
Dashboy1998 Feb 17, 2024
dc66c8b
Merge branch 'main' into update-countdown
Dashboy1998 Feb 17, 2024
53986bd
Removed echo in RCON
Dashboy1998 Feb 17, 2024
043af58
Fixed spacing
Dashboy1998 Feb 17, 2024
6e7751c
Moved RCON check to RCON function in all helper functions
Dashboy1998 Feb 17, 2024
624d9ee
Removed checking exit code in update.sh
Dashboy1998 Feb 17, 2024
a35af01
Fixed update.sh issues from merge
Dashboy1998 Feb 17, 2024
0847f7b
Changed if in update.sh
Dashboy1998 Feb 17, 2024
ca6b52f
Changed shutdown to DoExit, resolves #395
Dashboy1998 Feb 17, 2024
381d845
Updated structure of backup.sh
Dashboy1998 Feb 17, 2024
75021bd
Updated exit code in update.sh
Dashboy1998 Feb 17, 2024
9b075a0
Updated start.sh
Dashboy1998 Feb 17, 2024
18ddb66
Fixed spacing in init.sh
Dashboy1998 Feb 17, 2024
4da9a05
Merge branch 'main' into update-countdown
Dashboy1998 Feb 17, 2024
24e045b
Fixed merge issue
Dashboy1998 Feb 17, 2024
e3ae137
Fixed update/install in start
Dashboy1998 Feb 17, 2024
b089211
Added broadcast function. Partially Resolves #400
Dashboy1998 Feb 17, 2024
82536b4
Update scripts/start.sh
Dashboy1998 Feb 18, 2024
131638d
Changed exit codes for countdown_message
Dashboy1998 Feb 18, 2024
958a930
Moved player count check
Dashboy1998 Feb 18, 2024
1baeb04
Moved case when 1
Dashboy1998 Feb 18, 2024
27c1466
Added comment
Dashboy1998 Feb 18, 2024
3e38a6e
Reordered cases
Dashboy1998 Feb 18, 2024
9fb677c
Merge branch 'main' into update-countdown
Dashboy1998 Feb 18, 2024
5d72e7c
Merge branch 'main' into update-countdown
Dashboy1998 Feb 19, 2024
a718120
Checking if broadcast contains non-ascii characters.
Dashboy1998 Feb 19, 2024
408617b
Reverted spacing changes
Dashboy1998 Feb 19, 2024
43ca7a2
Added missing fi
Dashboy1998 Feb 19, 2024
acdf259
Moved source helper_install.sh out of helper_functions.sh
Dashboy1998 Feb 19, 2024
e58143e
Merge branch 'main' into update-countdown
Dashboy1998 Feb 19, 2024
f96ef24
Only broadcast valid messages
Dashboy1998 Feb 19, 2024
635d201
Fixed merge issue
Dashboy1998 Feb 19, 2024
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
6 changes: 1 addition & 5 deletions scripts/auto_reboot.sh
Dashboy1998 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ if [ "${RCON_ENABLED,,}" = true ]; then
if [ -z "${AUTO_REBOOT_WARN_MINUTES}" ]; then
echo "Unable to auto reboot, AUTO_REBOOT_WARN_MINUTES is empty."
elif [[ "${AUTO_REBOOT_WARN_MINUTES}" =~ ^[0-9]+$ ]]; then
for ((i = "${AUTO_REBOOT_WARN_MINUTES}" ; i > 0 ; i--)); do
rcon-cli -c /home/steam/server/rcon.yaml "broadcast The_Server_will_reboot_in_${i}_Minutes"
sleep "1m"
done

countdown_message "${AUTO_REBOOT_WARN_MINUTES}" "The_Server_will_reboot_in"
Dashboy1998 marked this conversation as resolved.
Show resolved Hide resolved
rcon-cli -c /home/steam/server/rcon.yaml save
rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1"
else
Expand Down
36 changes: 35 additions & 1 deletion scripts/helper_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,38 @@ get_player_count() {
fi
player_list=$(rcon-cli -c /home/steam/server/rcon.yaml "ShowPlayers")
echo -n "${player_list}" | wc -l
}
}

# Given an amount of time in minutes and a message prefix
countdown_message() {
mtime="$1"
message_prefix="$2"

for ((i = "${mtime}" ; i > 0 ; i--)); do
if [ "$i" -eq 1 ]; then
rcon-cli -c /home/steam/server/rcon.yaml "broadcast ${message_prefix}_${i}_minutue"
Dashboy1998 marked this conversation as resolved.
Show resolved Hide resolved
sleep 30s
rcon-cli -c /home/steam/server/rcon.yaml "broadcast ${message_prefix}_30_seconds"
sleep 20s
rcon-cli -c /home/steam/server/rcon.yaml "broadcast ${message_prefix}_10_seconds"
sleep 10s
else
case "$i" in
"$mtime" )
;&
15 )
;&
10 )
;&
5 )
;&
2 )
rcon-cli -c /home/steam/server/rcon.yaml "broadcast ${message_prefix}_${i}_minutues"
Dashboy1998 marked this conversation as resolved.
Show resolved Hide resolved
;&
* )
sleep 1m
;;
esac
fi
done
}
26 changes: 16 additions & 10 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,24 @@ if [ "$CURRENT_MANIFEST" != "$TARGET_MANIFEST" ]; then
fi
exit 0
fi
echo "New Build was found. Updating the server from $CURRENT_MANIFEST to $TARGET_MANIFEST."
rm /palworld/steamapps/appmanifest_2394010.acf

if [ "$(get_player_count)" -gt 0 ]; then
if [ -n "${DISCORD_WEBHOOK_URL}" ]; then
/home/steam/server/discord.sh "Server will update in ${AUTO_UPDATE_WARN_MINUTES} minutes" "info" &
if [ -z "${AUTO_UPDATE_WARN_MINUTES}" ]; then
echo "Unable to auto update, AUTO_UPDATE_WARN_MINUTES is empty."
elif [[ "${AUTO_UPDATE_WARN_MINUTES}" =~ ^[0-9]+$ ]]; then
echo "New Build was found. Updating the server from $CURRENT_MANIFEST to $TARGET_MANIFEST."
rm /palworld/steamapps/appmanifest_2394010.acf

if [ "$(get_player_count)" -gt 0 ]; then
if [ -n "${DISCORD_WEBHOOK_URL}" ]; then
/home/steam/server/discord.sh "Server will update in ${AUTO_UPDATE_WARN_MINUTES} minutes" "info" &
fi
countdown_message "${AUTO_UPDATE_WARN_MINUTES}" "Server_will_update_in"
fi
rcon-cli -c /home/steam/server/rcon.yaml "broadcast Server_will_update_in_${AUTO_UPDATE_WARN_MINUTES}_Minutes"
sleep "${AUTO_UPDATE_WARN_MINUTES}m"
backup
rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1"
else
echo "Unable to auto update, AUTO_UPDATE_WARN_MINUTES is not an integer: ${AUTO_UPDATE_WARN_MINUTES}"
fi
backup
rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1"
else
echo "The Server is up to date!"
fi
fi