a better way to set IP address with the EDEX service manager
Former-commit-id:1715e9fe60
[formerly7bff0bb7a3
] [formerlyfba486d50c
] [formerly 42288b53542e7e4cc01144956f19f70bfadc0dba [formerly 664e147e90c04836a158dc62409e3f8d2dc8d4b4] [formerlyfba486d50c
[formerly25cb18c0c7
]]] Former-commit-id: 8ec868abf247c9a41279933ceb95bc4af4c79c4d [formerly ab8bc0442c55fa79498901b40a635e7bcfc3b07a] [formerly43326f949f
[formerly2dfbe88894
]] Former-commit-id:43326f949f
Former-commit-id:4cfe53682b
This commit is contained in:
parent
19bfef77c4
commit
c41401f85a
1 changed files with 2 additions and 29 deletions
|
@ -43,48 +43,21 @@ options=( 'status' 'start' 'stop' 'log' 'setup' 'test' )
|
|||
nopts=${options[@]}
|
||||
|
||||
# main program
|
||||
#
|
||||
|
||||
# Construct IP subnet
|
||||
#
|
||||
# OS X
|
||||
|
||||
#IP=`ifconfig | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'`
|
||||
|
||||
# Linux
|
||||
# Simple solution
|
||||
#IP=`hostname -I`
|
||||
|
||||
# For multiple IP addresses we need to account for non-routable IPs
|
||||
#IP=`/sbin/ifconfig | grep "inet addr" | grep -v 127.0.0 | awk '{ print $2 }' | cut -d: -f2`
|
||||
|
||||
ethdev=`ip link show| grep ^[0-9]| awk '{ print $2}'`
|
||||
|
||||
if [[ $ethdev =~ eth0 ]]; then
|
||||
usedev=eth0
|
||||
elif [[ $ethdev =~ wlan0 ]]; then
|
||||
usedev=wlan0
|
||||
fi
|
||||
|
||||
# better solution: find interface for routeable IPs
|
||||
usedev=`netstat -rn | egrep "^0.0.0.0" | awk '{print $8}'`
|
||||
IP=`/sbin/ifconfig $usedev | grep "inet addr" | awk '{ print $2 }' | cut -d: -f2`
|
||||
|
||||
if [[ $IP =~ ^10\..* || $IP =~ ^192\.168.* ]] # non-routable IP range
|
||||
then
|
||||
if [[ $ethdev =~ eth1 ]]; then
|
||||
IP=`/sbin/ifconfig eth1 | grep "inet addr" | awk '{ print $2 }' | cut -d: -f2`
|
||||
fi
|
||||
elif [[ $IP =~ ^172\..* ]]
|
||||
then
|
||||
IPb=`echo $IP | cut -d"." -f2`
|
||||
if [[ $IPb -gt 15 && $IPb -lt 32 ]] # non-routable 172.16 to 172.32 range
|
||||
then
|
||||
IP=`/sbin/ifconfig eth1 | grep "inet addr" | awk '{ print $2 }' | cut -d: -f2`
|
||||
fi
|
||||
fi
|
||||
|
||||
# truncate
|
||||
IP_CIDR="${IP%.*}"
|
||||
|
||||
editFiles=($PG_FILE $EDEX_ENV_FILE $LDMD_CONF)
|
||||
boolFiles=(true true true)
|
||||
editFuncs=(edit_pg edit_edex edit_ldm)
|
||||
|
|
Loading…
Add table
Reference in a new issue