Browse Source
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.
pull/4332/head
Daniel Gibbs
2 years ago
No known key found for this signature in database
GPG Key ID: 2076B128385E8C55
1 changed files with
4 additions and
4 deletions
lgsm/modules/info_game.sh
@ -2409,7 +2409,7 @@ if [ -f "${tmpdir}/publicip.txt" ]; then
fi
fi
if [ ! -f " ${ tmpdir } /publicip.txt " ] ; then
if [ ! -f " ${ tmpdir } /publicip.txt " ] ; then
apiurl = "http://ip-api.com/json/ "
apiurl = "http://ip-api.com/json"
curl -s " ${ apiurl } " > " ${ tmpdir } /publicip.txt "
curl -s " ${ apiurl } " > " ${ tmpdir } /publicip.txt "
exitcode = $?
exitcode = $?
# if curl passes add publicip to publicip.txt
# 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 " ) "
country = " $( jq -r '.country' " ${ tmpdir } /publicip.txt " ) "
countrycode = " $( jq -r '.countryCode' " ${ tmpdir } /publicip.txt " ) "
countrycode = " $( jq -r '.countryCode' " ${ tmpdir } /publicip.txt " ) "
else
else
publicip = "unknown "
publicip = "NOT SET "
country = "unknown "
country = "NOT SET "
countrycode = "unknown "
countrycode = "NOT SET "
fi
fi
# Alert IP address
# Alert IP address