From 2d60674d94cad20d07be9d47015cbdd38d43ad1e Mon Sep 17 00:00:00 2001 From: Alasdair Haig Date: Thu, 2 Jul 2020 00:23:05 +0200 Subject: [PATCH] Added rocketchat token variable and setup base alert class to handle calling rocketchat alert script --- lgsm/config-default/config-lgsm/vhserver/_default.cfg | 1 + lgsm/functions/alert.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) mode change 100644 => 100755 lgsm/functions/alert.sh diff --git a/lgsm/config-default/config-lgsm/vhserver/_default.cfg b/lgsm/config-default/config-lgsm/vhserver/_default.cfg index 169f9a534..1d09a514c 100644 --- a/lgsm/config-default/config-lgsm/vhserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/vhserver/_default.cfg @@ -78,6 +78,7 @@ pushovertoken="accesstoken" # Rocketchat Alerts rocketchatalert="off" rocketchatwebhook="webhook" +rocketchattoken="" # Slack Alerts | https://docs.linuxgsm.com/alerts/slack slackalert="off" diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh old mode 100644 new mode 100755 index 5f8fe156e..4a6c28d7f --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -190,6 +190,17 @@ elif [ -z "${telegramchatid}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then fn_script_error "Telegram chat id not set." fi +if [ "${rocketchatalert}" == "on" ]&&[ -n "${rocketchatalert}" ]; then + alert_rocketchat.sh +elif [ "${rocketchatalert}" != "on" ]&&[ "${commandname}" == "TEST-ALERT" ]; then + fn_print_warn_nl "Rocketchat alerts not enabled" + fn_script_log_warn "Rocketchat alerts not enabled" +elif [ -z "${rocketchattoken}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then + fn_print_error_nl "Rocketchat token not set" + #echo -e "* https://docs.linuxgsm.com/alerts/slack" + fn_script_error "Rocketchat token not set" +fi + if [ "${slackalert}" == "on" ]&&[ -n "${slackalert}" ]; then alert_slack.sh elif [ "${slackalert}" != "on" ]&&[ "${commandname}" == "TEST-ALERT" ]; then