mirror of
https://github.com/YunoHost-Apps/linuxdash_ynh.git
synced 2024-09-03 19:36:07 +02:00
15 lines
555 B
Bash
Executable file
15 lines
555 B
Bash
Executable file
#!/bin/bash
|
|
awkCmd=`which awk`
|
|
grepCmd=`which grep`
|
|
sedCmd=`which sed`
|
|
ifconfigCmd=`which ifconfig`
|
|
trCmd=`which tr`
|
|
digCmd=`which dig`
|
|
|
|
externalIp=`$digCmd +short myip.opendns.com @resolver1.opendns.com`
|
|
|
|
$ifconfigCmd \
|
|
| $grepCmd -B1 "inet addr" \
|
|
| $awkCmd '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' \
|
|
| $awkCmd -v exIp="$externalIp" -F: 'BEGIN {print "["} { print "{ \"interface\": \"" $1 "\", \"ip\": \"" $3 "\" },"} END {print "{ \"interface\": \"external\", \"ip\": \""exIp"\" } ]"}' \
|
|
| $trCmd -d '\r\n'
|