Skip to content

Commit

Permalink
support MacOS bash and ifconfig properly
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-solana authored and garious committed Jun 25, 2018
1 parent c22ef50 commit 3966eb5
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions multinode-demo/myip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

function myip()
{
declare ipaddrs=( )

# query interwebs
mapfile -t ipaddrs < <(curl -s ifconfig.co)

# machine's interfaces
mapfile -t -O "${#ipaddrs[*]}" ipaddrs < \
<(ifconfig | awk '/inet(6)? (addr:)?/ {print $2}')

ipaddrs=( "${extips[@]}" "${ipaddrs[@]}" )
# shellcheck disable=SC2207
declare ipaddrs=(
# query interwebs
$(curl -s ifconfig.co)
# machine's interfaces
$(ifconfig |
awk '/inet addr:/ {gsub("addr:","",$2); print $2; next}
/inet6 addr:/ {gsub("/.*", "", $3); print $3; next}
/inet(6)? / {print $2}'
)
)

if (( ! ${#ipaddrs[*]} ))
then
Expand Down

0 comments on commit 3966eb5

Please sign in to comment.