You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
38 lines
1.0 KiB
4 years ago
|
|
||
|
|
||
|
function ifup {
|
||
|
if [[ ! -d /sys/class/net/${1} ]]; then
|
||
|
return 1
|
||
|
else
|
||
|
[[ $(</sys/class/net/${1}/carrier) == 1 ]]
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
if ifup $1; then
|
||
|
hybridswarm='Online'
|
||
|
else
|
||
|
hybridswarm='NotOnline'
|
||
|
fi
|
||
|
|
||
|
|
||
|
dockerswarm=$(docker info --format "{{json .}}" | jq .Swarm.LocalNodeState)
|
||
|
tempswarm="${dockerswarm%\"}"
|
||
|
tempswarm="${tempswarm#\"}"
|
||
|
dockerswarm=$tempswarm
|
||
|
|
||
|
dockerswarmid=$(docker info --format "{{json .}}" | jq .Swarm.NodeID)
|
||
|
tempswarm1="${dockerswarmid%\"}"
|
||
|
tempswarm1="${tempswarm1#\"}"
|
||
|
swarmlabid=$tempswarm1
|
||
|
#echo $dockerswarm
|
||
|
#echo $hybridswarm
|
||
|
#echo $swarmlabid
|
||
|
|
||
|
#jq --arg key0 'swarmlab' --arg swarmlab $dockerswarm --arg key1 'hybrid' --arg hybrid $hybridswarm --arg key2 'swarmlabid' --arg swarmlabid $swarmlabid'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}'
|
||
|
jq \
|
||
|
--arg key0 'swarmlab' --arg swarmlab $dockerswarm \
|
||
|
--arg key1 'hybrid' --arg hybrid $hybridswarm \
|
||
|
--arg key2 'swarmlabid' --arg swarmlabid $swarmlabid \
|
||
|
'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}'
|
||
|
|