Browse Source

Update alert.sh

pull/3507/head
n 4 years ago
parent
commit
f6d864d99f
  1. 19
      lgsm/functions/alert.sh
  2. 2
      lgsm/functions/alert_matrix.sh

19
lgsm/functions/alert.sh

@ -221,3 +221,22 @@ elif [ -z "${slacktoken}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
echo -e "* https://docs.linuxgsm.com/alerts/slack"
fn_script_error "Slack token not set"
fi
if [ "${matrixalert}" == "on" ]&&[ -n "${matrixtoken}" ]; then
alert_matrix.sh
elif [ "${matrixalert}" != "on" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
fn_print_warn_nl "Matrix alerts not enabled"
fn_script_log_warn "Matrix alerts not enabled"
elif [ -z "${matrixhomeserver}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
fn_print_error_nl "Matrix homeserver not set."
echo -e "* https://docs.linuxgsm.com/alerts/matrix"
fn_script_error "Matrix homeserver not set."
elif [ -z "${matrixtoken}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
fn_print_error_nl "Matrix token not set."
echo -e "* https://docs.linuxgsm.com/alerts/matrix"
fn_script_error "Matrix token not set."
elif [ -z "${matrixroom}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
fn_print_error_nl "Matrix room not set."
echo -e "* https://docs.linuxgsm.com/alerts/matrix"
fn_script_error "Matrix room not set."
fi

2
lgsm/functions/alert_matrix.sh

@ -17,7 +17,7 @@ EOF
)
fn_print_dots "Sending Matrix alert"
matrixsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://${matrixhomeserver}/_matrix/client/r0/rooms/${matrixroom}/send/m.room.message?access_token=${matrixaccesstoken} | grep "error")
matrixsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://${matrixhomeserver}/_matrix/client/r0/rooms/${matrixroom}/send/m.room.message?access_token=${matrixtoken} | grep "error")
if [ -n "${matrixsend}" ]; then

Loading…
Cancel
Save