Quellcode durchsuchen

feat: add ismygameserver.online links (#4742)

Daniel Gibbs vor 1 Jahr
Ursprung
Commit
8d17622af3

+ 10 - 87
lgsm/modules/alert_discord.sh

@@ -7,7 +7,7 @@
 
 moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
-jsoninfo=$(
+json=$(
 	cat << EOF
 {
     "username": "LinuxGSM",
@@ -29,103 +29,32 @@ jsoninfo=$(
                 "url": "${alerticon}"
             },
             "fields": [
-				{
-					"name": "Server Name",
-					"value": "${servername}"
-				},
-				{
-					"name": "Information",
-					"value": "${alertmessage}"
-				},
                 {
-                    "name": "Game",
-                    "value": "${gamename}",
-                    "inline": true
+                    "name": "Server Name",
+                    "value": "${servername}"
                 },
                 {
-                    "name": "Server IP",
-                    "value": "\`${alertip}:${port}\`",
-                    "inline": true
-                },
-                {
-                    "name": "Hostname",
-                    "value": "${HOSTNAME}",
-                    "inline": true
+                    "name": "Information",
+                    "value": "${alertmessage}"
                 },
-				{
-					"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
-)
-
-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": "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}",
+                    "name": "Server Time",
+                    "value": "$(date)",
                     "inline": true
                 },
                 {
-                    "name": "Server Time",
-                    "value": "$(date)",
+                    "name": "Is my Game Server Online?",
+                    "value": "https://ismygameserver.online/${imgsoquerytype}/${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}"
             }
         }
@@ -136,12 +65,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

+ 20 - 14
lgsm/modules/alert_gotify.sh

@@ -7,32 +7,38 @@
 
 moduleselfname="$(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
-}
+	"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/${imgsoquerytype}/${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)",
+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 .)")
 

+ 20 - 14
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)"
-}
+	"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/${imgsoquerytype}/${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")
 

+ 20 - 15
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)"
-}
+	"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/${imgsoquerytype}/${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")
 

+ 20 - 4
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=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>Server Time<br>$(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=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
+message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>"
+
+if [ -n "${querytype}" ]; then
+	message+="<b>Is my Game Server Online?</b><br><a href='https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}'>Check here</a><br><br>"
+fi
+
+if [ -n "${alerturl}" ]; then
+	message+="<b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>"
 fi
 
+message+="Server Time<br>$(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}"

+ 26 - 8
lgsm/modules/alert_rocketchat.sh

@@ -7,7 +7,7 @@
 
 moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
-jsoninfo=$(
+json=$(
 	cat << EOF
 {
 	"alias": "LinuxGSM",
@@ -64,7 +64,31 @@ jsoninfo=$(
 EOF
 )
 
-jsonnoinfo=$(
+if [ -n "${querytype}" ]; then
+	json+=$(
+		cat << EOF
+				{
+					"short": false,
+					"title": "Is my Game Server Online?",
+					"value": "<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>"
+				},
+EOF
+	)
+fi
+
+if [ -n "${alerturl}" ]; then
+	json+=$(
+		cat << EOF
+				{
+					"short": false,
+					"title": "More info",
+					"value": "${alerturl}"
+				},
+EOF
+	)
+fi
+
+json+=$(
 	cat << EOF
 {
 	"alias": "LinuxGSM",
@@ -116,12 +140,6 @@ jsonnoinfo=$(
 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}")
 

+ 30 - 8
lgsm/modules/alert_slack.sh

@@ -7,7 +7,7 @@
 
 moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
-jsonnoinfo=$(
+json=$(
 	cat << EOF
 {
 	"attachments": [
@@ -87,7 +87,35 @@ jsonnoinfo=$(
 EOF
 )
 
-jsoninfo=$(
+if [ -n "${querytype}" ]; then
+	json+=$(
+		cat << EOF
+				{
+					"type": "section",
+					"text": {
+						"type": "mrkdwn",
+						"text": "*Is my Game Server Online?*\n<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>"
+					}
+				},
+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": [
@@ -174,12 +202,6 @@ jsoninfo=$(
 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}")

+ 20 - 17
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": "<b>${alerttitle}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>\n\n<b>Server Time</b>\n$(date)",
-	"disable_web_page_preview": "yes"
-}
+	"text": "<b>${alerttitle}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n
 EOF
 )
 
-jsonnoinfo=$(
+if [ -n "${querytype}" ]; then
+	json+=$(
+		cat << EOF
+<b>Is my Game Server Online?</b>\n<a href='https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}'>Check here</a>\n\n
+EOF
+	)
+fi
+
+if [ -n "${alerturl}" ]; then
+	json+=$(
+		cat << EOF
+<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>\n\n
+EOF
+	)
+fi
+
+json+=$(
 	cat << EOF
-{
-	"chat_id": "${telegramchatid}",
-	"message_thread_id": "${telegramthreadid}",
-	"parse_mode": "HTML",
-	"disable_notification": "${telegramdisablenotification}",
-	"text": "<b>${alerttitle}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Server Time</b>\n$(date)",
+<b>Server Time</b>\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")
 

+ 2 - 2
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:"
 			{

+ 4 - 0
lgsm/modules/command_dev_query_raw.sh

@@ -208,6 +208,10 @@ 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/${imgsoquerytype}/${queryip}:${queryport}"
+echo -e ""
 echo -e "${lightgreen}Gamedig Raw Output${default}"
 fn_messages_separator
 echo -e ""

+ 33 - 0
lgsm/modules/info_messages.sh

@@ -7,6 +7,29 @@
 
 moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
+# Converts querytype to imgsoquerytype for use with ismygameserver.online urls
+if [ -n "${querytype}" ]; then
+	if [ "${querytype}" == "protocol-valve" ]; then
+		imgsoquerytype="valve"
+	elif [ "${querytype}" == "protocol-gamespy1" ]; then
+		imgsoquerytype="gamespy"
+	elif [ "${querytype}" == "protocol-gamespy2" ]; then
+		imgsoquerytype="gamespy"
+	elif [ "${querytype}" == "protocol-gamespy3" ]; then
+		imgsoquerytype="gamespy"
+	elif [ "${querytype}" == "protocol-quake1" ]; then
+		imgsoquerytype="quake"
+	elif [ "${querytype}" == "protocol-quake2" ]; then
+		imgsoquerytype="quake"
+	elif [ "${querytype}" == "protocol-quake3" ]; then
+		imgsoquerytype="quake"
+	elif [ "${querytype}" == "protocol-unreal2" ]; then
+		imgsoquerytype="unrealtournament2004"
+	else
+		imgsoquerytype="${querytype}"
+	fi
+fi
+
 # Removes the passwords form all but details.
 fn_info_messages_password_strip() {
 	if [ "${commandname}" != "DETAILS" ]; then
@@ -66,6 +89,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/${imgsoquerytype}/${alertip}:${queryport}"
+		echo -e ""
+	fi
 	echo -e "Server Time"
 	echo -e "$(date)"
 }
@@ -503,6 +531,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/${imgsoquerytype}/${alertip}:${queryport}"
+		fi
 	} | column -s $'\t' -t
 	echo -e ""
 }