luci-app-bmx6: Fix corner case in bmx6-info?tunnels

The bmx6-info script will return null when no tunnels are known to BMX6.
However, the "Graph" and the "Tunnels" pages expect a JSON structure with an
array of tunnels. In case no tunnels are known to BMX6, bmx6-info now returns
'{ "tunnels" : [] }'.

Fixes #434

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
This commit is contained in:
Roger Pueyo Centelles 2018-12-08 22:20:42 +01:00
parent 9bc518e8c8
commit 2cc3c50bed
1 changed files with 8 additions and 3 deletions

View File

@ -100,7 +100,12 @@ if [ "$QUERY" == 'neighbours' ]; then
fi
if [ "$QUERY" == 'tunnels' ]; then
bmx6 -c --jshow tunnels /r=0
tunnels=$(bmx6 -c --jshow tunnels /r=0)
if [ -z $tunnels ]; then
echo '{ "tunnels" : [] }'
else
echo $tunnels
fi
exit 0
fi