Daniel Gibbs 5 лет назад
Родитель
Сommit
f4a6d610ac

+ 7 - 7
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${alertbody}\n\nGame: \n${gamename}\n\nServer name: \n${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${alertbody}\n\nGame: \n${gamename}\n\nServer name: \n${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

+ 8 - 8
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${alertbody}\n\nGame\n${gamename}\n\nServer name\n${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${alertbody}\n\nGame\n${gamename}\n\nServer name\n${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

+ 32 - 32
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 ${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": "${servername}"
-        }
-      ]
-    }
-  ]
+	"alias": "LinuxGSM",
+	"text": "*${alertemoji} ${alertsubject} ${alertemoji}* + \n ${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": "${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

+ 54 - 54
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 ${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 ${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 ${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 ${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

+ 8 - 8
lgsm/functions/alert_telegram.sh

@@ -8,10 +8,10 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 json=$(cat <<EOF
 {
-  "chat_id": "${telegramchatid}",
-  "parse_mode": "HTML",
-  "text": "<b>${alertemoji} ${alertsubject} ${alertemoji}</b>\n\n<b>Message</b>\n${alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server name</b>\n${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${alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server name</b>\n${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
 )
 
@@ -19,9 +19,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