Browse Source

Merge branch 'develop' into feature/2915-rust-seed

pull/3190/head
Daniel Gibbs 5 years ago
committed by GitHub
parent
commit
274c9d2748
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      lgsm/config-default/config-lgsm/jc2server/_default.cfg
  2. 11
      lgsm/functions/alert.sh
  3. 23
      lgsm/functions/alert_sendgrid.sh
  4. 103
      lgsm/functions/alert_slack.sh
  5. 5
      lgsm/functions/core_functions.sh
  6. 16
      lgsm/functions/info_config.sh
  7. 0
      lgsm/functions/update_factorio.sh
  8. 0
      lgsm/functions/update_minecraft_bedrock.sh
  9. 0
      lgsm/functions/update_mta.sh
  10. 0
      lgsm/functions/update_mumble.sh
  11. 0
      lgsm/functions/update_ts3.sh

7
lgsm/config-default/config-lgsm/jc2server/_default.cfg

@ -67,6 +67,13 @@ rocketchatalert="off"
rocketchatwebhook="webhook" rocketchatwebhook="webhook"
rocketchattoken="" rocketchattoken=""
# Sendgrid Email Alerts | https://docs.linuxgsm.com/alerts/sendgrid
sendgridalert="off"
sendgridtoken="accesstoken"
sendgriddomain="example.com"
sendgridemailfrom="[email protected]"
sendgridemail="[email protected]"
# Slack Alerts | https://docs.linuxgsm.com/alerts/slack # Slack Alerts | https://docs.linuxgsm.com/alerts/slack
slackalert="off" slackalert="off"
slackwebhook="webhook" slackwebhook="webhook"

11
lgsm/functions/alert.sh

@ -188,6 +188,17 @@ elif [ -z "${pushovertoken}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
fn_script_error "Pushover token not set" fn_script_error "Pushover token not set"
fi fi
if [ "${sendgridalert}" == "on" ]&&[ -n "${sendgridalert}" ]; then
alert_sendgrid.sh
elif [ "${sendgridalert}" != "on" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
fn_print_warn_nl "SendGrid alerts not enabled"
fn_script_log_warn "SendGrid alerts not enabled"
elif [ -z "${sendgridtoken}" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
fn_print_error_nl "SendGrid token not set"
echo -e "* https://docs.linuxgsm.com/alerts/sendgrid"
fn_script_error "SendGrid token not set"
fi
if [ "${telegramalert}" == "on" ]&&[ -n "${telegramtoken}" ]; then if [ "${telegramalert}" == "on" ]&&[ -n "${telegramtoken}" ]; then
alert_telegram.sh alert_telegram.sh
elif [ "${telegramalert}" != "on" ]&&[ "${commandname}" == "TEST-ALERT" ]; then elif [ "${telegramalert}" != "on" ]&&[ "${commandname}" == "TEST-ALERT" ]; then

23
lgsm/functions/alert_sendgrid.sh

@ -0,0 +1,23 @@
#!/bin/bash
# LinuxGSM alert_sendgrid.sh function
# Author: Daniel Gibbs
# Website: https://linuxgsm.com
# Description: Sends SendGrid Email alert.
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_print_dots "Sending Email alert: SendGrid: ${email}"
sendgridsend=$(curl -s --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header "Authorization: Bearer ${sendgridtoken}" \
--header 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": ${sendgridemail}"}]}],"from": {"email": "${sendgridemailfrom}"},"subject": "${alertemoji} ${alertsubject} ${alertemoji}","content": [{"type": "text/plain", "value": "$(cat "${alertlog}")"}]}')
if [ -z "${sendgridsend}" ]; then
fn_print_fail_nl "Sending Email alert: SendGrid: ${email}"
fn_script_log_fatal "Sending Email alert: SendGrid: ${email}"
else
fn_print_ok_nl "Sending Email alert: SendGrid: ${email}"
fn_script_log_pass "Sending Email alert: SendGrid: ${email}"
fi

103
lgsm/functions/alert_slack.sh

