-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: William Stearns <[email protected]>
- Loading branch information
1 parent
e5fbb07
commit 93b2dc5
Showing
1 changed file
with
10 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
#Performs all the setup steps needed to connect to one or more hosts listed on the command line | ||
#Copyright 2022 William Stearns <[email protected]> | ||
#Released under the GPL 3.0 | ||
#Version 0.1.6 | ||
#Version 0.1.7 | ||
|
||
|
||
|
||
|
@@ -230,8 +230,8 @@ check_config_block() { | |
prepend_config_block "\nHost ${2} ${local_ip}\n\tHostname\t\t${local_ip}\n\tHostKeyAlias\t\t${2}\n${user_line}\n" | ||
else | ||
status "No user-supplied target IP or hostname for $2, look one up" | ||
ip4=$(dig +short ${2} A) | ||
ip6=$(dig +short ${2} AAAA) | ||
ip4=$(dig +nocomment +short ${2} A 2>/dev/null | sed -e 's/;;.*//' | grep -v '^$') | ||
ip6=$(dig +nocomment +short ${2} AAAA 2>/dev/null | sed -e 's/;;.*//' | grep -v '^$') | ||
|
||
if [ -n "$ip4" ]; then | ||
if [ -n "$ip6" ]; then | ||
|
@@ -246,8 +246,13 @@ check_config_block() { | |
status "Have an ipv6 address only for $2" | ||
prepend_config_block "\nHost ${2} ${2}-v6 ${ip6}\n\tHostname\t\t${ip6}\n\tHostKeyAlias\t\t${2}\n${user_line}\n" | ||
else | ||
status "No ipv4 or ipv6 address found for ${2}. Please enter an IP address to use:" | ||
read ip_or_hostname | ||
#echo "== No ipv4 or ipv6 address found for ${2}. Please enter an IP address to use:" >&2 | ||
#read ip_or_hostname <&2 | ||
#if [ -z "$ip_or_hostname" ]; then | ||
# ip_or_hostname="$2" | ||
#fi | ||
status "We could not lookup a DNS address for $2 so we will just use $2 in the ssh Hostname field." | ||
ip_or_hostname="$2" | ||
prepend_config_block "\nHost ${2} ${ip_or_hostname}\n\tHostname\t\t${ip_or_hostname}\n\tHostKeyAlias\t\t${2}\n${user_line}\n" | ||
fi | ||
fi | ||
|