From 45c220a471c2a3a9b35387609b712d233a8583aa Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 18 Aug 2024 20:47:11 +0100 Subject: [PATCH 1/9] add ismygameserveronline --- lgsm/modules/alert_discord.sh | 102 +++++++--------------------------- 1 file changed, 21 insertions(+), 81 deletions(-) diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index c98bef765b..d5b1c464ec 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -7,7 +7,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -jsoninfo=$( +json=$( cat << EOF { "username": "LinuxGSM", @@ -29,14 +29,14 @@ jsoninfo=$( "url": "${alerticon}" }, "fields": [ - { - "name": "Server Name", - "value": "${servername}" - }, - { - "name": "Information", - "value": "${alertmessage}" - }, + { + "name": "Server Name", + "value": "${servername}" + }, + { + "name": "Information", + "value": "${alertmessage}" + }, { "name": "Game", "value": "${gamename}", @@ -52,80 +52,26 @@ jsoninfo=$( "value": "${HOSTNAME}", "inline": true }, +EOF +) + +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF { "name": "Is my Game Server Online?", "value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}", "inline": true }, - { - "name": "More info", - "value": "${alerturl}", - "inline": true - }, - { - "name": "Server Time", - "value": "$(date)", - "inline": true - } - ], - "footer": { - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "text": "Sent by LinuxGSM ${version}" - } - } - ] -} EOF -) + ) +fi -jsonnoinfo=$( +json+=$( cat << EOF -{ - "username": "LinuxGSM", - "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "file": "content", - "embeds": [ - { - "author": { - "name": "LinuxGSM Alert", - "url": "", - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" - }, - "title": "${alerttitle}", - "url": "", - "description": "", - "color": "${alertcolourdec}", - "type": "content", - "thumbnail": { - "url": "${alerticon}" - }, - "fields": [ - { - "name": "Server Name", - "value": "${servername}" - }, - { - "name": "Information", - "value": "${alertmessage}" - }, - { - "name": "Game", - "value": "${gamename}", - "inline": true - }, { - "name": "Server IP", - "value": "\`${alertip}:${port}\`", - "inline": true - }, - { - "name": "Hostname", - "value": "${HOSTNAME}", - "inline": true - }, - { - "name": "Is my Game Server Online?", - "value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}", + "name": "More info", + "value": "${alerturl}", "inline": true }, { @@ -135,7 +81,7 @@ jsonnoinfo=$( } ], "footer": { - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "text": "Sent by LinuxGSM ${version}" } } @@ -146,12 +92,6 @@ EOF fn_print_dots "Sending Discord alert" -if [ -z "${alerturl}" ]; then - json="${jsonnoinfo}" -else - json="${jsoninfo}" -fi - discordsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}") if [ -n "${discordsend}" ]; then From ad60556722a7b08ab73cb2a55de11011e07f65db Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 18 Aug 2024 20:59:04 +0100 Subject: [PATCH 2/9] feat(alerts): add ismygameserver.online --- lgsm/modules/alert_discord.sh | 128 +++++++-------- lgsm/modules/alert_gotify.sh | 38 +++-- lgsm/modules/alert_ifttt.sh | 38 +++-- lgsm/modules/alert_pushbullet.sh | 41 ++--- lgsm/modules/alert_pushover.sh | 24 ++- lgsm/modules/alert_rocketchat.sh | 176 +++++++++----------- lgsm/modules/alert_slack.sh | 266 ++++++++++++------------------- lgsm/modules/alert_telegram.sh | 47 +++--- lgsm/modules/info_messages.sh | 5 + 9 files changed, 355 insertions(+), 408 deletions(-) diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index d5b1c464ec..c0434df899 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -10,82 +10,82 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$( cat << EOF { - "username": "LinuxGSM", - "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "file": "content", - "embeds": [ - { - "author": { - "name": "LinuxGSM Alert", - "url": "", - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" - }, - "title": "${alerttitle}", - "url": "", - "description": "", - "color": "${alertcolourdec}", - "type": "content", - "thumbnail": { - "url": "${alerticon}" - }, - "fields": [ - { - "name": "Server Name", - "value": "${servername}" - }, - { - "name": "Information", - "value": "${alertmessage}" - }, - { - "name": "Game", - "value": "${gamename}", - "inline": true - }, - { - "name": "Server IP", - "value": "\`${alertip}:${port}\`", - "inline": true - }, - { - "name": "Hostname", - "value": "${HOSTNAME}", - "inline": true - }, + "username": "LinuxGSM", + "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "file": "content", + "embeds": [ + { + "author": { + "name": "LinuxGSM Alert", + "url": "", + "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" + }, + "title": "${alerttitle}", + "url": "", + "description": "", + "color": "${alertcolourdec}", + "type": "content", + "thumbnail": { + "url": "${alerticon}" + }, + "fields": [ + { + "name": "Server Name", + "value": "${servername}" + }, + { + "name": "Information", + "value": "${alertmessage}" + }, + { + "name": "Game", + "value": "${gamename}", + "inline": true + }, + { + "name": "Server IP", + "value": "\`${alertip}:${port}\`", + "inline": true + }, + { + "name": "Hostname", + "value": "${HOSTNAME}", + "inline": true + }, EOF ) if [ -n "${querytype}" ]; then json+=$( cat << EOF - { - "name": "Is my Game Server Online?", - "value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}", - "inline": true - }, + { + "name": "Is my Game Server Online?", + "value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}", + "inline": true + }, EOF ) fi json+=$( cat << EOF - { - "name": "More info", - "value": "${alerturl}", - "inline": true - }, - { - "name": "Server Time", - "value": "$(date)", - "inline": true - } - ], - "footer": { - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "text": "Sent by LinuxGSM ${version}" - } - } - ] + { + "name": "More info", + "value": "${alerturl}", + "inline": true + }, + { + "name": "Server Time", + "value": "$(date)", + "inline": true + } + ], + "footer": { + "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "text": "Sent by LinuxGSM ${version}" + } + } + ] } EOF ) diff --git a/lgsm/modules/alert_gotify.sh b/lgsm/modules/alert_gotify.sh index 8f1d31e918..63f083b3b9 100644 --- a/lgsm/modules/alert_gotify.sh +++ b/lgsm/modules/alert_gotify.sh @@ -7,32 +7,38 @@ module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -jsoninfo=$( +json=$( cat << EOF { - "title": "${alerttitle}", - "message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)", - "priority": 5 -} + "title": "${alerttitle}", + "message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) -jsonnoinfo=$( +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF +Is my Game Server Online?\nhttps://ismygameserver.online/${querytype}/${alertip}:${queryport}\n\n +EOF + ) +fi + +if [ -n "${alerturl}" ]; then + json+=$( + cat << EOF +More info\n${alerturl}\n\n +EOF + ) +fi + +json+=$( cat << EOF -{ - "title": "${alerttitle}", - "message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)", - "priority": 5 +Server Time\n$(date)", + "priority": 5 } EOF ) -if [ -z "${alerturl}" ]; then - json="${jsonnoinfo}" -else - json="${jsoninfo}" -fi - fn_print_dots "Sending Gotify alert" gotifysend=$(curl --connect-timeout 3 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)") diff --git a/lgsm/modules/alert_ifttt.sh b/lgsm/modules/alert_ifttt.sh index cbd740ec50..5d4660b1c8 100644 --- a/lgsm/modules/alert_ifttt.sh +++ b/lgsm/modules/alert_ifttt.sh @@ -7,32 +7,38 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -jsoninfo=$( +json=$( cat << EOF { - "value1": "${selfname}", - "value2": "${alerttitle}", - "value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)" -} + "value1": "${selfname}", + "value2": "${alerttitle}", + "value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) -jsonnoinfo=$( +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF +Is my Game Server Online?\nhttps://ismygameserver.online/${querytype}/${alertip}:${queryport}\n\n +EOF + ) +fi + +if [ -n "${alerturl}" ]; then + json+=$( + cat << EOF +More info\n${alerturl}\n\n +EOF + ) +fi + +json+=$( cat << EOF -{ - "value1": "${selfname}", - "value2": "${alerttitle}", - "value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)" +Server Time\n$(date)" } EOF ) -if [ -z "${alerturl}" ]; then - json="${jsonnoinfo}" -else - json="${jsoninfo}" -fi - fn_print_dots "Sending IFTTT alert" iftttsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request") diff --git a/lgsm/modules/alert_pushbullet.sh b/lgsm/modules/alert_pushbullet.sh index 5ed3853f66..4a47df4425 100644 --- a/lgsm/modules/alert_pushbullet.sh +++ b/lgsm/modules/alert_pushbullet.sh @@ -7,34 +7,39 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -jsoninfo=$( +json=$( cat << EOF { - "channel_tag": "${channeltag}", - "type": "note", - "title": "${alerttitle}", - "body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)" -} + "channel_tag": "${channeltag}", + "type": "note", + "title": "${alerttitle}", + "body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) -jsonnoinfo=$( +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF +Is my Game Server Online?\nhttps://ismygameserver.online/${querytype}/${alertip}:${queryport}\n\n +EOF + ) +fi + +if [ -n "${alerturl}" ]; then + json+=$( + cat << EOF +More info\n${alerturl}\n\n +EOF + ) +fi + +json+=$( cat << EOF -{ - "channel_tag": "${channeltag}", - "type": "note", - "title": "${alerttitle}", - "body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)" +Server Time\n$(date)" } EOF ) -if [ -z "${alerturl}" ]; then - json="${jsonnoinfo}" -else - json="${jsoninfo}" -fi - fn_print_dots "Sending Pushbullet alert" pushbulletsend=$(curl --connect-timeout 3 -sSL -H "Access-Token: ${pushbullettoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://api.pushbullet.com/v2/pushes" | grep "error_code") diff --git a/lgsm/modules/alert_pushover.sh b/lgsm/modules/alert_pushover.sh index 22180d503d..246cffff1b 100644 --- a/lgsm/modules/alert_pushover.sh +++ b/lgsm/modules/alert_pushover.sh @@ -22,12 +22,28 @@ else alertpriority="0" fi -if [ -z "${alerturl}" ]; then - pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}

Server Time
$(date)" "https://api.pushover.net/1/messages.json" | grep errors) -else - pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}

More info
${alerturl}

Server Time
$(date)" "https://api.pushover.net/1/messages.json" | grep errors) +message=" Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}

" + +if [ -n "${querytype}" ]; then + message+="Is my Game Server Online?
Check here

" +fi + +if [ -n "${alerturl}" ]; then + message+="More info
${alerturl}

" fi +message+="Server Time
$(date)" + +pushoversend=$(curl --connect-timeout 3 -sS \ + -F token="${pushovertoken}" \ + -F user="${pushoveruserkey}" \ + -F html="1" \ + -F sound="${alertsound}" \ + -F priority="${alertpriority}" \ + -F title="${alerttitle}" \ + -F message="${message}" \ + "https://api.pushover.net/1/messages.json" | grep errors) + if [ -n "${pushoversend}" ]; then fn_print_fail_nl "Sending Pushover alert: ${pushoversend}" fn_script_log_fail "Sending Pushover alert: ${pushoversend}" diff --git a/lgsm/modules/alert_rocketchat.sh b/lgsm/modules/alert_rocketchat.sh index 9107228041..e9cf83b22b 100644 --- a/lgsm/modules/alert_rocketchat.sh +++ b/lgsm/modules/alert_rocketchat.sh @@ -7,121 +7,87 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -jsoninfo=$( +json=$( cat << EOF { - "alias": "LinuxGSM", - "text": "*${alerttitle}*", - "attachments": [ - { - "title": "", - "color": "${alertcolourhex}", - "author_name": "LinuxGSM Alert", - "author_link": "https://linuxgsm.com", - "author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "thumb_url": "${alerticon}", - "text": "", - "fields": [ - { - "short": false, - "title": "Server Name", - "value": "${servername}" - }, - { - "short": false, - "title": "Information", - "value": "${alertmessage}" - }, - { - "short": false, - "title": "Game", - "value": "${gamename}" - }, - { - "short": false, - "title": "Server IP", - "value": "${alertip}:${port}" - }, - { - "short": false, - "title": "Hostname", - "value": "${HOSTNAME}" - }, - { - "short": false, - "title": "More info", - "value": "${alerturl}" - }, - { - "short": false, - "title": "Server Time", - "value": "$(date)" - } - ] - } - ] -} + "alias": "LinuxGSM", + "text": "*${alerttitle}*", + "attachments": [ + { + "title": "", + "color": "${alertcolourhex}", + "author_name": "LinuxGSM Alert", + "author_link": "https://linuxgsm.com", + "author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "thumb_url": "${alerticon}", + "text": "", + "fields": [ + { + "short": false, + "title": "Server Name", + "value": "${servername}" + }, + { + "short": false, + "title": "Information", + "value": "${alertmessage}" + }, + { + "short": false, + "title": "Game", + "value": "${gamename}" + }, + { + "short": false, + "title": "Server IP", + "value": "${alertip}:${port}" + }, + { + "short": false, + "title": "Hostname", + "value": "${HOSTNAME}" + }, EOF ) -jsonnoinfo=$( +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF + { + "short": false, + "title": "Is my Game Server Online?", + "value": "" + }, +EOF + ) +fi + +if [ -n "${alerturl}" ]; then + json+=$( + cat << EOF + { + "short": false, + "title": "More info", + "value": "${alerturl}" + }, +EOF + ) +fi + +json+=$( cat << EOF -{ - "alias": "LinuxGSM", - "text": "*${alerttitle}*", - "attachments": [ - { - "title": "", - "color": "${alertcolourhex}", - "author_name": "LinuxGSM Alert", - "author_link": "https://linuxgsm.com", - "author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "thumb_url": "${alerticon}", - "text": "", - "fields": [ - { - "short": false, - "title": "Server Name", - "value": "${servername}" - }, - { - "short": false, - "title": "Information", - "value": "${alertmessage}" - }, - { - "short": false, - "title": "Game", - "value": "${gamename}" - }, - { - "short": false, - "title": "Server IP", - "value": "${alertip}:${port}" - }, - { - "short": false, - "title": "Hostname", - "value": "${HOSTNAME}" - }, - { - "short": false, - "title": "Server Time", - "value": "$(date)" - } - ] - } - ] + { + "short": false, + "title": "Server Time", + "value": "$(date)" + } + ] + } + ] } EOF ) -if [ -z "${alerturl}" ]; then - json="${jsonnoinfo}" -else - json="${jsoninfo}" -fi - fn_print_dots "Sending Rocketchat alert" rocketchatsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${rocketchatwebhook}") diff --git a/lgsm/modules/alert_slack.sh b/lgsm/modules/alert_slack.sh index b74f98decb..2565ea8324 100644 --- a/lgsm/modules/alert_slack.sh +++ b/lgsm/modules/alert_slack.sh @@ -7,179 +7,119 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -jsonnoinfo=$( +json=$( cat << EOF { - "attachments": [ - { - "color": "${alertcolourhex}", - "blocks": [ - { - "type": "header", - "text": { - "type": "mrkdwn", - "text": "${alerttitle}", - "emoji": true - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Server Name*\n${servername}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Information*\n${alertmessage}" - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Game*\n${gamename}" - }, - { - "type": "mrkdwn", - "text": "*Server IP*\n\`${alertip}:${port}\`" - }, - { - "type": "mrkdwn", - "text": "*Hostname*\n${HOSTNAME}" - }, - { - "type": "mrkdwn", - "text": "*Server Time*\n$(date)" - } - ], - "accessory": { - "type": "image", - "image_url": "${alerticon}", - "alt_text": "cute cat" - } - }, - { - "type": "context", - "elements": [ - { - "type": "image", - "image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "alt_text": "LinuxGSM icon" - }, - { - "type": "plain_text", - "text": "Sent by LinuxGSM ${version}", - "emoji": true - } - ] - } - ] - } - ] -} + "attachments": [ + { + "color": "${alertcolourhex}", + "blocks": [ + { + "type": "header", + "text": { + "type": "mrkdwn", + "text": "${alerttitle}", + "emoji": true + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Server Name*\n${servername}" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Information*\n${alertmessage}" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Game*\n${gamename}" + }, + { + "type": "mrkdwn", + "text": "*Server IP*\n\`${alertip}:${port}\`" + }, + { + "type": "mrkdwn", + "text": "*Hostname*\n${HOSTNAME}" + }, + { + "type": "mrkdwn", + "text": "*Server Time*\n$(date)" + } + ], + "accessory": { + "type": "image", + "image_url": "${alerticon}", + "alt_text": "cute cat" + } + }, EOF ) -jsoninfo=$( +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Is my Game Server Online?*\n" + } + }, +EOF + ) +fi + +if [ -n "${alerturl}" ]; then + json+=$( + cat << EOF + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*More info*\n<${alerturl}|${alerturl}>" + } + }, +EOF + ) +fi + +json+=$( cat << EOF -{ - "attachments": [ - { - "color": "${alertcolourhex}", - "blocks": [ - { - "type": "header", - "text": { - "type": "mrkdwn", - "text": "${alerttitle}", - "emoji": true - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Server Name*\n${servername}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Information*\n${alertmessage}" - } - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Game*\n${gamename}" - }, - { - "type": "mrkdwn", - "text": "*Server IP*\n\`${alertip}:${port}\`" - }, - { - "type": "mrkdwn", - "text": "*Hostname*\n${HOSTNAME}" - }, - { - "type": "mrkdwn", - "text": "*Server Time*\n$(date)" - } - ], - "accessory": { - "type": "image", - "image_url": "${alerticon}", - "alt_text": "cute cat" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Server Time*\n${alertmessage}" - } - }, - { - "type": "context", - "elements": [ - { - "type": "image", - "image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "alt_text": "LinuxGSM icon" - }, - { - "type": "plain_text", - "text": "Sent by LinuxGSM ${version}", - "emoji": true - } - ] - } - ] - } - ] + { + "type": "context", + "elements": [ + { + "type": "image", + "image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "alt_text": "LinuxGSM icon" + }, + { + "type": "plain_text", + "text": "Sent by LinuxGSM ${version}", + "emoji": true + } + ] + } + ] + } + ] } EOF ) -if [ -z "${alerturl}" ]; then - json="${jsonnoinfo}" -else - json="${jsoninfo}" -fi - fn_print_dots "Sending Slack alert" slacksend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${slackwebhook}") diff --git a/lgsm/modules/alert_telegram.sh b/lgsm/modules/alert_telegram.sh index 98e1a980b3..e504c62bb4 100644 --- a/lgsm/modules/alert_telegram.sh +++ b/lgsm/modules/alert_telegram.sh @@ -7,38 +7,41 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -jsoninfo=$( +json=$( cat << EOF { - "chat_id": "${telegramchatid}", - "message_thread_id": "${telegramthreadid}", - "parse_mode": "HTML", - "disable_notification": "${telegramdisablenotification}", - "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)", - "disable_web_page_preview": "yes" -} + "chat_id": "${telegramchatid}", + "message_thread_id": "${telegramthreadid}", + "parse_mode": "HTML", + "disable_notification": "${telegramdisablenotification}", + "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) -jsonnoinfo=$( +if [ -n "${querytype}" ]; then + json+=$( + cat << EOF +Is my Game Server Online?\nCheck here\n\n +EOF + ) +fi + +if [ -n "${alerturl}" ]; then + json+=$( + cat << EOF +More info\n${alerturl}\n\n +EOF + ) +fi + +json+=$( cat << EOF -{ - "chat_id": "${telegramchatid}", - "message_thread_id": "${telegramthreadid}", - "parse_mode": "HTML", - "disable_notification": "${telegramdisablenotification}", - "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)", - "disable_web_page_preview": "yes" +Server Time\n$(date)", + "disable_web_page_preview": "yes" } EOF ) -if [ -z "${alerturl}" ]; then - json="${jsonnoinfo}" -else - json="${jsoninfo}" -fi - fn_print_dots "Sending Telegram alert" telegramsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code") diff --git a/lgsm/modules/info_messages.sh b/lgsm/modules/info_messages.sh index 9bab0cbb72..c1d2086912 100644 --- a/lgsm/modules/info_messages.sh +++ b/lgsm/modules/info_messages.sh @@ -66,6 +66,11 @@ fn_info_messages_head() { echo -e "Hostname" echo -e "${HOSTNAME}" echo -e "" + if [ -n "${querytype}" ]; then + echo -e "Is my Game Server Online?" + echo -e "https://ismygameserver.online/${querytype}/${alertip}:${queryport}" + echo -e "" + fi echo -e "Server Time" echo -e "$(date)" } From 57387b016e3715d6612d5ae35e0f67ceef778985 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Sep 2024 22:13:08 +0100 Subject: [PATCH 3/9] changed to error --- lgsm/modules/check_permissions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/modules/check_permissions.sh b/lgsm/modules/check_permissions.sh index 44c527bfb5..5b99f2e80b 100644 --- a/lgsm/modules/check_permissions.sh +++ b/lgsm/modules/check_permissions.sh @@ -63,8 +63,8 @@ fn_check_permissions() { findnotexecutable="$(find "${modulesdir}" -type f -not -executable)" findnotexecutablewc="$(find "${modulesdir}" -type f -not -executable | wc -l)" if [ "${findnotexecutablewc}" -ne "0" ]; then - fn_print_fail_nl "Permissions issues found" - fn_script_log_fail "Permissions issues found" + fn_print_error_nl "Permissions issues found" + fn_script_log_error "Permissions issues found" fn_print_information_nl "The following files are not executable:" fn_script_log_info "The following files are not executable:" { From be7a42fa460726ed6333961111ed5ad9dd342c34 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 16 Sep 2024 20:31:01 +0100 Subject: [PATCH 4/9] add to details --- lgsm/modules/info_messages.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lgsm/modules/info_messages.sh b/lgsm/modules/info_messages.sh index 32a02a4849..391ed66e42 100644 --- a/lgsm/modules/info_messages.sh +++ b/lgsm/modules/info_messages.sh @@ -508,6 +508,11 @@ fn_info_messages_gameserver() { else echo -e "${lightblue}Status:\t${green}STARTED${default}" fi + + # ismygameserver.online + if [ -n "${querytype}" ]; then + echo -e "${lightblue}Query Check:\t${default}https://ismygameserver.online/${querytype}/${alertip}:${queryport}" + fi } | column -s $'\t' -t echo -e "" } From 41b2488b542bf0c52ed6ed81f06bbc80f471bd2d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 16 Sep 2024 20:33:28 +0100 Subject: [PATCH 5/9] add ismgso to query check --- lgsm/modules/command_dev_query_raw.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lgsm/modules/command_dev_query_raw.sh b/lgsm/modules/command_dev_query_raw.sh index 39f4787d30..33730b56c8 100644 --- a/lgsm/modules/command_dev_query_raw.sh +++ b/lgsm/modules/command_dev_query_raw.sh @@ -204,9 +204,14 @@ echo -e "" echo -e "PORT: ${port}" echo -e "QUERY PORT: ${queryport}" echo -e "" +echo -e "${lightgreen}Is My Game Server Online?${default}" +fn_messages_separator +echo -e "Game server status: https://ismygameserver.online/${querytype}/${queryip}:${queryport}" +echo -e "" echo -e "${lightgreen}Gamedig Raw Output${default}" fn_messages_separator echo -e "" + if [ ! "$(command -v gamedig 2> /dev/null)" ] && [ ! -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then fn_print_failure_nl "gamedig not installed" fi From b0d38a41bacb96005caefb9614595ca2cf9963bb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 16 Sep 2024 22:43:44 +0100 Subject: [PATCH 6/9] feat(ro): Migrate to using valve query by default --- .../config-lgsm/roserver/_default.cfg | 2 +- .../modules/command_dev_parse_game_details.sh | 8 ++--- lgsm/modules/core_messages.sh | 2 +- lgsm/modules/info_game.sh | 36 +++++++++---------- lgsm/modules/info_messages.sh | 19 +++++----- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/lgsm/config-default/config-lgsm/roserver/_default.cfg b/lgsm/config-default/config-lgsm/roserver/_default.cfg index c000f61816..0af49a0d4c 100644 --- a/lgsm/config-default/config-lgsm/roserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/roserver/_default.cfg @@ -142,7 +142,7 @@ stopmode="2" # 4: gsquery # 5: tcp querymode="2" -querytype="protocol-unreal2" +querytype="protocol-valve" ## Console type consoleverbose="yes" diff --git a/lgsm/modules/command_dev_parse_game_details.sh b/lgsm/modules/command_dev_parse_game_details.sh index 2e22aa7ae0..5938f817d4 100644 --- a/lgsm/modules/command_dev_parse_game_details.sh +++ b/lgsm/modules/command_dev_parse_game_details.sh @@ -74,12 +74,12 @@ declare -A server_details=( ['Port IPv6']="${portipv6}" ['Port']="${port}" ['Query Enabled']="${queryenabled}" - ['Query HTTP Port']="${queryhttpport}" - ['Query HTTPS Port']="${queryhttpsport}" + ['Query HTTP Port']="${httpqueryport}" + ['Query HTTPS Port']="${httpsqueryport}" ['Query Mode']="${querymode}" - ['Query Port GS']="${queryportgs}" + ['Query Port GS']="${gamespyqueryport}" ['Query Port']="${queryport}" - ['Query SSH Port']="${querysshport}" + ['Query SSH Port']="${sshqueryport}" ['Queue Enabled']="${queueenabled}" ['Queue Port']="${queueport}" ['Random Map']="${randommap}" diff --git a/lgsm/modules/core_messages.sh b/lgsm/modules/core_messages.sh index 6488c02bc3..52129dc4b5 100644 --- a/lgsm/modules/core_messages.sh +++ b/lgsm/modules/core_messages.sh @@ -31,7 +31,7 @@ fn_ansi_loader() { darkgrey="\e[90m" lightgrey="\e[37m" white="\e[97m" - # erase to end of line. + # erase to end of line. creeol+="\033[K" fi } diff --git a/lgsm/modules/info_game.sh b/lgsm/modules/info_game.sh index d56d4fbff9..5875627ca3 100644 --- a/lgsm/modules/info_game.sh +++ b/lgsm/modules/info_game.sh @@ -496,7 +496,7 @@ fn_info_game_kf() { fn_info_game_ini "lanport" "LANServerPort" fn_info_game_ini "maxplayers" "MaxPlayers" fn_info_game_ini "port" "Port" - fn_info_game_ini "queryportgs" "QueryPort" + fn_info_game_ini "gamespyqueryport" "QueryPort" fn_info_game_ini "servername" "ServerName" fn_info_game_ini "serverpassword" "GamePassword" fi @@ -510,7 +510,7 @@ fn_info_game_kf() { maxplayers="${maxplayers:-"0"}" port="${port:-"0"}" queryport="$((port + 1))" - queryportgs="${queryportgs:-"0"}" + gamespyqueryport="${gamespyqueryport:-"0"}" servername="${servername:-"NOT SET"}" serverpassword="${serverpassword:-"NOT SET"}" steamport="28852" @@ -754,19 +754,19 @@ fn_info_game_ts3() { fn_info_game_ini "dbplugin" "dbplugin" fn_info_game_ini "fileport" "filetransfer_port" fn_info_game_ini "port" "default_voice_port" - fn_info_game_ini "queryhttpport" "query_http_port" - fn_info_game_ini "queryhttpsport" "query_https_port" + fn_info_game_ini "httpqueryport" "query_http_port" + fn_info_game_ini "httpsqueryport" "query_https_port" fn_info_game_ini "queryport" "query_port" - fn_info_game_ini "querysshport" "query_ssh_port" + fn_info_game_ini "sshqueryport" "query_ssh_port" fi configip="${configip:-"0.0.0.0"}" dbplugin="${dbplugin:-"NOT SET"}" fileport="${fileport:-"0"}" port="${port:-"0"}" - queryhttpport="${queryhttpport:-"0"}" - queryhttpsport="${queryhttpsport:-"0"}" + httpqueryport="${httpqueryport:-"0"}" + httpsqueryport="${httpsqueryport:-"0"}" queryport="${queryport:-"0"}" - querysshport="${querysshport:-"0"}" + sshqueryport="${sshqueryport:-"0"}" telnetport="${queryport}" } @@ -797,7 +797,7 @@ fn_info_game_ut99() { fn_info_game_ini "adminpassword" "AdminPassword" fn_info_game_ini "beaconport" "ServerBeaconPort" fn_info_game_ini "port" "Port" - fn_info_game_ini "queryportgs" "OldQueryPortNumber" + fn_info_game_ini "gamespyqueryport" "OldQueryPortNumber" fn_info_game_ini "servername" "ServerName" fn_info_game_ini "serverpassword" "GamePassword" fn_info_game_ini "httpenabled" "bEnabled" @@ -811,7 +811,7 @@ fn_info_game_ut99() { httpport="${httpport:-"0"}" port="${port:-"0"}" queryport="$((port + 1))" - queryportgs="${queryportgs:-"0"}" + gamespyqueryport="${gamespyqueryport:-"0"}" servername="${servername:-"NOT SET"}" serverpassword="${serverpassword:-"NOT SET"}" httpenabled="${httpenabled:-"0"}" @@ -857,7 +857,7 @@ fn_info_game_unreal2() { fn_info_game_ini "adminpassword" "AdminPassword" fn_info_game_ini "httpport" "ListenPort" fn_info_game_ini "port" "Port" - fn_info_game_ini "queryportgs" "OldQueryPortNumber" + fn_info_game_ini "gamespyqueryport" "OldQueryPortNumber" fn_info_game_ini "servername" "ServerName" fn_info_game_ini "serverpassword" "GamePassword" fn_info_game_ini "httpenabled" "bEnabled" @@ -868,7 +868,7 @@ fn_info_game_unreal2() { httpport="${httpport:-"0"}" port="${port:-"0"}" queryport="$((port + 1))" - queryportgs="${queryportgs:-"0"}" + gamespyqueryport="${gamespyqueryport:-"0"}" servername="${servername:-"NOT SET"}" serverpassword="${serverpassword:-"NOT SET"}" httpenabled="${httpenabled:-"0"}" @@ -902,7 +902,7 @@ fn_info_game_ut2k4() { fn_info_game_ini "httpport" "ListenPort" fn_info_game_ini "lanport" "LANServerPort" fn_info_game_ini "port" "Port" - fn_info_game_ini "queryportgs" "OldQueryPortNumber" + fn_info_game_ini "gamespyqueryport" "OldQueryPortNumber" fn_info_game_ini "servername" "ServerName" fn_info_game_ini "serverpassword" "GamePassword" fn_info_game_ini "httpenabled" "bEnabled" @@ -914,7 +914,7 @@ fn_info_game_ut2k4() { lanport="${lanport:-"0"}" port="${port:-"0"}" queryport="$((port + 1))" - queryportgs="${queryportgs:-"0"}" + gamespyqueryport="${gamespyqueryport:-"0"}" servername="${servername:-"NOT SET"}" serverpassword="${serverpassword:-"NOT SET"}" httpenabled="${httpenabled:-"0"}" @@ -1771,7 +1771,6 @@ fn_info_game_ro() { fn_info_game_ini "lanport" "LANServerPort" fn_info_game_ini "maxplayers" "MaxPlayers" fn_info_game_ini "port" "Port" - fn_info_game_ini "queryportgs" "QueryPort" fn_info_game_ini "servername" "ServerName" fn_info_game_ini "serverpassword" "GamePassword" fi @@ -1784,12 +1783,11 @@ fn_info_game_ro() { lanport="${lanport:-"0"}" maxplayers="${maxplayers:-"0"}" port="${port:-"0"}" - queryport="$((port + 1))" - queryportgs="${queryportgs:-"0"}" + queryport=$((28902 + (port - 7757))) # Valve Query Port servername="${servername:-"NOT SET"}" serverpassword="${serverpassword:-"NOT SET"}" - steamport="28902" - steamworksport="20610" + steamport="20610" + unreal2queryport="$((port + 1))" # Unreal2 Query Port } # Config Type: QuakeC diff --git a/lgsm/modules/info_messages.sh b/lgsm/modules/info_messages.sh index 391ed66e42..29fe1c6bc0 100644 --- a/lgsm/modules/info_messages.sh +++ b/lgsm/modules/info_messages.sh @@ -842,7 +842,7 @@ fn_info_messages_armar() { { fn_port "header" fn_port "Game" port udp - fn_port "Steam Query" queryport udp + fn_port "Query" queryport udp fn_port "BattleEye" battleeyeport tcp } | column -s $'\t' -t } @@ -1140,7 +1140,7 @@ fn_info_messages_kf() { fn_port "header" fn_port "Game" port udp fn_port "Query" queryport udp - fn_port "Query (GameSpy)" queryportgs udp + fn_port "Query (GameSpy)" gamespyqueryport udp fn_port "Web Interface" httpport tcp fn_port "LAN" lanport udp fn_port "Steamworks P2P" steamworksport udp @@ -1353,11 +1353,12 @@ fn_info_messages_ro() { { fn_port "header" fn_port "Game" port udp - fn_port "Query" queryport udp + fn_port "Query - Steam" queryport udp + fn_port "Query - Unreal 2" unreal2queryport udp fn_port "Web Interface" httpport tcp fn_port "LAN" lanport udp - fn_port "Steamworks P2P" steamworksport udp fn_port "Steam" steamport udp + } | column -s $'\t' -t echo -e "" echo -e "${bold}${lightgreen}${servername} Web Interface${default}" @@ -1514,7 +1515,7 @@ fn_info_messages_source() { fn_port "Query" queryport tcp fn_port "RCON" rconport tcp fn_port "SourceTV" sourcetvport udp - # Will not show if unaviable + # Will not show if unavailable if [ "${steamport}" == "0" ] || [ -v "${steamport}" ]; then fn_port "Steam" steamport udp fi @@ -1580,9 +1581,9 @@ fn_info_messages_ts3() { fn_port "header" fn_port "Voice" port udp fn_port "Query" queryport tcp - fn_port "Query (SSH)" querysshport tcp - fn_port "Query (http)" queryhttpport tcp - fn_port "Query (https)" queryhttpsport tcp + fn_port "Query (SSH)" sshqueryport tcp + fn_port "Query (http)" httpqueryport tcp + fn_port "Query (https)" httpsqueryport tcp fn_port "File Transfer" fileport tcp fn_port "Telnet" telnetport tcp } | column -s $'\t' -t @@ -1628,7 +1629,7 @@ fn_info_messages_ut2k4() { fn_port "header" fn_port "Game" port udp fn_port "Query" queryport udp - fn_port "Query (GameSpy)" queryportgs udp + fn_port "Query (GameSpy)" gamespyqueryport udp fn_port "Web Interface" httpport tcp fn_port "LAN" lanport udp } | column -s $'\t' -t From bfff6d1d0c8ccabade01bb8e5d236f0b81308980 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 21 Sep 2024 23:22:07 +0100 Subject: [PATCH 7/9] feat(kf): Migrate to using valve query --- .../config-lgsm/kfserver/_default.cfg | 2 +- lgsm/modules/info_game.sh | 15 ++++++++++----- lgsm/modules/info_messages.sh | 6 +++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lgsm/config-default/config-lgsm/kfserver/_default.cfg b/lgsm/config-default/config-lgsm/kfserver/_default.cfg index d9df57d3e5..222ba99790 100644 --- a/lgsm/config-default/config-lgsm/kfserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/kfserver/_default.cfg @@ -146,7 +146,7 @@ stopmode="2" # 4: gsquery # 5: tcp querymode="2" -querytype="protocol-unreal2" +querytype="protocol-valve" ## Console type consoleverbose="yes" diff --git a/lgsm/modules/info_game.sh b/lgsm/modules/info_game.sh index 5875627ca3..8496f078f3 100644 --- a/lgsm/modules/info_game.sh +++ b/lgsm/modules/info_game.sh @@ -496,12 +496,13 @@ fn_info_game_kf() { fn_info_game_ini "lanport" "LANServerPort" fn_info_game_ini "maxplayers" "MaxPlayers" fn_info_game_ini "port" "Port" - fn_info_game_ini "gamespyqueryport" "QueryPort" + fn_info_game_ini "gamespyqueryport" "OldQueryPortNumber" fn_info_game_ini "servername" "ServerName" fn_info_game_ini "serverpassword" "GamePassword" fi adminpassword="${adminpassword:-"NOT SET"}" defaultmap="${defaultmap:-"NOT SET"}" + gamespyqueryport="${gamespyqueryport:-"0"}" # Gamespy Query Port httpenabled="${httpenabled:-"NOT SET"}" httppassword="${adminpassword}" httpport="${httpport:-"0"}" @@ -509,12 +510,11 @@ fn_info_game_kf() { lanport="${lanport:-"0"}" maxplayers="${maxplayers:-"0"}" port="${port:-"0"}" - queryport="$((port + 1))" - gamespyqueryport="${gamespyqueryport:-"0"}" + queryport=$((28902 + (port - 7757))) # Valve Query Port servername="${servername:-"NOT SET"}" serverpassword="${serverpassword:-"NOT SET"}" - steamport="28852" - steamworksport="20560" + steamport="20610" + unreal2queryport="$((port + 1))" # Unreal2 Query Port } # Config Type: ini @@ -1761,6 +1761,11 @@ fn_info_game_qw() { servername="${servername:-"NOT SET"}" } +# Config Type: ini +# Parameters: true +# Comment: ; or # +# Example: ServerName=SERVERNAME +# Filetype: ini fn_info_game_ro() { if [ -f "${servercfgfullpath}" ]; then fn_info_game_ini "adminpassword" "AdminPassword" diff --git a/lgsm/modules/info_messages.sh b/lgsm/modules/info_messages.sh index 29fe1c6bc0..a76c3502e9 100644 --- a/lgsm/modules/info_messages.sh +++ b/lgsm/modules/info_messages.sh @@ -1139,11 +1139,11 @@ fn_info_messages_kf() { { fn_port "header" fn_port "Game" port udp - fn_port "Query" queryport udp - fn_port "Query (GameSpy)" gamespyqueryport udp + fn_port "Query - Steam" queryport udp + fn_port "Query - Unreal 2" unreal2queryport udp + fn_port "Query - Gamespy" gamespyqueryport udp fn_port "Web Interface" httpport tcp fn_port "LAN" lanport udp - fn_port "Steamworks P2P" steamworksport udp fn_port "Steam" steamport udp } | column -s $'\t' -t echo -e "" From 839032a59fa95ec436b248a64384753635b91e64 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 24 Sep 2024 22:45:25 +0100 Subject: [PATCH 8/9] bug --- lgsm/modules/alert_discord.sh | 3 +-- lgsm/modules/alert_gotify.sh | 6 +++--- lgsm/modules/alert_ifttt.sh | 6 +++--- lgsm/modules/alert_pushbullet.sh | 8 ++++---- lgsm/modules/alert_rocketchat.sh | 20 ++++++++++---------- lgsm/modules/alert_slack.sh | 28 ++++++++++++++-------------- lgsm/modules/alert_telegram.sh | 12 ++++++------ 7 files changed, 41 insertions(+), 42 deletions(-) diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index 08fd8d9690..20d7a145a1 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -86,8 +86,7 @@ jsonnoinfo=$( "inline": true }, EOF - ) -fi +) json+=$( cat << EOF diff --git a/lgsm/modules/alert_gotify.sh b/lgsm/modules/alert_gotify.sh index 8673ebc23c..6ba1106e11 100644 --- a/lgsm/modules/alert_gotify.sh +++ b/lgsm/modules/alert_gotify.sh @@ -10,8 +10,8 @@ module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$( cat << EOF { - "title": "${alerttitle}", - "message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n + "title": "${alerttitle}", + "message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) @@ -34,7 +34,7 @@ fi json+=$( cat << EOF Server Time\n$(date)", - "priority": 5 + "priority": 5 } EOF ) diff --git a/lgsm/modules/alert_ifttt.sh b/lgsm/modules/alert_ifttt.sh index 2e23a1bab9..16d78c807f 100644 --- a/lgsm/modules/alert_ifttt.sh +++ b/lgsm/modules/alert_ifttt.sh @@ -10,9 +10,9 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$( cat << EOF { - "value1": "${selfname}", - "value2": "${alerttitle}", - "value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n + "value1": "${selfname}", + "value2": "${alerttitle}", + "value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) diff --git a/lgsm/modules/alert_pushbullet.sh b/lgsm/modules/alert_pushbullet.sh index 56b329b151..10407026f6 100644 --- a/lgsm/modules/alert_pushbullet.sh +++ b/lgsm/modules/alert_pushbullet.sh @@ -10,10 +10,10 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$( cat << EOF { - "channel_tag": "${channeltag}", - "type": "note", - "title": "${alerttitle}", - "body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n + "channel_tag": "${channeltag}", + "type": "note", + "title": "${alerttitle}", + "body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) diff --git a/lgsm/modules/alert_rocketchat.sh b/lgsm/modules/alert_rocketchat.sh index acd1e58f98..7d9b67e66d 100644 --- a/lgsm/modules/alert_rocketchat.sh +++ b/lgsm/modules/alert_rocketchat.sh @@ -67,11 +67,11 @@ EOF if [ -n "${querytype}" ]; then json+=$( cat << EOF - { - "short": false, - "title": "Is my Game Server Online?", - "value": "" - }, + { + "short": false, + "title": "Is my Game Server Online?", + "value": "" + }, EOF ) fi @@ -79,11 +79,11 @@ fi if [ -n "${alerturl}" ]; then json+=$( cat << EOF - { - "short": false, - "title": "More info", - "value": "${alerturl}" - }, + { + "short": false, + "title": "More info", + "value": "${alerturl}" + }, EOF ) fi diff --git a/lgsm/modules/alert_slack.sh b/lgsm/modules/alert_slack.sh index 6911601235..15e7d5036e 100644 --- a/lgsm/modules/alert_slack.sh +++ b/lgsm/modules/alert_slack.sh @@ -90,13 +90,13 @@ EOF if [ -n "${querytype}" ]; then json+=$( cat << EOF - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Is my Game Server Online?*\n" - } - }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Is my Game Server Online?*\n" + } + }, EOF ) fi @@ -104,13 +104,13 @@ fi if [ -n "${alerturl}" ]; then json+=$( cat << EOF - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*More info*\n<${alerturl}|${alerturl}>" - } - }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*More info*\n<${alerturl}|${alerturl}>" + } + }, EOF ) fi diff --git a/lgsm/modules/alert_telegram.sh b/lgsm/modules/alert_telegram.sh index c3394898bd..138b4b3f67 100644 --- a/lgsm/modules/alert_telegram.sh +++ b/lgsm/modules/alert_telegram.sh @@ -10,11 +10,11 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$( cat << EOF { - "chat_id": "${telegramchatid}", - "message_thread_id": "${telegramthreadid}", - "parse_mode": "HTML", - "disable_notification": "${telegramdisablenotification}", - "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n + "chat_id": "${telegramchatid}", + "message_thread_id": "${telegramthreadid}", + "parse_mode": "HTML", + "disable_notification": "${telegramdisablenotification}", + "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF ) @@ -37,7 +37,7 @@ fi json+=$( cat << EOF Server Time\n$(date)", - "disable_web_page_preview": "yes" + "disable_web_page_preview": "yes" } EOF ) From 81c00410a5be90a2ab008843e3cd76133ff36e98 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 24 Sep 2024 22:51:19 +0100 Subject: [PATCH 9/9] bug --- lgsm/modules/alert_discord.sh | 87 +++++------------------------------ 1 file changed, 12 insertions(+), 75 deletions(-) diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index 20d7a145a1..78e0293493 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -29,95 +29,32 @@ json=$( "url": "${alerticon}" }, "fields": [ - { - "name": "Server Name", - "value": "${servername}" - }, - { - "name": "Information", - "value": "${alertmessage}" - }, - { - "name": "Game", - "value": "${gamename}", - "inline": true - }, { - "name": "Server Time", - "value": "$(date)", - "inline": true - } - ], - "footer": { - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "text": "Sent by LinuxGSM ${version}" - } - } - ] -} -EOF -) - -jsonnoinfo=$( - cat << EOF -{ - "username": "LinuxGSM", - "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", - "file": "content", - "embeds": [ - { - "author": { - "name": "LinuxGSM Alert", - "url": "", - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" - }, - "title": "${alerttitle}", - "url": "", - "description": "", - "color": "${alertcolourdec}", - "type": "content", - "thumbnail": { - "url": "${alerticon}" - }, - "fields": [ - { - "name": "Is my Game Server Online?", - "value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}", - "inline": true - }, -EOF -) - -json+=$( - cat << EOF - { - "name": "More info", - "value": "${alerturl}", - "inline": true - }, - { - "name": "Game", - "value": "${gamename}", - "inline": true + "name": "Server Name", + "value": "${servername}" }, { - "name": "Server IP", - "value": "\`${alertip}:${port}\`", - "inline": true + "name": "Information", + "value": "${alertmessage}" }, { - "name": "Hostname", - "value": "${HOSTNAME}", + "name": "Game", + "value": "${gamename}", "inline": true }, { "name": "Server Time", "value": "$(date)", "inline": true + }, + { + "name": "Is my Game Server Online?", + "value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}", + "inline": true } ], "footer": { - "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "text": "Sent by LinuxGSM ${version}" } }