Browse Source

more info

feature/alerts-refactor
Daniel Gibbs 4 years ago
parent
commit
f26101c816
No known key found for this signature in database GPG Key ID: 2EBB36015C6D78E2
  1. 16
      lgsm/functions/alert.sh
  2. 8
      lgsm/functions/alert_discord.sh
  3. 2
      lgsm/functions/alert_gotify.sh
  4. 2
      lgsm/functions/alert_ifttt.sh
  5. 2
      lgsm/functions/alert_pushbullet.sh
  6. 2
      lgsm/functions/alert_pushover.sh
  7. 2
      lgsm/functions/alert_rocketchat.sh
  8. 50
      lgsm/functions/alert_slack.sh
  9. 2
      lgsm/functions/alert_telegram.sh

16
lgsm/functions/alert.sh

@ -35,7 +35,6 @@ fn_alert_test(){
alerttitle="Alert - ${selfname} - Test" alerttitle="Alert - ${selfname} - Test"
alertemoji="🚧" alertemoji="🚧"
alertsound="1" alertsound="1"
alerturl="not enabled"
alerttriggermessage="Testing LinuxGSM Alert. No action to be taken." alerttriggermessage="Testing LinuxGSM Alert. No action to be taken."
# Green # Green
alertcolourhex="#cdcd00" alertcolourhex="#cdcd00"
@ -47,7 +46,6 @@ fn_alert_restart(){
alerttitle="Alert - ${selfname} - Restarted" alerttitle="Alert - ${selfname} - Restarted"
alertemoji="🚨" alertemoji="🚨"
alertsound="2" alertsound="2"
alerturl="not enabled"
alerttriggermessage="${selfname} is not running. Game Server has been restarted." alerttriggermessage="${selfname} is not running. Game Server has been restarted."
# Red # Red
alertcolourhex="#cd0000" alertcolourhex="#cd0000"
@ -59,7 +57,6 @@ fn_alert_restart_query(){
alerttitle="Alert - ${selfname} - Restarted" alerttitle="Alert - ${selfname} - Restarted"
alertemoji="🚨" alertemoji="🚨"
alertsound="2" alertsound="2"
alerturl="not enabled"
alerttriggermessage="Unable to query ${selfname}. Game server has been restarted." alerttriggermessage="Unable to query ${selfname}. Game server has been restarted."
# Red # Red
alertcolourhex="#cd0000" alertcolourhex="#cd0000"
@ -71,7 +68,6 @@ fn_alert_update(){
alerttitle="Alert - ${selfname} - Updated" alerttitle="Alert - ${selfname} - Updated"
alertemoji="🎉" alertemoji="🎉"
alertsound="1" alertsound="1"
alerturl="not enabled"
alerttriggermessage="${selfname} has received an update." alerttriggermessage="${selfname} has received an update."
# Green # Green
alertcolourhex="#00cd00" alertcolourhex="#00cd00"
@ -83,7 +79,6 @@ fn_alert_check_update(){
alerttitle="Alert - ${selfname} - Update available" alerttitle="Alert - ${selfname} - Update available"
alertemoji="💿" alertemoji="💿"
alertsound="1" alertsound="1"
alerturl="not enabled"
alerttriggermessage="Update available for ${selfname}." alerttriggermessage="Update available for ${selfname}."
# Blue # Blue
alertcolourhex="#1e90ff" alertcolourhex="#1e90ff"
@ -95,7 +90,6 @@ fn_alert_permissions(){
alerttitle="Alert - ${selfname}: Permissions error" alerttitle="Alert - ${selfname}: Permissions error"
alertemoji="❗" alertemoji="❗"
alertsound="2" alertsound="2"
alerturl="not enabled"
alerttriggermessage="${selfname} has permissions issues." alerttriggermessage="${selfname} has permissions issues."
# Red # Red
alertcolourhex="#cd0000" alertcolourhex="#cd0000"
@ -107,7 +101,6 @@ fn_alert_config(){
alerttitle="Alert - ${selfname} - New _default.cfg" alerttitle="Alert - ${selfname} - New _default.cfg"
alertemoji="📄" alertemoji="📄"
alertsound="1" alertsound="1"
alerturl="not enabled"
alerttriggermessage="${selfname} has received a new _default.cfg. Check file for changes." alerttriggermessage="${selfname} has received a new _default.cfg. Check file for changes."
# Blue # Blue
alertcolourhex="#1e90ff" alertcolourhex="#1e90ff"
@ -119,7 +112,6 @@ fn_alert_wipe(){
alerttitle="Alert - ${selfname} - Wiped" alerttitle="Alert - ${selfname} - Wiped"
alertemoji="🧹" alertemoji="🧹"
alertsound="1" alertsound="1"
alerturl="not enabled"
alerttriggermessage="${selfname} as been wiped." alerttriggermessage="${selfname} as been wiped."
# Green # Green
alertcolourhex="#00cd00" alertcolourhex="#00cd00"
@ -173,16 +165,24 @@ else
alertversion="Unknown" alertversion="Unknown"
fi fi
if [ "${postalert}" == "on" ]; then
alertmoreinfo="More info"
fi
# Images # Images
mapimagestatus="$(curl -o /dev/null -s -w "%{http_code}\n" https://raw.githubusercontent.com/${githubuser}/game-server-map-images/main/${shortname}/${alertmap}.jpg)" mapimagestatus="$(curl -o /dev/null -s -w "%{http_code}\n" https://raw.githubusercontent.com/${githubuser}/game-server-map-images/main/${shortname}/${alertmap}.jpg)"
if [ -n "${gdmap}" ]&&[ "${mapimagestatus}" == "200" ]; then if [ -n "${gdmap}" ]&&[ "${mapimagestatus}" == "200" ]; then
alertimage="https://raw.githubusercontent.com/${githubuser}/game-server-map-images/main/${shortname}/${gdmap}.jpg" alertimage="https://raw.githubusercontent.com/${githubuser}/game-server-map-images/main/${shortname}/${gdmap}.jpg"
alertimagealt="${gdmap}"
elif [ -n "${appid}" ]; then elif [ -n "${appid}" ]; then
alertimage="https://cdn.cloudflare.steamstatic.com/steam/apps/${gameappid}/header.jpg" alertimage="https://cdn.cloudflare.steamstatic.com/steam/apps/${gameappid}/header.jpg"
alertimagealt="${gamename} header"
else else
alertimage="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameheaders/${shortname}-header.jpg" alertimage="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameheaders/${shortname}-header.jpg"
alertimagealt="${gamename} header"
fi fi
alerticon="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameicons/${shortname}-icon.png" alerticon="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameicons/${shortname}-icon.png"
alerticonalt="${gamename} icon"
if [ "${alert}" == "permissions" ]; then if [ "${alert}" == "permissions" ]; then
fn_alert_permissions fn_alert_permissions

8
lgsm/functions/alert_discord.sh

@ -41,7 +41,7 @@ json=$(cat <<EOF
}, },
{ {
"name": "Server IP", "name": "Server IP",
"value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})", "value": "${alertip}:${port}",
"inline": true "inline": true
}, },
{ {
@ -56,7 +56,11 @@ json=$(cat <<EOF
}, },
{ {
"name": "Trigger Message", "name": "Trigger Message",
"value": "${alerttriggermessage} \n\n More info: ${alerturl}" "value": "${alerttriggermessage}"
},
{
"name": "${alertmoreinfo}",
"value": "${alertmoreinfourl}"
} }
], ],
"thumbnail": { "thumbnail": {

2
lgsm/functions/alert_gotify.sh

@ -10,7 +10,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
json=$(cat <<EOF json=$(cat <<EOF
{ {
"title": "${alertemoji} ${alerttitle} ${alertemoji}", "title": "${alertemoji} ${alerttitle} ${alertemoji}",
"message": "Server name\n${servername}\n\nTrigger Message\n${alerttriggermessage}\n\nGame\n${gamename}\n\nCurrent Players\n${alertplayers}\n\nMap\n${alertmap}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nVersion\n${alertversion}\n\nMore info\n${alerturl}", "message": "Server name\n${servername}\n\nTrigger Message\n${alerttriggermessage}\n\nGame\n${gamename}\n\nCurrent Players\n${alertplayers}\n\nMap\n${alertmap}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nVersion\n${alertversion}\n\nMore info\n${alertmoreinfourl}",
"priority": 5 "priority": 5
} }
EOF EOF

2
lgsm/functions/alert_ifttt.sh

@ -11,7 +11,7 @@ json=$(cat <<EOF
{ {
"value1": "${selfname}", "value1": "${selfname}",
"value2": "${alertemoji} ${alerttitle} ${alertemoji}", "value2": "${alertemoji} ${alerttitle} ${alertemoji}",
"value3": "Server name<br>${servername}<br><br>Trigger Message<br>${alerttriggermessage}<br><br>Game<br>${gamename}<br><br>${alertplayerstitle}<br>${alertplayers}<br><br>Map<br>${alertmap}<br><br>Server IP<br>${alertip}:${port}<br><br>Hostname<br>${HOSTNAME}<br><br>More info<br>${alerturl}" "value3": "Server name<br>${servername}<br><br>Trigger Message<br>${alerttriggermessage}<br><br>Game<br>${gamename}<br><br>${alertplayerstitle}<br>${alertplayers}<br><br>Map<br>${alertmap}<br><br>Server IP<br>${alertip}:${port}<br><br>Hostname<br>${HOSTNAME}<br><br>More info<br>${alertmoreinfourl}"
} }
EOF EOF
) )

2
lgsm/functions/alert_pushbullet.sh

@ -12,7 +12,7 @@ json=$(cat <<EOF
"channel_tag": "${channeltag}", "channel_tag": "${channeltag}",
"type": "note", "type": "note",
"title": "${alertemoji} ${alerttitle} ${alertemoji}", "title": "${alertemoji} ${alerttitle} ${alertemoji}",
"body": "Server name\n${servername}\n\nTrigger Message\n${alerttriggermessage}\n\nGame\n${gamename}\n\nCurrent Players\n${alertplayers}\n\nMap\n${alertmap}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nVersion\n${alertversion}\n\nMore info\n${alerturl}" "body": "Server name\n${servername}\n\nTrigger Message\n${alerttriggermessage}\n\nGame\n${gamename}\n\nCurrent Players\n${alertplayers}\n\nMap\n${alertmap}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nVersion\n${alertversion}\n\n${alertmoreinfo}\n${alertmoreinfourl}"
} }
EOF EOF
) )

2
lgsm/functions/alert_pushover.sh

@ -22,7 +22,7 @@ else
alertpriority="0" alertpriority="0"
fi fi
pushoversend=$(curl --connect-timeout 10 -sSL -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alerttitle} ${alertemoji}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Trigger Message</b><br>${alerttriggermessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Current Players</b><br>${alertplayers}<br><br><b>Map</b><br>${alertmap}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Version</b><br>${alertversion}<br><br><b>More info</b><br>${alerturl}" "https://api.pushover.net/1/messages.json" | grep errors) pushoversend=$(curl --connect-timeout 10 -sSL -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alerttitle} ${alertemoji}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Trigger Message</b><br>${alerttriggermessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Current Players</b><br>${alertplayers}<br><br><b>Map</b><br>${alertmap}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Version</b><br>${alertversion}<br><br><b>${alertmoreinfo}</b><br>${alertmoreinfourl}" "https://api.pushover.net/1/messages.json" | grep errors)
if [ -n "${pushoversend}" ]; then if [ -n "${pushoversend}" ]; then
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}" fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"

2
lgsm/functions/alert_rocketchat.sh

@ -10,7 +10,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
json=$(cat <<EOF json=$(cat <<EOF
{ {
"alias": "LinuxGSM", "alias": "LinuxGSM",
"text": "*${alertemoji} ${alerttitle} ${alertemoji}* \n *${servername}* \n ${alerttriggermessage} \n More info: ${alerturl}", "text": "*${alertemoji} ${alerttitle} ${alertemoji}* \n *${servername}* \n ${alerttriggermessage} \n More info: ${alertmoreinfourl}",
"attachments": [ "attachments": [
{ {
"fields": [ "fields": [

50
lgsm/functions/alert_slack.sh

@ -36,12 +36,12 @@ json=$(cat <<EOF
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*${alertemoji} ${alerttitle}* \n ${alertmessage}" "text": "*${alertemoji} ${alerttitle} ${alertemoji}*"
}, },
"accessory": { "accessory": {
"type": "image", "type": "image",
"image_url": "${alertimage}", "image_url": "${alertimage}",
"alt_text": "Alert Image" "alt_text": "${alertimagealt}"
} }
}, },
{ {
@ -50,7 +50,7 @@ json=$(cat <<EOF
{ {
"type": "image", "type": "image",
"image_url": "${alerticon}", "image_url": "${alerticon}",
"alt_text": "Alert Icon" "alt_text": "${alerticonalt}"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
@ -63,48 +63,77 @@ json=$(cat <<EOF
"fields": [ "fields": [
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Maxplayers*" "text": "*Game*"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Map*" "text": "*${alertplayerstitle}*"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "${alertplayers}" "text": "${gamename}"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "${alertmap}" "text": "${alertplayers}"
} }
] ]
}, },
{ {
"type": "section", "type": "section",
"fields": [ "fields": [
{
"type": "mrkdwn",
"text": "*Map*"
},
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Server IP*" "text": "*Server IP*"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Hostname*" "text": "${alertmap}"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "${alertip}:${port}" "text": "${alertip}:${port}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Hostname*"
},
{
"type": "mrkdwn",
"text": "*Version*"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "${HOSTNAME}" "text": "${HOSTNAME}"
},
{
"type": "mrkdwn",
"text": "${alertversion}"
} }
] ]
}, },
{ {
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Trigger Message*\n${alerttriggermessage} \n More info: ${alerturl}" "text": "*Trigger Message*\n${alerttriggermessage}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${alertmoreinfo}*\n${alertmoreinfourl}"
} }
}, },
{ {
@ -124,6 +153,9 @@ json=$(cat <<EOF
"emoji": true "emoji": true
} }
] ]
},
{
"type": "divider"
} }
] ]
} }

2
lgsm/functions/alert_telegram.sh

@ -11,7 +11,7 @@ json=$(cat <<EOF
{ {
"chat_id": "${telegramchatid}", "chat_id": "${telegramchatid}",
"parse_mode": "HTML", "parse_mode": "HTML",
"text": "<b>${alertemoji} ${alerttitle} ${alertemoji}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Trigger Message</b>\n${alerttriggermessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Current Players</b>\n${alertplayers}\n\n<b>Map</b>\n${alertmap}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Version</b>\n${alertversion}\n\n<b>More info</b>\n${alerturl}", "text": "<b>${alertemoji} ${alerttitle} ${alertemoji}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Trigger Message</b>\n${alerttriggermessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Current Players</b>\n${alertplayers}\n\n<b>Map</b>\n${alertmap}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Version</b>\n${alertversion}\n\n<b>More info</b>\n${alertmoreinfourl}",
"disable_web_page_preview": "yes" "disable_web_page_preview": "yes"
} }
EOF EOF

Loading…
Cancel
Save