Rework LuCI build system
[project/luci.git] / applications / luci-app-olsr-viz / htdocs / cgi-bin / vizdata.sh
1 #!/bin/sh
2 echo Content-type: text/html
3 echo
4
5 cat<<EOF
6 <HTML>
7 <HEAD>
8         <TITLE>OLSR-VIZ Data</TITLE>
9         <META CONTENT="text/html; charset=iso-8859-1" HTTP-EQUIV="Content-Type">
10         <META CONTENT="no-cache" HTTP-EQUIV="cache-control">
11 </HEAD>
12 <BODY>
13
14 <script langauge='JavaScript1.2' type='text/javascript'>
15 EOF
16
17 # sed + txtinfo plugin
18 re_ip='[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}'
19 re_sep='[[:space:]]\{1,\}'
20 re_nosep='[^[:space:]]\{1,\}'
21 wget http://127.0.0.1:2006/all -qO - | sed -n "
22 /^Table: Links$/,/^$/ {
23 s#              #       -       #g
24 s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{3\}$re_sep\($re_nosep\)#parent.touch_edge(parent.touch_node('\1').set_metric(1).update(),parent.touch_node('\2').set_metric(1).update(),'\4');#p
25 }
26 /^Table: Topology$/,/^$/ {
27 s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{2\}$re_sep\($re_nosep\)#parent.touch_edge(parent.touch_node('\1').update(),parent.touch_node('\2').update(),'\4');#p
28 }
29 /^Table: HNA$/,/^$/ {
30 s#\($re_ip\)/\([0-9]\{1,\}\)$re_sep\($re_ip\)#parent.touch_hna(parent.touch_node('\3'),'\1','\2');#p
31 }
32 /^Table: Routes$/,/^$/ {
33 s#\($re_ip\)/32$re_sep$re_nosep$re_sep\($re_nosep\).*#parent.touch_node('\1').set_metric('\2').update();#p
34 }
35 "
36
37 hosts=$(uci show olsrd|grep hosts_file|cut -d "=" -f 2)
38 if [ -n $hosts ]; then
39 sed -n "
40 s#\($re_ip\)$re_sep\($re_nosep\)$re_sep.*#parent.touch_node('\1').set_desc('\2');#p
41 " < $hosts
42 fi
43
44 cat<<EOF
45         parent.viz_callback();
46 </script>
47 </BODY></HTML>
48 EOF