From 4448b97536ca88ec5dd1c4337c2a1b7ec89273cb Mon Sep 17 00:00:00 2001 From: Kris-Sekula Date: Wed, 16 Nov 2016 22:30:11 +0000 Subject: [PATCH] Add files via upload --- mailmyip.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 mailmyip.sh diff --git a/mailmyip.sh b/mailmyip.sh new file mode 100644 index 0000000..fb73c38 --- /dev/null +++ b/mailmyip.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +#sleep 120 + +((count = 1000)) # Maximum number to try. +while [[ $count -ne 0 ]] ; do + ping -c 1 8.8.8.8 # Try once. or put address that is ping-able. + rc=$? + if [[ $rc -eq 0 ]] ; then + ((count = 1)) # If okay, flag to exit loop. + fi + ((count = count - 1)) # So we don't go forever. +done + +if [[ $rc -eq 0 ]] ; then # Make final determination. + echo 'say The internet is back up.' + ip=$(hostname -I) + echo "$ip" | mail -s "New IP of $(hostname)" to@domain.com +else + echo 'say Timeout.' +fi