diff options
author | Mike Crute <mike@crute.us> | 2018-03-27 03:55:58 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2018-03-27 03:55:58 +0000 |
commit | dd4c49d7f1b4b4112a21595528c77987b00f59fd (patch) | |
tree | e715aa05744f4d04716028f05d3bee29cf584dd0 | |
parent | 6552b2f47c26a9a8d5b358b779f285bcb2880164 (diff) | |
download | server_bin-dd4c49d7f1b4b4112a21595528c77987b00f59fd.tar.bz2 server_bin-dd4c49d7f1b4b4112a21595528c77987b00f59fd.tar.xz server_bin-dd4c49d7f1b4b4112a21595528c77987b00f59fd.zip |
Fallback to external DNS
-rwxr-xr-x | phonehome.sh | 6 |
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 | |||
13 | CRONTAB=/var/spool/cron/crontabs/root | 13 | CRONTAB=/var/spool/cron/crontabs/root |
14 | CRON_ENTRY="*/5 * * * * /root/phonehome.sh" | 14 | CRON_ENTRY="*/5 * * * * /root/phonehome.sh" |
15 | 15 | ||
16 | DEFAULT_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 |
22 | HOST_IP=$(dig +short @8.8.8.8 phonehome.crute.me | awk '/^[0-9]+/ { print $0; exit; }') | 24 | ALT_HOST=$(dig +short @8.8.8.8 phonehome.crute.me | awk '/^[0-9]+/ { print $0; exit; }') |
23 | 25 | ||
24 | function start_autossh { | 26 | function start_autossh { |
25 | autossh -f \ | 27 | autossh -f \ |
@@ -48,5 +50,5 @@ else | |||
48 | fi | 50 | fi |
49 | 51 | ||
50 | if ! pgrep autossh > /dev/null; then | 52 | if ! pgrep autossh > /dev/null; then |
51 | start_autossh $HOST_IP | 53 | start_autossh $ALT_HOST |
52 | fi | 54 | fi |