Add in journal log of service and ip, or failure

This commit is contained in:
Brian Read 2024-11-16 19:23:32 +00:00
parent 6d91ce0a87
commit f4fc0394f7

View File

@ -37,13 +37,15 @@ get_public_ip() {
# 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
logger -t public_ip_script "Service used: $service, IP found: $public_ip"
echo "$public_ip"
return
fi
done
# 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
}