Add in journal log of service and ip, or failure
This commit is contained in:
parent
6d91ce0a87
commit
f4fc0394f7
4
getmyip
4
getmyip
@ -37,13 +37,15 @@ get_public_ip() {
|
|||||||
|
|
||||||
# Check if the curl request was successful and there's a valid IP address
|
# Check if the curl request was successful and there's a valid IP address
|
||||||
if [[ $? -eq 0 && $public_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
if [[ $? -eq 0 && $public_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
logger -t public_ip_script "Service used: $service, IP found: $public_ip"
|
||||||
echo "$public_ip"
|
echo "$public_ip"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none of the services returned a valid IP, output an error message
|
# If none of the services returned a valid IP, output an error message
|
||||||
echo "Error: Failed to retrieve public IP using all services." >&2
|
echo "Failed to retrieve public IP using all services." >&2
|
||||||
|
logger -t public_ip_script "Error: Failed to retrieve public IP using all services."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user