@ -13,54 +13,59 @@ fi
json=$(cat <<EOF json=$(cat <<EOF
{ {
"attachments": [ "attachments": [
{ {
"color": "#36a64f", "blocks": [
"blocks": [ {
{ "type": "section",
"type": "section", "text": {
"text": { "type": "mrkdwn",
"type": "mrkdwn", "text": "*${alertemoji} ${alertsubject} ${alertemoji}*"
"text": "*LinuxGSM Alert*" }
} },
}, {
{ "type": "section",
"type": "section", "text": {
"text": { "type": "mrkdwn",
"type": "mrkdwn", "text": "*${servername}*"
"text": "*${alertemoji} ${alertsubject}* \n ${alertbody}" }
} },
}, {
{ "type": "section",
"type": "divider" "text": {
}, "type": "mrkdwn",
{ "text": "${alertbody} \n More info: ${alerturl}"
"type": "section", }
"fields": [ },
{ {
"type": "mrkdwn", "type": "divider"
"text": "*Game:* \n ${gamename}" },
}, {
{ "type": "section",
"type": "mrkdwn", "fields": [
"text": "*Server IP:* \n ${alertip}:${port}" {
}, "type": "mrkdwn",
{ "text": "*Game:* \n ${gamename}"
"type": "mrkdwn", },
"text": "*Server Name:* \n ${servername}" {
} "type": "mrkdwn",
] "text": "*Server IP:* \n ${alertip}:${port}"
}, }
{ ]
"type": "section", },
"text": { {
"type": "mrkdwn", "type": "divider"
"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}" },
} {
} "type": "section",
] "text": {
} "type": "mrkdwn",
] "text": "*Hostname:* ${HOSTNAME}"
}
}
]
}
]
} }
EOF EOF
) )
@ -73,6 +78,6 @@ if [ "${slacksend}" == "ok" ]; then
fn_print_ok_nl "Sending Slack alert" fn_print_ok_nl "Sending Slack alert"
fn_script_log_pass "Sending Slack alert" fn_script_log_pass "Sending Slack alert"
else else
fn_print_fail_nl "Sending Slack alert: ${slacksend}" fn_print_fail_nl "Sending Slack alert: ${slacksend}"
fn_script_log_fatal "Sending Slack alert: ${slacksend}" fn_script_log_fatal "Sending Slack alert: ${slacksend}"
fi fi

5
lgsm/functions/core_functions.sh

@ -569,6 +569,11 @@ functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_sendgrid.sh(){
functionfile="${FUNCNAME[0]}"
fn_fetch_function
}
alert_slack.sh(){ alert_slack.sh(){
functionfile="${FUNCNAME[0]}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function

16
lgsm/functions/info_config.sh

@ -1064,15 +1064,15 @@ fn_info_config_unreal2(){
webadminuser="${unavailable}" webadminuser="${unavailable}"
webadminpass="${unavailable}" webadminpass="${unavailable}"
else else
servername=$(grep "ServerName" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'| sed 's/\r$//') servername=$(sed -nr 's/^ServerName=(.*)$/\1/p' "${servercfgfullpath}" | tr -d '=\";,:' | sed 's/\r$//')
serverpassword=$(grep "GamePassword" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/GamePassword//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'| sed 's/\r$//') serverpassword=$(sed -nr 's/^GamePassword=(.*)$/\1/p' "${servercfgfullpath}" | tr -d '=\";,:' | sed 's/\r$//')
adminpassword=$(grep "AdminPassword" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/AdminPassword//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'| sed 's/\r$//') adminpassword=$(sed -nr 's/^AdminPassword=(.*)$/\1/p' "${servercfgfullpath}" | tr -d '=\";,:' | sed 's/\r$//')
port=$(grep "Port" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' | grep "^Port" | grep -v "#" | tr -cd '[:digit:]') port=$(sed -nr 's/^Port=(.*)$/\1/p' "${servercfgfullpath}" | tr -cd '[:digit:]')
queryport=$((port + 1)) queryport=$((port + 1))
queryportgs=$(grep "OldQueryPortNumber" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') queryportgs=$(sed -nr 's/^OldQueryPortNumber=(.*)$/\1/p' "${servercfgfullpath}" | tr -cd '[:digit:]')
webadminenabled=$(grep "bEnabled" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/bEnabled//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'| sed 's/\r$//') webadminenabled=$(sed -nr 's/^bEnabled=(.*)$/\1/p' "${servercfgfullpath}" | tr -d '=\";,:' | sed 's/\r$//')
webadminport=$(grep "ListenPort" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') webadminport=$(sed -nr 's/^ListenPort=(.*)$/\1/p' "${servercfgfullpath}" | tr -cd '[:digit:]')
webadminuser=$(grep "AdminName" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/AdminName//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'| sed 's/\r$//') webadminuser=$(sed -nr 's/^AdminName=(.*)$/\1/p' "${servercfgfullpath}" | tr -d '=\";,:' | sed 's/\r$//')
webadminpass="${adminpassword}" webadminpass="${adminpassword}"
# Not Set # Not Set

0
lgsm/functions/update_factorio.sh

0
lgsm/functions/update_minecraft_bedrock.sh

0
lgsm/functions/update_mta.sh

0
lgsm/functions/update_mumble.sh

0
lgsm/functions/update_ts3.sh

Loading…
Cancel
Save