Skip to content

Commit

Permalink
refactor: rework email alert
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Oct 17, 2023
1 parent be64ce0 commit 999602d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
26 changes: 8 additions & 18 deletions lgsm/modules/alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -150,20 +141,18 @@ 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"
}

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"
Expand All @@ -176,25 +165,24 @@ 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"
}

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"
Expand Down Expand Up @@ -223,6 +211,8 @@ elif [ "${alert}" == "wipe" ]; then
fn_alert_wipe
fi

alerttitle="LinuxGSM Alert - ${alertaction} - ${servername}"

# Generate alert log.
fn_alert_log

Expand Down
15 changes: 8 additions & 7 deletions lgsm/modules/info_messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 999602d

Please sign in to comment.