Browse Source

space

pull/3051/head
Daniel Gibbs 5 years ago
parent
commit
4d102eca2a
  1. 76
      lgsm/functions/alert_discord.sh
  2. 14
      lgsm/functions/alert_ifttt.sh
  3. 16
      lgsm/functions/alert_pushbullet.sh
  4. 64
      lgsm/functions/alert_rocketchat.sh
  5. 108
      lgsm/functions/alert_slack.sh
  6. 16
      lgsm/functions/alert_telegram.sh

76
lgsm/functions/alert_discord.sh

@ -8,44 +8,44 @@
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if ! command -v jq > /dev/null; then
fn_print_fail_nl "Sending Discord alert: jq is missing."
fn_script_log_fatal "Sending Discord alert: jq is missing."
fn_print_fail_nl "Sending Discord alert: jq is missing."
fn_script_log_fatal "Sending Discord alert: jq is missing."
fi
json=$(cat <<EOF
{
"username":"LinuxGSM",
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png",
"file":"content",
"embeds": [{
"color": "2067276",
"author": {
"name": "${alertemoji} ${alertsubject} ${alertemoji}",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png"},
"title": "${escaped_servername}",
"description": ${escaped_alertbody},
"url": "",
"type": "content",
"thumbnail": {},
"footer": {"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}", "icon_url": ""},
"fields": [
{
"name": "Game",
"value": "${gamename}",
"inline": true
},
{
"name": "Server IP",
"value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})",
"inline": true
},
{
"name": "Server Name",
"value": ${escaped_servername},
"inline": true
}
]
}]
"username":"LinuxGSM",
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png",
"file":"content",
"embeds": [{
"color": "2067276",
"author": {
"name": "${alertemoji} ${alertsubject} ${alertemoji}",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png"},
"title": "${escaped_servername}",
"description": ${escaped_alertbody},
"url": "",
"type": "content",
"thumbnail": {},
"footer": {"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}", "icon_url": ""},
"fields": [
{
"name": "Game",
"value": "${gamename}",
"inline": true
},
{
"name": "Server IP",
"value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})",
"inline": true
},
{
"name": "Server Name",
"value": ${escaped_servername},
"inline": true
}
]
}]
}
EOF
)
@ -55,9 +55,9 @@ fn_print_dots "Sending Discord alert"
discordsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${discordwebhook}")
if [ "${discordsend}" ]; then
fn_print_fail_nl "Sending Discord alert: ${discordsend}"
fn_script_log_fatal "Sending Discord alert: ${discordsend}"
fn_print_fail_nl "Sending Discord alert: ${discordsend}"
fn_script_log_fatal "Sending Discord alert: ${discordsend}"
else
fn_print_ok_nl "Sending Discord alert"
fn_script_log_pass "Sending Discord alert"
fn_print_ok_nl "Sending Discord alert"
fn_script_log_pass "Sending Discord alert"
fi

14
lgsm/functions/alert_ifttt.sh

@ -8,9 +8,9 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
json=$(cat <<EOF
{
"value1": "${selfname}",
"value2": "${alertemoji} ${alertsubject} ${alertemoji}",
"value3": "Message: \n${escaped_alertbody}\n\nGame: \n${gamename}\n\nServer name: \n${escaped_servername}\n\nHostname: \n${HOSTNAME}\n\nServer IP: \n${alertip}:${port}\n\nMore info: \n${alerturl}"
"value1": "${selfname}",
"value2": "${alertemoji} ${alertsubject} ${alertemoji}",
"value3": "Message: \n${escaped_alertbody}\n\nGame: \n${gamename}\n\nServer name: \n${escaped_servername}\n\nHostname: \n${HOSTNAME}\n\nServer IP: \n${alertip}:${port}\n\nMore info: \n${alerturl}"
}
EOF
)
@ -19,9 +19,9 @@ fn_print_dots "Sending IFTTT alert"
iftttsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
if [ "${iftttsend}" ]; then
fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"
fn_script_log_fatal "Sending IFTTT alert: ${pushbulletsend}"
fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"
fn_script_log_fatal "Sending IFTTT alert: ${pushbulletsend}"
else
fn_print_ok_nl "Sending IFTTT alert"
fn_script_log_pass "Sent IFTTT alert"
fn_print_ok_nl "Sending IFTTT alert"
fn_script_log_pass "Sent IFTTT alert"
fi

16
lgsm/functions/alert_pushbullet.sh

@ -8,10 +8,10 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
json=$(cat <<EOF
{
"channel_tag": "${channeltag}",
"type": "note",
"title": "${alertemoji} ${alertsubject} ${alertemoji}",
"body": "Message\n${escaped_alertbody}\n\nGame\n${gamename}\n\nServer name\n${escaped_servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${alertip}:${port}\n\nMore info\n${alerturl}"
"channel_tag": "${channeltag}",
"type": "note",
"title": "${alertemoji} ${alertsubject} ${alertemoji}",
"body": "Message\n${escaped_alertbody}\n\nGame\n${gamename}\n\nServer name\n${escaped_servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${alertip}:${port}\n\nMore info\n${alerturl}"
}
EOF
)
@ -20,9 +20,9 @@ fn_print_dots "Sending Pushbullet alert"
pushbulletsend=$(curl -sSL -u """${pushbullettoken}"":" -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
if [ "${pushbulletsend}" ]; then
fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"
fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}"
fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"
fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}"
else
fn_print_ok_nl "Sending Pushbullet alert"
fn_script_log_pass "Sent Pushbullet alert"
fn_print_ok_nl "Sending Pushbullet alert"
fn_script_log_pass "Sent Pushbullet alert"
fi

64
lgsm/functions/alert_rocketchat.sh

@ -7,38 +7,38 @@
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if ! command -v jq > /dev/null; then
fn_print_fail_nl "Sending Rocketchat alert: jq is missing."
fn_script_log_fatal "Sending Rocketchat alert: jq is missing."
fn_print_fail_nl "Sending Rocketchat alert: jq is missing."
fn_script_log_fatal "Sending Rocketchat alert: jq is missing."
fi
json=$(cat <<EOF
{
"alias": "LinuxGSM",
"text": "*${alertemoji} ${alertsubject} ${alertemoji}* + \n ${escaped_alertbody}",
"attachments": [
{
"title": "Linuxgsm Alert",
"text": "Hostname: ${HOSTNAME}",
"color": "#36a64f",
"fields": [
{
"short": true,
"title": "Game:",
"value": "${gamename}"
},
{
"short": true,
"title": "Server IP:",
"value": "${alertip}:${port}"
},
{
"short": true,
"title": "Server Name:",
"value": "${escaped_servername}"
}
]
}
]
"alias": "LinuxGSM",
"text": "*${alertemoji} ${alertsubject} ${alertemoji}* + \n ${escaped_alertbody}",
"attachments": [
{
"title": "Linuxgsm Alert",
"text": "Hostname: ${HOSTNAME}",
"color": "#36a64f",
"fields": [
{
"short": true,
"title": "Game:",
"value": "${gamename}"
},
{
"short": true,
"title": "Server IP:",
"value": "${alertip}:${port}"
},
{
"short": true,
"title": "Server Name:",
"value": "${escaped_servername}"
}
]
}
]
}
EOF
)
@ -48,9 +48,9 @@ fn_print_dots "Sending Rocketchat alert"
rocketlaunch=$(curl -sSL -H "Content-Type:application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${rocketchatwebhook}")
if [ "${rocketlaunch}" == "ok" ]; then
fn_print_ok_nl "Sending Rocketchat alert"
fn_script_log_pass "Sending Rocketchat alert"
fn_print_ok_nl "Sending Rocketchat alert"
fn_script_log_pass "Sending Rocketchat alert"
else
fn_print_fail_nl "Sending Rocketchat alert: ${rocketlaunch}"
fn_script_log_fatal "Sending Rocketchat alert: ${rocketlaunch}"
fn_print_fail_nl "Sending Rocketchat alert: ${rocketlaunch}"
fn_script_log_fatal "Sending Rocketchat alert: ${rocketlaunch}"
fi

108
lgsm/functions/alert_slack.sh

@ -7,60 +7,60 @@
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if ! command -v jq > /dev/null; then
fn_print_fail_nl "Sending Slack alert: jq is missing."
fn_script_log_fatal "Sending Slack alert: jq is missing."
fn_print_fail_nl "Sending Slack alert: jq is missing."
fn_script_log_fatal "Sending Slack alert: jq is missing."
fi
json=$(cat <<EOF
{
"attachments": [
{
"color": "#36a64f",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*LinuxGSM Alert*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${alertemoji} ${alertsubject} ${alertemoji}* \n ${escaped_alertbody}"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Game:* \n ${gamename}"
},
{
"type": "mrkdwn",
"text": "*Server IP:* \n ${alertip}:${port}"
},
{
"type": "mrkdwn",
"text": "*Server Name:* \n ${escaped_servername}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}"
}
}
]
}
]
"attachments": [
{
"color": "#36a64f",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*LinuxGSM Alert*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${alertemoji} ${alertsubject} ${alertemoji}* \n ${escaped_alertbody}"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Game:* \n ${gamename}"
},
{
"type": "mrkdwn",
"text": "*Server IP:* \n ${alertip}:${port}"
},
{
"type": "mrkdwn",
"text": "*Server Name:* \n ${escaped_servername}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}"
}
}
]
}
]
}
EOF
)
@ -70,9 +70,9 @@ fn_print_dots "Sending Slack alert"
slacksend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${slackwebhook}")
if [ "${slacksend}" == "ok" ]; then
fn_print_ok_nl "Sending Slack alert"
fn_script_log_pass "Sending Slack alert"
fn_print_ok_nl "Sending Slack alert"
fn_script_log_pass "Sending Slack alert"
else
fn_print_fail_nl "Sending Slack alert: ${slacksend}"
fn_script_log_fatal "Sending Slack alert: ${slacksend}"
fn_print_fail_nl "Sending Slack alert: ${slacksend}"
fn_script_log_fatal "Sending Slack alert: ${slacksend}"
fi

16
lgsm/functions/alert_telegram.sh

@ -11,10 +11,10 @@ escaped_alertbody=$(echo -n "${alertbody}" | jq -sRr "@json")
json=$(cat <<EOF
{
"chat_id": "${telegramchatid}",
"parse_mode": "HTML",
"text": "<b>${alertemoji} ${alertsubject} ${alertemoji}</b>\n\n<b>Message</b>\n${escaped_alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server name</b>\n${escaped_servername}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Server IP</b>\n<a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a>\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>",
"disable_web_page_preview": "yes",
"chat_id": "${telegramchatid}",
"parse_mode": "HTML",
"text": "<b>${alertemoji} ${alertsubject} ${alertemoji}</b>\n\n<b>Message</b>\n${escaped_alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server name</b>\n${escaped_servername}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Server IP</b>\n<a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a>\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>",
"disable_web_page_preview": "yes",
EOF
)
@ -22,9 +22,9 @@ fn_print_dots "Sending Telegram alert"
telegramsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" ${curlcustomstring} "https://api.telegram.org/bot${telegramtoken}/sendMessage" | grep "error_code")
if [ "${telegramsend}" ]; then
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"
fn_script_log_fatal "Sending Telegram alert: ${telegramsend}"
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"
fn_script_log_fatal "Sending Telegram alert: ${telegramsend}"
else
fn_print_ok_nl "Sending Telegram alert"
fn_script_log_pass "Sent Telegram alert"
fn_print_ok_nl "Sending Telegram alert"
fn_script_log_pass "Sent Telegram alert"
fi

Loading…
Cancel
Save