Просмотр исходного кода

Added rocketchat token variable and setup base alert class to handle calling rocketchat alert script

Alasdair Haig 6 лет назад
Родитель
Сommit
2d60674d94
2 измененных файлов с 12 добавлено и 0 удалено
  1. 1 0
      lgsm/config-default/config-lgsm/vhserver/_default.cfg
  2. 11 0
      lgsm/functions/alert.sh

+ 1 - 0
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"

+ 11 - 0
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