| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #!/bin/bash
- # LinuxGSM alert_rocketchat.sh module
- # Author: Daniel Gibbs
- # Contributors: http://linuxgsm.com/contrib
- # Website: https://linuxgsm.com
- # Description: Sends Rocketchat alert.
- moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
- jsoninfo=$(
- cat << EOF
- {
- "alias": "LinuxGSM",
- "text": "*${alerttitle}*",
- "attachments": [
- {
- "title": "",
- "color": "${alertcolourhex}",
- "author_name": "LinuxGSM Alert",
- "author_link": "https://linuxgsm.com",
- "author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
- "thumb_url": "${alerticon}",
- "text": "",
- "fields": [
- {
- "short": false,
- "title": "Server Name",
- "value": "${servername}"
- },
- {
- "short": false,
- "title": "Information",
- "value": "${alertmessage}"
- },
- {
- "short": false,
- "title": "Game",
- "value": "${gamename}"
- },
- {
- "short": false,
- "title": "Server IP",
- "value": "${alertip}:${port}"
- },
- {
- "short": false,
- "title": "Hostname",
- "value": "${HOSTNAME}"
- },
- {
- "short": false,
- "title": "More info",
- "value": "${alerturl}"
- },
- {
- "short": false,
- "title": "Server Time",
- "value": "$(date)"
- }
- ]
- }
- ]
- }
- EOF
- )
- jsonnoinfo=$(
- cat << EOF
- {
- "alias": "LinuxGSM",
- "text": "*${alerttitle}*",
- "attachments": [
- {
- "title": "",
- "color": "${alertcolourhex}",
- "author_name": "LinuxGSM Alert",
- "author_link": "https://linuxgsm.com",
- "author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
- "thumb_url": "${alerticon}",
- "text": "",
- "fields": [
- {
- "short": false,
- "title": "Server Name",
- "value": "${servername}"
- },
- {
- "short": false,
- "title": "Information",
- "value": "${alertmessage}"
- },
- {
- "short": false,
- "title": "Game",
- "value": "${gamename}"
- },
- {
- "short": false,
- "title": "Server IP",
- "value": "${alertip}:${port}"
- },
- {
- "short": false,
- "title": "Hostname",
- "value": "${HOSTNAME}"
- },
- {
- "short": false,
- "title": "Server Time",
- "value": "$(date)"
- }
- ]
- }
- ]
- }
- EOF
- )
- if [ -z "${alerturl}" ]; then
- json="${jsonnoinfo}"
- else
- json="${jsoninfo}"
- fi
- fn_print_dots "Sending Rocketchat alert"
- rocketchatsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${rocketchatwebhook}")
- if [ -n "${rocketchatsend}" ]; then
- fn_print_ok_nl "Sending Rocketchat alert"
- fn_script_log_pass "Sending Rocketchat alert"
- else
- fn_print_fail_nl "Sending Rocketchat alert: ${rocketchatsend}"
- fn_script_log_fail "Sending Rocketchat alert: ${rocketchatsend}"
- fi
|