From 999602d9ab0777d0eb6c95079a79d45bca441b24 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 17 Oct 2023 18:58:42 +0100 Subject: [PATCH] refactor: rework email alert --- lgsm/modules/alert.sh | 26 ++++++++------------------ lgsm/modules/info_messages.sh | 15 ++++++++------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/lgsm/modules/alert.sh b/lgsm/modules/alert.sh index 385ce3b2b6..97460aee66 100644 --- a/lgsm/modules/alert.sh +++ b/lgsm/modules/alert.sh @@ -29,12 +29,11 @@ fn_alert_log() { fn_alert_test() { fn_script_log_info "Sending alert: Testing LinuxGSM Alert. No action to be taken" - alerttitle="Alert - ${selfname} - Test" alertaction="Tested" alertemoji="๐Ÿšง" alertsound="1" alerturl="not enabled" - alertmessage="Testing LinuxGSM Alert. No action to be taken." + alertmessage="Testing ${selfname} LinuxGSM Alert. No action to be taken." # Green alertcolourhex="#cdcd00" alertcolourdec="13487360" @@ -43,7 +42,6 @@ fn_alert_test() { # Running command manually fn_alert_stopped() { fn_script_log_info "Sending alert: ${selfname} has stopped" - alerttitle="Alert - ${selfname} - Stopped" alertaction="Stopped" alertemoji="โŒ" alertsound="1" @@ -56,7 +54,6 @@ fn_alert_stopped() { fn_alert_started() { fn_script_log_info "Sending alert: ${selfname} has started" - alerttitle="Alert - ${selfname} - Started" alertaction="Started" alertemoji="โœ…" alertsound="1" @@ -69,12 +66,11 @@ fn_alert_started() { fn_alert_restarted() { fn_script_log_info "Sending alert: ${selfname} has restarted" - alerttitle="Alert - ${selfname} - Restarted" alertaction="Restarted" alertemoji="โ†บ" alertsound="1" alerturl="not enabled" - alertmessage="${selfname} has restarted" + alertmessage="${selfname} has restarted." # Green alertcolourhex="#00cd00" alertcolourdec="52480" @@ -83,7 +79,6 @@ fn_alert_restarted() { # Failed monitor checks fn_alert_monitor_session() { fn_script_log_info "Sending alert: ${selfname} is not running. Game server has been restarted" - alerttitle="Alert - ${selfname} - Restarted" alertaction="Restarted" alertemoji="๐Ÿšจ" alertsound="2" @@ -96,7 +91,6 @@ fn_alert_monitor_session() { fn_alert_monitor_query() { fn_script_log_info "Sending alert: Unable to query ${selfname}. Game server has been restarted" - alerttitle="Alert - ${selfname} - Restarted" alertaction="Restarted" alertemoji="๐Ÿšจ" alertsound="2" @@ -110,7 +104,6 @@ fn_alert_monitor_query() { # Update alerts fn_alert_update() { fn_script_log_info "Sending alert: ${selfname} has received a game server update: ${localbuild}" - alerttitle="Alert - ${selfname} - Updated" alertaction="Updated" alertemoji="๐ŸŽ‰" alertsound="1" @@ -123,7 +116,6 @@ fn_alert_update() { fn_alert_check_update() { fn_script_log_info "Sending alert: ${gamename} update available: ${remotebuildversion}" - alerttitle="Alert - ${selfname} - Update available" alertaction="Checked for Update" alertemoji="๐ŸŽฎ" alertsound="1" @@ -136,7 +128,6 @@ fn_alert_check_update() { fn_alert_update_linuxgsm() { fn_script_log_info "Sending alert: ${selfname} has received an LinuxGSM update" - alerttitle="Alert - ${selfname} - LinuxGSM updated" alertaction="Updated" alertemoji="๐ŸŽ‰" alertsound="1" @@ -150,12 +141,11 @@ fn_alert_update_linuxgsm() { fn_alert_permissions() { fn_script_log_info "Sending alert: ${selfname} has permissions issues" - alerttitle="Alert - ${selfname}: Permissions error" alertaction="Checked Permissions" alertemoji="โ—" alertsound="2" alerturl="not enabled" - alertmessage="${selfname} has permissions issues" + alertmessage="${selfname} has permissions issues." # Red alertcolourhex="#cd0000" alertcolourdec="13434880" @@ -163,7 +153,6 @@ fn_alert_permissions() { fn_alert_config() { fn_script_log_info "Sending alert: ${selfname} has received a new _default.cfg" - alerttitle="Alert - ${selfname} - New _default.cfg" alertaction="Updated _default.cfg" alertemoji="๐ŸŽฎ" alertsound="1" @@ -176,12 +165,11 @@ fn_alert_config() { fn_alert_wipe() { fn_script_log_info "Sending alert: ${selfname} has been wiped" - alerttitle="Alert - ${selfname} - Wipe" alertaction="Wiped" alertemoji="๐Ÿงน" alertsound="1" alerturl="not enabled" - alertmessage="${selfname} has been wiped" + alertmessage="${selfname} has been wiped." # Blue alertcolourhex="#1e90ff" alertcolourdec="2003199" @@ -189,12 +177,12 @@ fn_alert_wipe() { fn_alert_info() { fn_script_log_info "Sending alert: ${selfname} info" - alerttitle="Alert - ${selfname} - Info" + alerttitle="LinuxGSM Alert - ${selfname} - Info" alertaction="Queried" alertemoji="๐Ÿ“„" alertsound="1" alerturl="not enabled" - alertmessage="${selfname} info" + alertmessage="${selfname} info." # Blue alertcolourhex="#1e90ff" alertcolourdec="2003199" @@ -223,6 +211,8 @@ elif [ "${alert}" == "wipe" ]; then fn_alert_wipe fi +alerttitle="LinuxGSM Alert - ${alertaction} - ${servername}" + # Generate alert log. fn_alert_log diff --git a/lgsm/modules/info_messages.sh b/lgsm/modules/info_messages.sh index f3b7182d2b..80313fb7c8 100644 --- a/lgsm/modules/info_messages.sh +++ b/lgsm/modules/info_messages.sh @@ -48,22 +48,23 @@ fn_info_message_password_strip() { # used with alertlog fn_info_message_head() { echo -e "" - echo -e "${bold}${lightyellow}Alert Summary${default}" + echo -e "LinuxGSM Alert Summary" fn_messages_separator - echo -e "Message" + echo -e "" + echo -e "Server name" + echo -e "${servername}" + echo -e "" + echo -e "Information" echo -e "${alertmessage}" echo -e "" echo -e "Game" echo -e "${gamename}" echo -e "" - echo -e "Server name" - echo -e "${servername}" + echo -e "Server IP" + echo -e "${alertip}:${port}" echo -e "" echo -e "Hostname" echo -e "${HOSTNAME}" - echo -e "" - echo -e "Server IP" - echo -e "${ip}:${port}" } fn_info_message_distro() {