Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

support MacOS bash and ifconfig properly #444

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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