Browse Source

refactor: rework email alert

pull/4345/head
Daniel Gibbs 2 years ago
parent
commit
999602d9ab
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 26
      lgsm/modules/alert.sh
  2. 15
      lgsm/modules/info_messages.sh

26
lgsm/modules/alert.sh

@ -29,12 +29,11 @@ fn_alert_log() {
fn_alert_test() { fn_alert_test() {
fn_script_log_info "Sending alert: Testing LinuxGSM Alert. No action to be taken" fn_script_log_info "Sending alert: Testing LinuxGSM Alert. No action to be taken"
alerttitle="Alert - ${selfname} - Test"
alertaction="Tested" alertaction="Tested"
alertemoji="🚧" alertemoji="🚧"
alertsound="1" alertsound="1"
alerturl="not enabled" alerturl="not enabled"
alertmessage="Testing LinuxGSM Alert. No action to be taken." alertmessage="Testing ${selfname} LinuxGSM Alert. No action to be taken."
# Green # Green
alertcolourhex="#cdcd00" alertcolourhex="#cdcd00"
alertcolourdec="13487360" alertcolourdec="13487360"
@ -43,7 +42,6 @@ fn_alert_test() {
# Running command manually # Running command manually
fn_alert_stopped() { fn_alert_stopped() {
fn_script_log_info "Sending alert: ${selfname} has stopped" fn_script_log_info "Sending alert: ${selfname} has stopped"
alerttitle="Alert - ${selfname} - Stopped"
alertaction="Stopped" alertaction="Stopped"
alertemoji="❌" alertemoji="❌"
alertsound="1" alertsound="1"
@ -56,7 +54,6 @@ fn_alert_stopped() {
fn_alert_started() { fn_alert_started() {
fn_script_log_info "Sending alert: ${selfname} has started" fn_script_log_info "Sending alert: ${selfname} has started"
alerttitle="Alert - ${selfname} - Started"
alertaction="Started" alertaction="Started"
alertemoji="✅" alertemoji="✅"
alertsound="1" alertsound="1"
@ -69,12 +66,11 @@ fn_alert_started() {
fn_alert_restarted() { fn_alert_restarted() {
fn_script_log_info "Sending alert: ${selfname} has restarted" fn_script_log_info "Sending alert: ${selfname} has restarted"
alerttitle="Alert - ${selfname} - Restarted"
alertaction="Restarted" alertaction="Restarted"
alertemoji="↺" alertemoji="↺"
alertsound="1" alertsound="1"
alerturl="not enabled" alerturl="not enabled"
alertmessage="${selfname} has restarted" alertmessage="${selfname} has restarted."
# Green # Green
alertcolourhex="#00cd00" alertcolourhex="#00cd00"
alertcolourdec="52480" alertcolourdec="52480"
@ -83,7 +79,6 @@ fn_alert_restarted() {
# Failed monitor checks # Failed monitor checks
fn_alert_monitor_session() { fn_alert_monitor_session() {
fn_script_log_info "Sending alert: ${selfname} is not running. Game server has been restarted" fn_script_log_info "Sending alert: ${selfname} is not running. Game server has been restarted"
alerttitle="Alert - ${selfname} - Restarted"
alertaction="Restarted" alertaction="Restarted"
alertemoji="🚨" alertemoji="🚨"
alertsound="2" alertsound="2"
@ -96,7 +91,6 @@ fn_alert_monitor_session() {
fn_alert_monitor_query() { fn_alert_monitor_query() {
fn_script_log_info "Sending alert: Unable to query ${selfname}. Game server has been restarted" fn_script_log_info "Sending alert: Unable to query ${selfname}. Game server has been restarted"
alerttitle="Alert - ${selfname} - Restarted"
alertaction="Restarted" alertaction="Restarted"
alertemoji="🚨" alertemoji="🚨"
alertsound="2" alertsound="2"
@ -110,7 +104,6 @@ fn_alert_monitor_query() {
# Update alerts # Update alerts
fn_alert_update() { fn_alert_update() {
fn_script_log_info "Sending alert: ${selfname} has received a game server update: ${localbuild}" fn_script_log_info "Sending alert: ${selfname} has received a game server update: ${localbuild}"
alerttitle="Alert - ${selfname} - Updated"
alertaction="Updated" alertaction="Updated"
alertemoji="🎉" alertemoji="🎉"
alertsound="1" alertsound="1"
@ -123,7 +116,6 @@ fn_alert_update() {
fn_alert_check_update() { fn_alert_check_update() {
fn_script_log_info "Sending alert: ${gamename} update available: ${remotebuildversion}" fn_script_log_info "Sending alert: ${gamename} update available: ${remotebuildversion}"
alerttitle="Alert - ${selfname} - Update available"
alertaction="Checked for Update" alertaction="Checked for Update"
alertemoji="🎮" alertemoji="🎮"
alertsound="1" alertsound="1"
@ -136,7 +128,6 @@ fn_alert_check_update() {
fn_alert_update_linuxgsm() { 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 an LinuxGSM update"
alerttitle="Alert - ${selfname} - LinuxGSM updated"
alertaction="Updated" alertaction="Updated"
alertemoji="🎉" alertemoji="🎉"
alertsound="1" alertsound="1"
@ -150,12 +141,11 @@ fn_alert_update_linuxgsm() {
fn_alert_permissions() { fn_alert_permissions() {
fn_script_log_info "Sending alert: ${selfname} has permissions issues" fn_script_log_info "Sending alert: ${selfname} has permissions issues"
alerttitle="Alert - ${selfname}: Permissions error"
alertaction="Checked Permissions" alertaction="Checked Permissions"
alertemoji="❗" alertemoji="❗"
alertsound="2" alertsound="2"
alerturl="not enabled" alerturl="not enabled"
alertmessage="${selfname} has permissions issues" alertmessage="${selfname} has permissions issues."
# Red # Red
alertcolourhex="#cd0000" alertcolourhex="#cd0000"
alertcolourdec="13434880" alertcolourdec="13434880"
@ -163,7 +153,6 @@ fn_alert_permissions() {
fn_alert_config() { fn_alert_config() {
fn_script_log_info "Sending alert: ${selfname} has received a new _default.cfg" fn_script_log_info "Sending alert: ${selfname} has received a new _default.cfg"
alerttitle="Alert - ${selfname} - New _default.cfg"
alertaction="Updated _default.cfg" alertaction="Updated _default.cfg"
alertemoji="🎮" alertemoji="🎮"
alertsound="1" alertsound="1"
@ -176,12 +165,11 @@ fn_alert_config() {
fn_alert_wipe() { fn_alert_wipe() {
fn_script_log_info "Sending alert: ${selfname} has been wiped" fn_script_log_info "Sending alert: ${selfname} has been wiped"
alerttitle="Alert - ${selfname} - Wipe"
alertaction="Wiped" alertaction="Wiped"
alertemoji="🧹" alertemoji="🧹"
alertsound="1" alertsound="1"
alerturl="not enabled" alerturl="not enabled"
alertmessage="${selfname} has been wiped" alertmessage="${selfname} has been wiped."
# Blue # Blue
alertcolourhex="#1e90ff" alertcolourhex="#1e90ff"
alertcolourdec="2003199" alertcolourdec="2003199"
@ -189,12 +177,12 @@ fn_alert_wipe() {
fn_alert_info() { fn_alert_info() {
fn_script_log_info "Sending alert: ${selfname} info" fn_script_log_info "Sending alert: ${selfname} info"
alerttitle="Alert - ${selfname} - Info" alerttitle="LinuxGSM Alert - ${selfname} - Info"
alertaction="Queried" alertaction="Queried"
alertemoji="📄" alertemoji="📄"
alertsound="1" alertsound="1"
alerturl="not enabled" alerturl="not enabled"
alertmessage="${selfname} info" alertmessage="${selfname} info."
# Blue # Blue
alertcolourhex="#1e90ff" alertcolourhex="#1e90ff"
alertcolourdec="2003199" alertcolourdec="2003199"
@ -223,6 +211,8 @@ elif [ "${alert}" == "wipe" ]; then
fn_alert_wipe fn_alert_wipe
fi fi
alerttitle="LinuxGSM Alert - ${alertaction} - ${servername}"
# Generate alert log. # Generate alert log.
fn_alert_log fn_alert_log

15
lgsm/modules/info_messages.sh

@ -48,22 +48,23 @@ fn_info_message_password_strip() {
# used with alertlog # used with alertlog
fn_info_message_head() { fn_info_message_head() {
echo -e "" echo -e ""
echo -e "${bold}${lightyellow}Alert Summary${default}" echo -e "LinuxGSM Alert Summary"
fn_messages_separator 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 "${alertmessage}"
echo -e "" echo -e ""
echo -e "Game" echo -e "Game"
echo -e "${gamename}" echo -e "${gamename}"
echo -e "" echo -e ""
echo -e "Server name" echo -e "Server IP"
echo -e "${servername}" echo -e "${alertip}:${port}"
echo -e "" echo -e ""
echo -e "Hostname" echo -e "Hostname"
echo -e "${HOSTNAME}" echo -e "${HOSTNAME}"
echo -e ""
echo -e "Server IP"
echo -e "${ip}:${port}"
} }
fn_info_message_distro() { fn_info_message_distro() {

Loading…
Cancel
Save