2013-07-24 14:21:20 -04:00
|
|
|
|
|
|
|
trim() {
|
|
|
|
trimmed=$*
|
|
|
|
trimmed=${trimmed%% }
|
|
|
|
trimmed=${trimmed## }
|
|
|
|
echo "$trimmed"
|
|
|
|
}
|
|
|
|
|
|
|
|
getDefaultIP() {
|
|
|
|
local routedev=$(ip -o -4 route show default)
|
|
|
|
routedev=${routedev##* dev }
|
|
|
|
routedev=${routedev%% *}
|
|
|
|
|
|
|
|
if [[ -z "$routedev" ]]
|
|
|
|
then
|
2013-07-31 10:29:43 -04:00
|
|
|
echo "127.0.0.1"
|
2013-07-24 14:21:20 -04:00
|
|
|
return 1
|
|
|
|
else
|
|
|
|
local defipaddr=$(ip -o -4 addr show "${routedev}")
|
|
|
|
defipaddr=${defipaddr##* inet }
|
|
|
|
defipaddr=${defipaddr%% *}
|
|
|
|
local mask=${defipaddr#*/}
|
|
|
|
local ip=${defipaddr%/*}
|
|
|
|
|
|
|
|
echo "${ip}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|