summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2018-03-27 03:55:58 +0000
committerMike Crute <mike@crute.us>2018-03-27 03:55:58 +0000
commitdd4c49d7f1b4b4112a21595528c77987b00f59fd (patch)
treee715aa05744f4d04716028f05d3bee29cf584dd0
parent6552b2f47c26a9a8d5b358b779f285bcb2880164 (diff)
downloadserver_bin-dd4c49d7f1b4b4112a21595528c77987b00f59fd.tar.bz2
server_bin-dd4c49d7f1b4b4112a21595528c77987b00f59fd.tar.xz
server_bin-dd4c49d7f1b4b4112a21595528c77987b00f59fd.zip
Fallback to external DNS
-rwxr-xr-xphonehome.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/phonehome.sh b/phonehome.sh
index f469d6c..3aa7cef 100755
--- a/phonehome.sh
+++ b/phonehome.sh
@@ -13,13 +13,15 @@ KEY=/root/.ssh/phonehome.id_rsa
13CRONTAB=/var/spool/cron/crontabs/root 13CRONTAB=/var/spool/cron/crontabs/root
14CRON_ENTRY="*/5 * * * * /root/phonehome.sh" 14CRON_ENTRY="*/5 * * * * /root/phonehome.sh"
15 15
16DEFAULT_HOST="phonehome.crute.me"
17
16# Alt host hedges against DNS being down if the default DNS server is on the 18# Alt host hedges against DNS being down if the default DNS server is on the
17# wrong side of a collapsed ssh tunnel 19# wrong side of a collapsed ssh tunnel
18# 20#
19# Grab only answers starting with numbers since we're trying to resolve the IP 21# Grab only answers starting with numbers since we're trying to resolve the IP
20# itself not the hostname (in the absence of normal DNS). Grab the first numeric 22# itself not the hostname (in the absence of normal DNS). Grab the first numeric
21# answer in the case of multiple records 23# answer in the case of multiple records
22HOST_IP=$(dig +short @8.8.8.8 phonehome.crute.me | awk '/^[0-9]+/ { print $0; exit; }') 24ALT_HOST=$(dig +short @8.8.8.8 phonehome.crute.me | awk '/^[0-9]+/ { print $0; exit; }')
23 25
24function start_autossh { 26function start_autossh {
25 autossh -f \ 27 autossh -f \
@@ -48,5 +50,5 @@ else
48fi 50fi
49 51
50if ! pgrep autossh > /dev/null; then 52if ! pgrep autossh > /dev/null; then
51 start_autossh $HOST_IP 53 start_autossh $ALT_HOST
52fi 54fi