-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_constant_metrics_olsrv1.sh
executable file
·112 lines (97 loc) · 3.29 KB
/
set_constant_metrics_olsrv1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env sh
testbed=$1
# metric string format: "IPnode1:IPnd1-cost,IPnd2-cost,...;IPnode2:IPnd1-cost,..."
# Per node metrics are separeted by ";"
# Each per node metric is composed by a node IP before ":" (e.g., IPnode1) that
# identifies the local node,
# followed by a comma separated list of <destination node IPs>-<link cost>
# pairs.
metrics=$2
hello_mult=$3
tc_mult=$4
disablelq=$5
disablelq_str=""
if [ "$disablelq" = "True" ]; then
disablelq_str="LinkQualityLevel 0"
fi
# timers string format: "IPnode1:hello,tc;..."
timers=$6
opkg_path=`which opkg`
if [ -z "$opkg_path" ]; then
host_name=`hostname | cut -d'.' -f 1`
else
host_name=`uci get system.@system[0].hostname`
echo "WARNING: metrics deployment on OpenWRT not implemented yet"
exit 1
fi
metrics_out=""
if [ "${metrics}" != "undefined" ]; then
for n in $(echo $metrics | sed -e "s/;/ /g")
do
node_ip=$(echo ${n} | cut -d ':' -f 1)
node_name=$(cat /etc/hosts | grep "${node_ip} " | cut -d ' ' -f 2 | sed -e 's/^pop-\(.*$\)/\1/')
metric_per_dst=$(echo ${n} | cut -d ':' -f 2)
if [ "$host_name" = "$node_name" ]; then
for dst_cost in $(echo ${metric_per_dst} | sed -e "s/,/ /g")
do
dst=$(echo ${dst_cost} | cut -d '-' -f 1)
cost=$(echo ${dst_cost} | cut -d '-' -f 2)
metrics_out="${metrics_out} LinkQualityMult ${dst} ${cost}\n"
done
fi
done
fi
timers_out=""
if [ $# -eq 6 ]; then
# we also have to set fixed timers
for n in $(echo $timers | sed -e "s/;/ /g")
do
node_ip=$(echo ${n} | cut -d ':' -f 1)
node_name=$(cat /etc/hosts | grep "${node_ip} " | cut -d ' ' -f 2 | sed -e 's/^pop-\(.*$\)/\1/')
if [ "$host_name" = "$node_name" ]; then
hello_interval=$(echo ${n} | cut -d':' -f 2 | cut -d',' -f 1)
hello_val=$(echo "scale=2; ${hello_interval}*${hello_mult}" | bc)
#hello_val=$(echo "scale=2; ${hello_interval}*10" | bc)
tc_interval=$(echo ${n} | cut -d':' -f 2 | cut -d',' -f 2)
tc_val=$(echo "scale=2; ${tc_interval}*${tc_mult}" | bc)
#tc_val=$(echo "scale=2; ${tc_interval}*60" | bc)
timers_out="HelloInterval ${hello_interval}\nHelloValidityTime ${hello_val}\nTcInterval ${tc_interval}\nTcValidityTime ${tc_val}"
#timers_out="HelloInterval ${hello_interval}\nHelloValidityTime ${hello_val}\nTcInterval ${tc_interval}"
#timers_out="HelloInterval ${hello_interval}\nTcInterval ${tc_interval}\n"
fi
done
else
hello_validity=$(echo "scale=2; 2.00*${hello_mult}" | bc)
tc_validity=$(echo "scale=2; 5.00*${tc_mult}" | bc)
timers_out="HelloInterval 2.00\nHelloValidityTime ${hello_validity}\nTcInterval 5.00\nTcValidityTime ${tc_validity}"
#timers_out="HelloInterval 2.00\nHelloValidityTime 20.00\nTcInterval 5.00\nTcValidityTime 300.00"
#timers_out="HelloInterval 2.00\nHelloValidityTime 20.00\nTcInterval 5.00\n"
#timers_out="HelloInterval 2.00\nTcInterval 5.00"
fi
metrics_out=$(cat <<EOF
DebugLevel 0
IpVersion 4
LoadPlugin "olsrd_jsoninfo.so.1.1" {
}
LoadPlugin "olsrd_txtinfo.so.1.1" {
}
LoadPlugin "olsrd_poprouting.so.0.1" {
PlParam "port" "1234"
}
${disablelq_str}
InterfaceDefaults
{
${metrics_out}
${timers_out}
}
LinkQualityFishEye 0
EOF
)
echo "${metrics_out}" | sudo tee /tmp/olsrd.conf
opkg_path=`which opkg`
if [ -z "$opkg_path" ]; then
sudo cp /tmp/olsrd.conf /etc/olsrd/olsrd.conf
else
echo "WARNING: constant metrics deployment not implemented on OpenWRT"
exit 1
fi