Browse Source

Added mailgun

pull/1601/head
Daniel Gibbs 8 years ago
parent
commit
131b8ef6ba
  1. 77
      lgsm/functions/alert.sh
  2. 22
      lgsm/functions/alert_mailgun.sh

77
lgsm/functions/alert.sh

@ -64,6 +64,17 @@ elif [ "${alert}" == "update" ]; then
fn_alert_update
fi
if [ "${discordalert}" == "on" ]&&[ -n "${discordalert}" ]; then
alert_discord.sh
elif [ "${discordalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_warn_nl "Discord alerts not enabled"
fn_script_log_warn "Discord alerts not enabled"
elif [ -z "${discordtoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_error_nl "Discord token not set"
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Discord"
fn_script_error_warn "Discord token not set"
fi
if [ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then
alert_email.sh
elif [ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
@ -74,6 +85,28 @@ elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; t
fn_script_log_error "Email not set"
fi
if [ "${iftttalert}" == "on" ]&&[ -n "${iftttalert}" ]; then
alert_ifttt.sh
elif [ "${iftttalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_warn_nl "IFTTT alerts not enabled"
fn_script_log_warn "IFTTT alerts not enabled"
elif [ -z "${ifttttoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_error_nl "IFTTT token not set"
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/IFTTT"
fn_script_error_warn "IFTTT token not set"
fi
if [ "${mailgunalert}" == "on" ]&&[ -n "${mailgunalert}" ]; then
alert_mailgun.sh
elif [ "${mailgunalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_warn_nl "Mailgun alerts not enabled"
fn_script_log_warn "Mailgun alerts not enabled"
elif [ -z "${mailguntoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_error_nl "Mailgun token not set"
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Mailgun"
fn_script_error_warn "Mailgun token not set"
fi
if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then
alert_pushbullet.sh
elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
@ -85,6 +118,17 @@ elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_aler
fn_script_error_warn "Pushbullet token not set"
fi
if [ "${pushoveralert}" == "on" ]&&[ -n "${pushoveralert}" ]; then
alert_pushover.sh
elif [ "${pushoveralert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_warn_nl "Pushover alerts not enabled"
fn_script_log_warn "Pushover alerts not enabled"
elif [ -z "${pushovertoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_error_nl "Pushover token not set"
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Pushover"
fn_script_error_warn "Pushover token not set"
fi
if [ "${telegramalert}" == "on" ]&&[ -n "${telegramtoken}" ]; then
alert_telegram.sh
elif [ "${telegramalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
@ -98,37 +142,4 @@ elif [ -z "${telegramchatid}" ]&&[ "${function_selfname}" == "command_test_alert
fn_print_error_nl "Telegram chat id not set."
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Telegram"
fn_script_error_warn "Telegram chat id not set."
fi
if [ "${discordalert}" == "on" ]&&[ -n "${discordalert}" ]; then
alert_discord.sh
elif [ "${discordalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_warn_nl "Discord alerts not enabled"
fn_script_log_warn "Discord alerts not enabled"
elif [ -z "${discordtoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_error_nl "Discord token not set"
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Discord"
fn_script_error_warn "Discord token not set"
fi
if [ "${pushoveralert}" == "on" ]&&[ -n "${pushoveralert}" ]; then
alert_pushover.sh
elif [ "${pushoveralert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_warn_nl "Pushover alerts not enabled"
fn_script_log_warn "Pushover alerts not enabled"
elif [ -z "${pushovertoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_error_nl "Pushover token not set"
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Pushover"
fn_script_error_warn "Pushover token not set"
fi
if [ "${iftttalert}" == "on" ]&&[ -n "${iftttalert}" ]; then
alert_ifttt.sh
elif [ "${iftttalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_warn_nl "IFTTT alerts not enabled"
fn_script_log_warn "IFTTT alerts not enabled"
elif [ -z "${ifttttoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_error_nl "IFTTT token not set"
echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/IFTTT"
fn_script_error_warn "IFTTT token not set"
fi

22
lgsm/functions/alert_mailgun.sh

@ -0,0 +1,22 @@
#!/bin/bash
# LinuxGSM alert_mailgun.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description: Sends Mailgun Email alert.
local commandname="ALERT"
local commandaction="Alert"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_print_dots "Sending Email (Mailgun) alert"
sleep 0.5
mailgunsend=$(curl -s --user "api:${mailguntoken}" -F from="LinuxGSM <${mailgundomain}>" -F to="${servicename} Admin <${mailgunemail}>" -F subject="${alertemoji} <b>${alertsubject}</b> ${alertemoji}" --form-string html="<br><br><b>Message</b><br>${alertbody}<br><br><b>Game</b><br>${gamename}<br><br><b>Server name</b><br>${servername}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Server IP</b><br><a href='https://www.gametracker.com/server_info/${ip}:${port}'>${ip}:${port}</a><br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" https://api.mailgun.net/v3/sandbox10b3f208bfe541aca8a0c97f33a6c3fe.mailgun.org/messages)
if [ -z "${mailgunsend}" ]; then
fn_print_fail_nl "Sending Email (Mailgun) alert"
fn_script_log_fatal "Sending Email (Mailgun) alert"
else
fn_print_ok_nl "Sending Email (Mailgun) alert"
fn_script_log_pass "Sent Email (Mailgun) alert"
fi
Loading…
Cancel
Save