-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebinterface0.sh
executable file
·290 lines (248 loc) · 7.02 KB
/
webinterface0.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/bin/sh
echo "Content-type: text/html"
echo ""
MCONFIG=/usr/local/bin/mconfig
RELOAD=/etc/rcS.d/S30mwlan
SETENVFL=/usr/local/bin/setenvlinsingle
APICALL=/usr/local/cgi-bin/api_call.sh
APIREAD=/usr/local/cgi-bin/api_read.sh
board_type=`/usr/local/bin/mconfig board_type`
bandwidth=`echo "$QUERY_STRING" | sed -n 's/^.*bandwidth=\([^&]*\).*$/\1/p'`
if [ "$bandwidth" != "" ]; then
echo ""
else
bandwidth=`${APIREAD} bw`
fi
BW0='';BW1='';
case ${bandwidth} in
5)
BW0='selected'
;;
20)
BW1='selected'
;;
*)
;;
esac
POWER_MW0='';POWER_MW1='';POWER_MW2='';
power_mw=`echo "$QUERY_STRING" | sed -n 's/^.*power_mw=\([^&]*\).*$/\1/p'`
if [ "$power_mw" != "" ]; then
echo ""
else
power_mw=`${APIREAD} power_mw`
fi
GATEWAY_DISABLE0='';GATEWAY_DISABLE1='';
gateway_disable=`echo "$QUERY_STRING" | sed -n 's/^.*gateway_disable=\([^&]*\).*$/\1/p'`
if [ "$gateway_disable" != "" ]; then
echo ""
else
gateway_disable=`${APIREAD} wbg_disable`
fi
case ${power_mw} in
1)
POWER_MW0='selected'
;;
10)
POWER_MW1='selected'
;;
16)
POWER_MW2='selected'
;;
63)
POWER_MW3='selected'
;;
100)
POWER_MW4='selected'
;;
126)
POWER_MW5='selected'
;;
158)
POWER_MW6='selected'
;;
200)
POWER_MW7='selected'
;;
250)
POWER_MW8='selected'
;;
316)
POWER_MW9='selected'
;;
398)
POWER_MW10='selected'
;;
500)
POWER_MW11='selected'
;;
630)
POWER_MW12='selected'
;;
800)
POWER_MW13='selected'
;;
1000)
POWER_MW14='selected'
;;
*)
;;
esac
case ${gateway_disable} in
0)
GATEWAY_DISABLE0='selected'
;;
1)
GATEWAY_DISABLE1='selected'
;;
*)
;;
esac
echo '<html>'
echo '<head>'
echo '<style>'
echo 'html, body {'
echo ' margin:0;'
echo ' width: 100%;'
echo ' height: 100%;'
echo ' padding:0;'
echo ' font-family: Calibri, Verdana;'
echo ' font-size: 0.9em;'
echo '}'
echo '</style>'
echo '<title>Silvus StreamCaster MIMO Radio</title>'
echo '</head>'
echo ''
echo '<body>'
freq=`echo "$QUERY_STRING" | sed -n 's/^.*freq=\([^&]*\).*$/\1/p'`
if [ "$freq" != "" ]; then
echo ""
else
freq=`${APIREAD} freq`
fi
supported_freq=`${APIREAD} supported_frequencies`
echo ''
echo '<h2>Basic Configuration <a href='user_manual.pdf#page=15' target='_blank'><font size='2'>(?)</font></a></h2>'
echo "<form name='form0' action=\"${SCRIPT}\" method=GET>"
echo '<table>'
echo "<tr><td colspan='1'>Frequency (MHz) </td><td> <select name='freq' >"
IFS='
'
for key in $supported_freq
do
if [ "$key" == "$freq" ]; then
is_selected="selected"
else
is_selected=""
fi
echo "<option value=$key $is_selected>$key</option>"
done
echo "</select></tr>"
echo "<tr><td colspan='1'>Bandwidth</td><td> <select name='bandwidth' >\
<option value='5' ${BW0}> 5 MHz\
<option value='20' ${BW1}> 20 MHz\
</select></tr>"
echo '<tr>'
echo ' <td><input type="submit" name="checkpage0" value="Apply"></td>'
echo ' <td><input type="submit" name="checkpage0" value="Save and Apply"></td>'
echo '</tr>'
echo '</table>'
echo '</form>'
echo '<hr>'
echo "<form name='form1' action=\"${SCRIPT}\" method=GET>"
echo '<table>'
echo "<tr><td colspan='1'>Transmit Power</td><td> <select name='power_mw' >\
<option value='1' ${POWER_MW0} > 0 dBm / 1 mW\
<option value='10' ${POWER_MW1} > 10 dBm / 10 mW\
<option value='16' ${POWER_MW2} > 12 dBm / 16 mW\
<option value='63' ${POWER_MW3} > 18 dBm / 63 mW\
<option value='100' ${POWER_MW4} > 20 dBm / 100 mW\
<option value='126' ${POWER_MW5} > 21 dBm / 126 mW\
<option value='158' ${POWER_MW6} > 22 dBm / 158 mW\
<option value='200' ${POWER_MW7} > 23 dBm / 200 mW\
<option value='250' ${POWER_MW8} > 24 dBm / 250 mW\
<option value='316' ${POWER_MW9} > 25 dBm / 316 mW\
<option value='398' ${POWER_MW10} > 26 dBm / 398 mW\
<option value='500' ${POWER_MW11} > 27 dBm / 500 mW\
<option value='630' ${POWER_MW12} > 28 dBm / 630 mW\
<option value='800' ${POWER_MW13} > 29 dBm / 800 mW\
<option value='1000' ${POWER_MW14} > 30 dBm /1000 mW\
</select></tr>"
echo '<tr>'
echo ' <td><input type="submit" name="checkpage1" value="Apply"></td>'
echo ' <td><input type="submit" name="checkpage1" value="Save and Apply"></td>'
echo '</tr>'
echo '</table>'
###for gateway_disable
echo '<hr>'
echo "<form name='form2' action=\"${SCRIPT}\" method=GET>"
echo '<table>'
echo "<tr><td colspan='1'>Gateway </td><td> <select name='gateway_disable' >\
<option value='0' ${GATEWAY_DISABLE0} > Enable\
<option value='1' ${GATEWAY_DISABLE1} > Disable\
</select></tr>"
echo '<tr>'
echo ' <td><input type="submit" name="checkpage2" value="Apply"></td>'
echo ' <td><input type="submit" name="checkpage2" value="Save and Apply"></td>'
echo '</tr>'
echo '</table>'
##gateway_disable
echo '<hr>'
echo "<form name='form3' action=\"${SCRIPT}\" method=GET>"
echo '<input type="submit" name="checkpage3" value="Reboot">'
echo '</form>'
echo '</body>'
echo '</html>'
if [ "$REQUEST_METHOD" != "GET" ]; then
echo "<hr>Script Error:"\
"<br>Usage error, cannot complete request, REQUEST_METHOD!=GET."\
"<br>Check your FORM declaration and be sure to use METHOD=\"GET\".<hr>"
exit 1
fi
X=`echo "$QUERY_STRING" | sed -n 's/^.*checkpage1=\([^&]*\).*$/\1/p'`
Y=`echo "$QUERY_STRING" | sed -n 's/^.*power_mw=\([^&]*\).*$/\1/p'`
X0=`echo "$QUERY_STRING" | sed -n 's/^.*checkpage0=\([^&]*\).*$/\1/p'`
X2=`echo "$QUERY_STRING" | sed -n 's/^.*checkpage3=\([^&]*\).*$/\1/p'`
Y0=`echo "$QUERY_STRING" | sed -n 's/^.*freq=\([^&]*\).*$/\1/p'`
Y1=`echo "$QUERY_STRING" | sed -n 's/^.*bandwidth=\([^&]*\).*$/\1/p'`
#Y2=`echo "$QUERY_STRING" | sed -n 's/^.*mobility=\([^&]*\).*$/\1/p'`
Z=`echo "$QUERY_STRING" | sed -n 's/^.*checkpage2=\([^&]*\).*$/\1/p'`
Z0=`echo "$QUERY_STRING" | sed -n 's/^.*gateway_disable=\([^&]*\).*$/\1/p'`
if [ "$X2" == "Reboot" ]; then
echo '<h2>Now rebooting ....</h2>'
/sbin/reboot
echo "Done."
fi
if [ "$X" == "Apply" ]; then
${APICALL} power_mw $Y > /dev/null
elif [ "$X" == "Save+and+Apply" ]; then
${APICALL} power_mw $Y > /dev/null
echo "Saving into flash ... "
${SETENVFL} power_mw $Y > /dev/null
echo "Done."
fi
if [ "$X0" == "Apply" ]; then
echo ""
${APICALL} freq_bw "$Y0\",\"$Y1"
#echo $Y2 > /dev/shm/radio/mobility
#${RELOAD} > /dev/null 2>&1 /dev/null
echo "Done."
elif [ "$X0" == "Save+and+Apply" ] ; then
echo ""
echo "Saving into flash ... "
${SETENVFL} freq $Y0 > /dev/null
${SETENVFL} bw $Y1 > /dev/null
#${SETENVFL} mobility $Y2 > /dev/null
${APICALL} freq_bw "$Y0\",\"$Y1"
#echo $Y2 > /dev/shm/radio/mobility
#${RELOAD} > /dev/null 2>&1 /dev/null
echo "Done."
fi
if [ "$Z" == "Apply" ]; then
${APICALL} wbg_disable $Z0 > /dev/null
echo "Done."
elif [ "$Z" == "Save+and+Apply" ]; then
${APICALL} wbg_disable $Z0 > /dev/null
echo "Saving into flash ... "
${SETENVFL} gateway_disable $Z0 > /dev/null
echo "Done."
fi