Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(alerts): add Matrix support to alerts #3507

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lgsm/functions/alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 1 deletion lgsm/functions/alert_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
n194 marked this conversation as resolved.
Show resolved Hide resolved


if [ -n "${matrixsend}" ]; then
Expand Down