contrib/package/freifunk-policyrouting: remove rc.d symlink
[project/luci.git] / contrib / package / freifunk-common / files / usr / bin / neigh.sh
1 #!/bin/sh
2
3 . /usr/share/libubox/jshn.sh
4
5 VARS="localIP:Local remoteIP:Remote validityTime:vTime linkQuality:LQ neighborLinkQuality:NLQ linkCost:Cost"
6
7 for HOST in 127.0.0.1 ::1;do
8         json_init
9         json_load "$(echo /links|nc ${HOST} 9090)"
10         if json_is_a links array;then
11                 json_select links
12                 for v in ${VARS};do
13                         eval _${v%:*}=0
14                 done
15                 for j in 0 1;do
16                         case ${j} in 1)
17                                 for v in ${VARS};do
18                                         eval printf \"%-\${_${v%:*}}s \" ${v#*:}
19                                 done
20                                 echo
21                         ;;esac
22                         i=1;while json_is_a ${i} object;do
23                                 json_select ${i}
24                                 json_get_vars $(for v in ${VARS};do echo ${v%:*};done)
25                                 case ${j} in 0)
26                                         for v in ${VARS};do
27                                                 eval "test \${_${v%:*}} -lt \${#${v%:*}} && _${v%:*}=\${#${v%:*}}"
28                                         done
29                                 ;;*)
30                                         for v in ${VARS};do
31                                                 eval printf \"%-\${_${v%:*}}s \" \$${v%:*}
32                                         done
33                                         echo
34                                 ;;esac
35                                 json_select ..
36                                 i=$(( i + 1 ))
37                         done
38                 done
39         fi
40         echo
41 done