Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion .shellcheckrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
disable=SC2154
disable=SC2154,SC2034
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shellcheck disable directive SC2034 has been added globally. SC2034 warns about unused variables. Adding this globally will suppress warnings about all unused variables across the entire codebase, which could hide legitimate issues. Consider adding inline # shellcheck disable=SC2034 comments only where needed (e.g., where previousbuild is intentionally set for later use) rather than disabling it globally.

Suggested change
disable=SC2154,SC2034
disable=SC2154

Copilot uses AI. Check for mistakes.
59 changes: 40 additions & 19 deletions lgsm/modules/alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
# Generates alert log of the details at the time of the alert.
# Used with email alerts.
fn_alert_log() {
info_distro.sh
info_game.sh
info_messages.sh
if [ -f "${alertlog}" ]; then
rm -f "${alertlog:?}"
fi

{
fn_info_messages_head
fn_info_messages_distro
Expand Down Expand Up @@ -97,45 +93,66 @@ fn_alert_monitor_query() {

# Update alerts
fn_alert_update() {
fn_script_log_info "Sending alert: ${selfname} has received a game server update: ${localbuild}"
# If previousbuild is set show transition, else fallback to single version.
if [ -n "${previousbuild:-}" ] && [ -n "${localbuild:-}" ]; then
fn_script_log_info "Sending alert: ${selfname} updated: ${previousbuild} -> ${localbuild}"
alertmessage="${selfname} updated: ${previousbuild} -> ${localbuild}."
else
fn_script_log_info "Sending alert: ${selfname} updated to ${localbuild}"
alertmessage="${selfname} updated to ${localbuild}."
fi
alertaction="Updated"
alertemoji="🎉"
alertsound="1"
alertmessage="${selfname} has received a game server update: ${localbuild}."
# Green
alertcolourhex="#00cd00"
alertcolourdec="52480"
}

fn_alert_update_request() {
fn_script_log_info "Sending alert: ${selfname} has requested an update and needs to be restarted."
alertaction="Updating"
# Update failure alert
fn_alert_update_failed() {
# Expect updatefailureexpected (target version) and updatefailuregot (actual localbuild) if set
local updateexpected="${updatefailureexpected:-${remotebuild:-unknown}}"
local updategot="${updatefailuregot:-${localbuild:-unknown}}"
fn_script_log_error "Sending alert: ${selfname} update failed: expected ${updateexpected}, got ${updategot}"
alertaction="Update Failed"
alertemoji="❌"
alertsound="2"
alertmessage="${selfname} update failed: expected ${updateexpected}, got ${updategot}. Manual intervention required."
# Red
alertcolourhex="#cd0000"
alertcolourdec="13434880"
}

fn_alert_update_restart_request() {
fn_script_log_info "Sending alert: ${selfname} restart requested"
alertaction="Restart Requested"
alertemoji="🎉"
alertsound="1"
alertmessage="${selfname} has requested an update and needs to be restarted."
alertmessage="${selfname} has requested a restart for an update to be applied. Restarting now."
# Blue
alertcolourhex="#1e90ff"
alertcolourdec="2003199"
}

fn_alert_check_update() {
fn_script_log_info "Sending alert: ${gamename} update available: ${remotebuildversion}"
alertaction="Update available"
fn_script_log_info "Sending alert: ${gamename} update available: ${localbuild} -> ${remotebuild}"
alertaction="Update Available"
alertemoji="🎉"
alertsound="1"
alertmessage="${gamename} update available: ${remotebuildversion}"
alertmessage="${gamename} update available: ${localbuild} -> ${remotebuild}"
# Blue
alertcolourhex="#1e90ff"
alertcolourdec="2003199"
}

fn_alert_update_linuxgsm() {
fn_script_log_info "Sending alert: ${selfname} has received an LinuxGSM update"
fn_script_log_info "Sending alert: ${selfname} has received a LinuxGSM update"
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the alert message: "an LinuxGSM" should be "a LinuxGSM". The article "an" is used before words beginning with vowel sounds, but "LinuxGSM" starts with a consonant sound (/l/).

Copilot uses AI. Check for mistakes.
alertaction="Updated"
alertemoji="🎉"
alertsound="1"
alertbody="${gamename} update available"
alertmessage="${selfname} has received an LinuxGSM update and been restarted."
alertmessage="${selfname} has received a LinuxGSM update and been restarted."
# Green
alertcolourhex="#00cd00"
alertcolourdec="52480"
Expand Down Expand Up @@ -197,8 +214,9 @@ fn_alert_info() {
alertcolourdec="2003199"
}

# Images
alerticon="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameicons/${shortname}-icon.png"
info_distro.sh
info_game.sh
info_messages.sh

if [ "${alert}" == "permissions" ]; then
fn_alert_permissions
Expand All @@ -210,8 +228,10 @@ elif [ "${alert}" == "test" ]; then
fn_alert_test
elif [ "${alert}" == "update" ]; then
fn_alert_update
elif [ "${alert}" == "update-request" ]; then
fn_alert_update_request
elif [ "${alert}" == "update-failed" ]; then
fn_alert_update_failed
elif [ "${alert}" == "update-restart-request" ]; then
fn_alert_update_restart_request
elif [ "${alert}" == "check-update" ]; then
fn_alert_check_update
elif [ "${alert}" == "config" ]; then
Expand All @@ -237,6 +257,7 @@ else
fi

alerttitle="${alertemoji} ${alertaction} - ${servername} ${alertemoji}"
alerticon="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameicons/${shortname}-icon.png"

# Generate alert log.
fn_alert_log
Expand Down
6 changes: 0 additions & 6 deletions lgsm/modules/alert_discord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ json=$(
"name": "Server Time",
"value": "$(date)",
"inline": true
},
{
"name": "More info",
"value": "${alerturl}",
"inline": true
}
EOF
)
Expand All @@ -62,7 +57,6 @@ if [ -n "${querytype}" ]; then
{
"name": "Is my Game Server Online?",
"value": "https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}",
"inline": true
}
EOF
)
Expand Down
1 change: 1 addition & 0 deletions lgsm/modules/check_last_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -f "${lockdir}/${selfname}-last-started.lock" ]; then
laststart=$(cat "${lockdir}/${selfname}-last-started.lock")
fi

if [ -f "${lockdir}/last-updated.lock" ]; then
lastupdate=$(cat "${lockdir}/last-updated.lock")
fi
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/command_monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ fn_monitor_check_update_source() {
fn_script_log_info "Checking update: CHECKING"
fn_print_ok "Checking update"
fn_print_ok_eol_nl
fn_script_log_info "Checking update: ${selfname} has requested an update and needs to be restarted"
alert="update-request"
fn_script_log_info "Checking update: ${selfname} has requested a restart for an update to be applied"
alert="update-restart-request"
alert.sh
command_restart.sh
core_exit.sh
Expand Down
22 changes: 11 additions & 11 deletions lgsm/modules/core_steamcmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ fn_update_steamcmd_remotebuild() {
fi

# password for branch not needed to check the buildid
remotebuildversion=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_request "${appid}" +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed -e '/"branches"/,/^}/!d' | sed -n "/\"${branch}\"/,/}/p" | grep -m 1 buildid | tr -cd '[:digit:]')
remotebuild=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_request "${appid}" +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed -e '/"branches"/,/^}/!d' | sed -n "/\"${branch}\"/,/}/p" | grep -m 1 buildid | tr -cd '[:digit:]')

if [ "${firstcommandname}" != "INSTALL" ]; then
fn_print_dots "Checking remote build: ${remotelocation}"
# Checks if remotebuildversion variable has been set.
if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then
# Checks if remotebuild variable has been set.
if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then
fn_print_fail "Checking remote build: ${remotelocation}"
fn_script_log_fail "Checking remote build"
core_exit.sh
Expand All @@ -200,7 +200,7 @@ fn_update_steamcmd_remotebuild() {
fi
else
# Checks if remotebuild variable has been set.
if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then
if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then
fn_print_failure "Unable to get remote build"
fn_script_log_fail "Unable to get remote build"
core_exit.sh
Expand All @@ -211,14 +211,14 @@ fn_update_steamcmd_remotebuild() {
fn_update_steamcmd_compare() {
fn_print_dots "Checking for update: ${remotelocation}"
# Update has been found or force update.
if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then
if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then
# Create update lockfile.
date '+%s' > "${lockdir:?}/update.lock"
fn_print_ok_nl "Checking for update: ${remotelocation}"
fn_print "\n"
fn_print_nl "${bold}${underline}Update${default} available"
fn_print_nl "* Local build: ${red}${localbuild}${default}"
fn_print_nl "* Remote build: ${green}${remotebuildversion}${default}"
fn_print_nl "* Remote build: ${green}${remotebuild}${default}"
if [ -n "${branch}" ]; then
fn_print_nl "* Branch: ${branch}"
fi
Expand All @@ -229,16 +229,17 @@ fn_update_steamcmd_compare() {
fn_print "\n"
fn_script_log_info "Update available"
fn_script_log_info "Local build: ${localbuild}"
fn_script_log_info "Remote build: ${remotebuildversion}"
fn_script_log_info "Remote build: ${remotebuild}"
if [ -n "${branch}" ]; then
fn_script_log_info "Branch: ${branch}"
fi
if [ -n "${betapassword}" ]; then
fn_script_log_info "Branch password: ${betapassword}"
fi
fn_script_log_info "${localbuild} > ${remotebuildversion}"
fn_script_log_info "${localbuild} > ${remotebuild}"

if [ "${commandname}" == "UPDATE" ]; then
date +%s > "${lockdir:?}/last-updated.lock"
unset updateonstart
check_status.sh
# If server stopped.
Expand All @@ -257,7 +258,6 @@ fn_update_steamcmd_compare() {
fn_firstcommand_reset
fi
unset exitbypass
date +%s > "${lockdir:?}/last-updated.lock"
alert="update"
elif [ "${commandname}" == "CHECK-UPDATE" ]; then
alert="check-update"
Expand All @@ -268,7 +268,7 @@ fn_update_steamcmd_compare() {
fn_print "\n"
fn_print_nl "${bold}${underline}No update${default} available"
fn_print_nl "* Local build: ${green}${localbuild}${default}"
fn_print_nl "* Remote build: ${green}${remotebuildversion}${default}"
fn_print_nl "* Remote build: ${green}${remotebuild}${default}"
if [ -n "${branch}" ]; then
fn_print_nl "* Branch: ${branch}"
fi
Expand All @@ -279,7 +279,7 @@ fn_update_steamcmd_compare() {
fn_print "\n"
fn_script_log_info "No update available"
fn_script_log_info "Local build: ${localbuild}"
fn_script_log_info "Remote build: ${remotebuildversion}"
fn_script_log_info "Remote build: ${remotebuild}"
if [ -n "${branch}" ]; then
fn_script_log_info "Branch: ${branch}"
fi
Expand Down
Loading
Loading