Added trap functions for bash agents or wrapper-agents
This commit is contained in:
parent
2c4d39eec6
commit
e1b91843df
1 changed files with 31 additions and 0 deletions
31
scripts/trap.functions
Normal file
31
scripts/trap.functions
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
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
|
||||
echo ""
|
||||
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
|
||||
|
||||
#echo "$routedev"
|
||||
#echo "${ip}/${mask}"
|
||||
}
|
||||
|
Loading…
Reference in a new issue