From f4fc0394f736f54502c59c97d3f79ed5614da603 Mon Sep 17 00:00:00 2001 From: Brian Read Date: Sat, 16 Nov 2024 19:23:32 +0000 Subject: [PATCH] Add in journal log of service and ip, or failure --- getmyip | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/getmyip b/getmyip index 90486f9..fc9b5ef 100755 --- a/getmyip +++ b/getmyip @@ -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 }