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

8
lgsm/functions/alert_discord.sh

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

2
lgsm/functions/alert_gotify.sh

@ -10,7 +10,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
json=$(cat <<EOF
{
"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
}
EOF

2
lgsm/functions/alert_ifttt.sh

@ -11,7 +11,7 @@ json=$(cat <<EOF
{
"value1": "${selfname}",
"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
)

2
lgsm/functions/alert_pushbullet.sh

@ -12,7 +12,7 @@ json=$(cat <<EOF
"channel_tag": "${channeltag}",
"type": "note",
"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
)

2
lgsm/functions/alert_pushover.sh

@ -22,7 +22,7 @@ else
alertpriority="0"
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
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
{
"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": [
{
"fields": [

50
lgsm/functions/alert_slack.sh

@ -36,12 +36,12 @@ json=$(cat <<EOF
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${alertemoji} ${alerttitle}* \n ${alertmessage}"
"text": "*${alertemoji} ${alerttitle} ${alertemoji}*"
},
"accessory": {
"type": "image",
"image_url": "${alertimage}",
"alt_text": "Alert Image"
"alt_text": "${alertimagealt}"
}
},
{
@ -50,7 +50,7 @@ json=$(cat <<EOF
{
"type": "image",
"image_url": "${alerticon}",
"alt_text": "Alert Icon"
"alt_text": "${alerticonalt}"
},
{
"type": "mrkdwn",
@ -63,48 +63,77 @@ json=$(cat <<EOF
"fields": [
{
"type": "mrkdwn",
"text": "*Maxplayers*"
"text": "*Game*"
},
{
"type": "mrkdwn",
"text": "*Map*"
"text": "*${alertplayerstitle}*"
},
{
"type": "mrkdwn",
"text": "${alertplayers}"
"text": "${gamename}"
},
{
"type": "mrkdwn",
"text": "${alertmap}"
"text": "${alertplayers}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Map*"
},
{
"type": "mrkdwn",
"text": "*Server IP*"
},
{
"type": "mrkdwn",
"text": "*Hostname*"
"text": "${alertmap}"
},
{
"type": "mrkdwn",
"text": "${alertip}:${port}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Hostname*"
},
{
"type": "mrkdwn",
"text": "*Version*"
},
{
"type": "mrkdwn",
"text": "${HOSTNAME}"
},
{
"type": "mrkdwn",
"text": "${alertversion}"
}
]
},
{
"type": "section",
"text": {
"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
}
]
},
{
"type": "divider"
}
]
}

2
lgsm/functions/alert_telegram.sh

@ -11,7 +11,7 @@ json=$(cat <<EOF
{
"chat_id": "${telegramchatid}",
"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"
}
EOF

Loading…
Cancel
Save