From da663e996afff24a1614b5e97a9d9b4cb60f9a55 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 8 Oct 2023 17:28:50 +0100 Subject: [PATCH] refactor: update API URL and set default values for public IP, country, and country code The commit refactors the code by updating the API URL to remove a trailing slash. Additionally, it sets default values for the variables `publicip`, `country`, and `countrycode` when the file `${tmpdir}/publicip.txt` is not found. --- lgsm/modules/info_game.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lgsm/modules/info_game.sh b/lgsm/modules/info_game.sh index 3e143678e..709995ba4 100644 --- a/lgsm/modules/info_game.sh +++ b/lgsm/modules/info_game.sh @@ -2409,7 +2409,7 @@ if [ -f "${tmpdir}/publicip.txt" ]; then fi if [ ! -f "${tmpdir}/publicip.txt" ]; then - apiurl="http://ip-api.com/json/" + apiurl="http://ip-api.com/json" curl -s "${apiurl}" > "${tmpdir}/publicip.txt" exitcode=$? # if curl passes add publicip to publicip.txt @@ -2425,9 +2425,9 @@ if [ -f "${tmpdir}/publicip.txt" ]; then country="$(jq -r '.country' "${tmpdir}/publicip.txt")" countrycode="$(jq -r '.countryCode' "${tmpdir}/publicip.txt")" else - publicip="unknown" - country="unknown" - countrycode="unknown" + publicip="NOT SET" + country="NOT SET" + countrycode="NOT SET" fi # Alert IP address