summaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
authorPatrick Grimm <patrick@lunatiki.de>2013-10-14 17:29:40 +0000
committerPatrick Grimm <patrick@lunatiki.de>2013-10-14 17:29:40 +0000
commitb8fe93a8368223da2ca9b56f0a1ca1b1e3740cd9 (patch)
tree322c4cbf02f7f4aed13f014ef98678e04ed5df80 /contrib
parent31ce19743a276d1f3963a818b6c66965615e804a (diff)
package/freifunk-common: neigh.sh: fix for missing .. as well as aligned headers
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/package/freifunk-common/files/usr/bin/neigh.sh37
1 files changed, 28 insertions, 9 deletions
diff --git a/contrib/package/freifunk-common/files/usr/bin/neigh.sh b/contrib/package/freifunk-common/files/usr/bin/neigh.sh
index 4c734ae22..cf4342450 100755
--- a/contrib/package/freifunk-common/files/usr/bin/neigh.sh
+++ b/contrib/package/freifunk-common/files/usr/bin/neigh.sh
@@ -2,21 +2,40 @@
. /usr/share/libubox/jshn.sh
+VARS="localIP:Local remoteIP:Remote validityTime:vTime linkQuality:LQ neighborLinkQuality:NLQ linkCost:Cost"
+
for HOST in 127.0.0.1 ::1;do
json_init
json_load "$(echo /links|nc ${HOST} 9090)"
if json_is_a links array;then
- echo "LocalIP RemoteIP vTime LQ NLQ Cost"
json_select links
- i=1
- while json_is_a ${i} object;do
- json_select ${i}
- json_get_vars localIP remoteIP validityTime linkQuality neighborLinkQuality linkCost
- echo "${localIP} ${remoteIP} ${validityTime} ${linkQuality} ${neighborLinkQuality} ${linkCost}"
- json_select
- i=$(( i + 1 ))
+ for v in ${VARS};do
+ eval _${v%:*}=0
+ done
+ for j in 0 1;do
+ case ${j} in 1)
+ for v in ${VARS};do
+ eval printf \"%-\${_${v%:*}}s \" ${v#*:}
+ done
+ echo
+ ;;esac
+ i=1;while json_is_a ${i} object;do
+ json_select ${i}
+ json_get_vars $(for v in ${VARS};do echo ${v%:*};done)
+ case ${j} in 0)
+ for v in ${VARS};do
+ eval "test \${_${v%:*}} -lt \${#${v%:*}} && _${v%:*}=\${#${v%:*}}"
+ done
+ ;;*)
+ for v in ${VARS};do
+ eval printf \"%-\${_${v%:*}}s \" \$${v%:*}
+ done
+ echo
+ ;;esac
+ json_select ..
+ i=$(( i + 1 ))
+ done
done
fi
echo
done
-