1 | 7 | simandl | #!/bin/bash |
2 | | | # author : Petr Simandl www.simandl.cz |
3 | 15 | simandl | # release date : 1/11/2006 |
4 | 7 | simandl | # name : sedlo |
5 | | | # description : dynamic side routing tables tool |
6 | | | # license : GPL |
7 | | | |
8 | 15 | simandl | sl_version="0.0.4pre6" |
9 | 7 | simandl | |
10 | | | PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin |
11 | | | |
12 | | | sl_nmcnf="sedlo.conf" |
13 | | | sl_sedlocnf="/etc/$sl_nmcnf" |
14 | | | sl_sedlocache="/var/cache/sedlo" |
15 | | | |
16 | | | sl_rttab="/etc/iproute2/rt_tables" |
17 | | | sl_rtnmin=110 |
18 | | | sl_rtnmax=200 |
19 | | | sl_ipnodef="10.0.0.0/8" |
20 | | | |
21 | | | slm_unknown="Nezname parametry : " |
22 | | | |
23 | | | sl_ipcmd=`which ip` |
24 | | | sl_trcmd=`which tr` |
25 | | | sl_wgetcmd=`which wget` |
26 | | | sl_hnmcmd=`which hostname` |
27 | | | sl_awkcmd=`which awk` |
28 | | | sl_catcmd=`which cat` |
29 | | | sl_grepcmd=`which grep` |
30 | 10 | simandl | sl_diffcmd=`which diff` |
31 | 7 | simandl | |
32 | | | if [ -e $sl_sedlocnf ] |
33 | | | then |
34 | | | sl_nop=1 |
35 | | | else |
36 | | | echo "$sl_sedlocnf not found" |
37 | | | exit 1 |
38 | | | fi |
39 | | | |
40 | | | if [ -e $sl_rttab ] |
41 | | | then |
42 | | | sl_nop=1 |
43 | | | else |
44 | | | echo "$sl_rttab not found" |
45 | | | exit 1 |
46 | | | fi |
47 | | | |
48 | 9 | simandl | sl_murlcfg=`cat $sl_sedlocnf | grep "^mcnf" | uniq | awk '{print $2" "$3" "$4}'` |
49 | 7 | simandl | |
50 | | | ###################################################################### |
51 | 8 | simandl | s_maru() |
52 | 7 | simandl | { |
53 | | | if [ $scm_info -gt 0 ]; then echo "Managing rules" ; fi |
54 | | | |
55 | | | sl_rules=`($sl_ipcmd ru ls | $sl_grepcmd -v "from all lookup" | $sl_awkcmd '{print $3"*ru"}' ; \ |
56 | | | $sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd "^ip" | $sl_awkcmd '{print $2"*ip"}') | sort | uniq` |
57 | | | |
58 | | | sl_merged=`echo $sl_rules $sl_ips | sort | uniq` |
59 | | | |
60 | | | echo $sl_merged |
61 | | | |
62 | 8 | simandl | } # s_maru |
63 | 7 | simandl | ###################################################################### |
64 | | | s_flru() |
65 | | | { |
66 | | | if [ $scm_info -gt 0 ]; then echo "Flushing all rules" ; fi |
67 | | | |
68 | | | sl_rules=`$sl_ipcmd ru ls | $sl_grepcmd -v "from all lookup" | $sl_grepcmd " 10." | $sl_trcmd '[:blank:]' '*'` |
69 | | | |
70 | | | for sl_rule in $sl_rules |
71 | | | do |
72 | | | # sl_ipn=`echo $sl_rule | $sl_awkcmd -F '*' '{print $2}'` |
73 | | | sl_ipgws=`echo $sl_rule | $sl_awkcmd -F '*' '{print $2,$3,$4,$5,$6,$7}'` |
74 | | | $sl_ipcmd ru del $sl_ipgws |
75 | | | done |
76 | | | |
77 | 8 | simandl | #this should make faster applying of new routing tables |
78 | | | $sl_ipcmd ro flush cache |
79 | | | |
80 | 7 | simandl | } # s_flru |
81 | 8 | simandl | |
82 | 7 | simandl | ###################################################################### |
83 | 10 | simandl | # here we get each ip and we create a rule to send this ip to a |
84 | | | # certain table |
85 | | | # this routine can be skipped when the number of ips and ip directions |
86 | | | # are still the same = old and new configs are the same |
87 | 7 | simandl | s_fillrules() |
88 | | | { |
89 | 8 | simandl | |
90 | | | #flush old rules before filling new ones |
91 | | | #not so nice solution - it is planned to change just what's necessary |
92 | | | #by s_maru |
93 | 7 | simandl | s_flru |
94 | | | |
95 | 10 | simandl | if [ $scm_info -gt 0 ]; then echo "Creating rules for ips" ; fi |
96 | 7 | simandl | |
97 | | | sl_ips=`$sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd "^ip" | $sl_awkcmd '{print $2"*"$4"*"$5"*"$6}'` |
98 | | | |
99 | | | for sl_ip in $sl_ips |
100 | | | do |
101 | | | sl_ipn=`echo $sl_ip | $sl_awkcmd -F '*' '{print $1}'` |
102 | | | sl_ipgws=`echo $sl_ip | $sl_awkcmd -F '*' '{print $2,$3,$4}'` |
103 | | | sl_ok="no" |
104 | | | for sl_ipgw in $sl_ipgws |
105 | | | do |
106 | | | sl_tbl=`$sl_ipcmd ro ls ta $sl_ipgw` |
107 | | | if [ "$sl_tbl x" != " x" ] && [ "$sl_ok" = "no" ] |
108 | | | then |
109 | | | if [ $scm_info -gt 1 ]; then echo "Creating new rules to send $sl_ipn to table $sl_ipgw" ; fi |
110 | | | $sl_ipcmd ru add from $sl_ipn lookup $sl_ipgw |
111 | | | sl_ok="yes" |
112 | | | else |
113 | | | if [ "$sl_ok" = "no" ] |
114 | | | then |
115 | | | if [ $scm_info -gt 1 ]; then echo "For $sl_ipn table $sl_ipgw not used because it is empty" ; fi |
116 | | | else |
117 | | | if [ $scm_info -gt 1 ]; then echo "For $sl_ipn table $sl_ipgw not used because it has lower priority" ; fi |
118 | | | fi |
119 | | | fi |
120 | | | done |
121 | | | done |
122 | | | |
123 | | | $sl_ipcmd ru add from $sl_ipnodef to $sl_ipnodef lookup main |
124 | | | |
125 | 8 | simandl | #this should make faster applying of new routing tables |
126 | | | $sl_ipcmd ro flush cache |
127 | | | |
128 | 7 | simandl | } # s_fillrules |
129 | 8 | simandl | |
130 | 7 | simandl | ###################################################################### |
131 | 10 | simandl | # here we look into the main routing table for path to our iGWs |
132 | | | # and we fill these tables with two halves default nets that |
133 | | | # point to appropriate direction |
134 | | | # this routine can be skipped when the routing table is the same |
135 | 7 | simandl | s_filltables() |
136 | | | { |
137 | 10 | simandl | if [ $scm_info -gt 0 ]; then echo "Checking main routing table" ; fi |
138 | | | |
139 | 7 | simandl | if [ $scm_info -gt 0 ]; then echo "Filling tables" ; fi |
140 | | | |
141 | 9 | simandl | sl_igws=`$sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd -E "^igw|^myigw" | $sl_awkcmd '{print $3"*"$2"*"$1}'` |
142 | 7 | simandl | |
143 | | | for sl_igw in $sl_igws |
144 | | | do |
145 | | | sl_igwn=`echo $sl_igw | $sl_awkcmd -F '*' '{print $1}'` |
146 | | | sl_igwip=`echo $sl_igw | $sl_awkcmd -F '*' '{print $2}'` |
147 | 9 | simandl | sl_igwtype=`echo $sl_igw | $sl_awkcmd -F '*' '{print $3}'` |
148 | 15 | simandl | |
149 | 14 | simandl | #oprava falesneho routovani na lokalni iface - pokud jsme lokalni igw tak se nema najit ip |
150 | | | #protoze cesta dal neni - jsme totiz uz na lokalnim iface |
151 | 15 | simandl | #head je tam proto ze se pro prespolni(a bgp) muze objevit vice rout s ruznou metrikou tak vezmem jen prvni (head) |
152 | | | #s nejmensi metrikou (sort) |
153 | | | sl_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd -v "proto kernel" | $sl_grepcmd "^$sl_igwip " | sort | $sl_awkcmd '{print $3}' | head -n 1` |
154 | 7 | simandl | |
155 | 9 | simandl | # equal cost multipath detection - just first IP is taken as way to igw |
156 | 7 | simandl | if [ "$sl_igwgt x" = "zebra x" ] |
157 | | | then |
158 | | | sl_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd -A 1 "^$sl_igwip " | $sl_grepcmd "nexthop" | $sl_awkcmd '{print $3}'` |
159 | | | fi |
160 | | | |
161 | 9 | simandl | #if myigw then fill table for local gateway with single ip from config |
162 | | | if [ "$sl_igwtype x" = "myigw x" ] |
163 | | | then |
164 | | | sl_igwgt=$sl_igwip |
165 | | | fi |
166 | 11 | simandl | #testing if the igw has not a route in global routing table |
167 | 7 | simandl | if [ "$sl_igwgt x" = " x" ] |
168 | | | then |
169 | 11 | simandl | if [ $scm_info -gt 1 ]; then echo "Route not found for igw $sl_igwn" ; fi |
170 | | | sl_myigw=`cat $sl_sedlocnf | $sl_grepcmd "^myigw" | $sl_grepcmd $sl_igwn | $sl_awkcmd '{print $3}'` |
171 | | | #testing if the igw without route is in local config |
172 | | | #if not we go to flush its table and set flag to redo rules |
173 | | | if [ "$sl_myigw x" = " x" ] |
174 | | | then |
175 | | | #getting num of routes of igw |
176 | 13 | simandl | sl_igwnr=`$sl_ipcmd ro ls ta all | $sl_grepcmd -c "table ${sl_igwn} "` |
177 | 11 | simandl | if [ "$sl_igwnr x" = "0 x" ] |
178 | | | then |
179 | 12 | simandl | if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn is already empty - no action taken" ; fi |
180 | 11 | simandl | else |
181 | 12 | simandl | if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will be flushed and rules rearranged" ; fi |
182 | 11 | simandl | $sl_ipcmd ro fl ta $sl_igwn |
183 | | | #because this igw dissapeared we set a flag for rules recreation |
184 | | | sl_diffigw=1 |
185 | | | fi |
186 | | | else |
187 | 13 | simandl | if [ $scm_info -gt 1 ]; then echo "Igw $sl_igwn found in local config - leaving table as is" ; fi |
188 | 11 | simandl | fi |
189 | 7 | simandl | else |
190 | | | sl_tbl=`$sl_ipcmd ro ls ta $sl_igwn` |
191 | 12 | simandl | #if the table is empty we fill it and we set flag for rules recreation |
192 | | | if [ "$sl_tbl x" = " x" ] |
193 | 7 | simandl | then |
194 | 12 | simandl | sl_diffigw=1 |
195 | | | $sl_ipcmd ro add 0.0.0.0/1 via $sl_igwgt ta $sl_igwn |
196 | | | $sl_ipcmd ro add 128.0.0.0/1 via $sl_igwgt ta $sl_igwn |
197 | | | if [ "$sl_igwtype x" = "myigw x" ] |
198 | | | then |
199 | | | if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn filled with default myigw $sl_igwgt" ; fi |
200 | | | else |
201 | | | if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn filled with default gw $sl_igwgt" ; fi |
202 | | | fi |
203 | | | #the table is not empty so we check if routes are the same |
204 | 9 | simandl | else |
205 | 12 | simandl | #picking default gateway from the table |
206 | | | sl_igwogt=`$sl_ipcmd ro ls ta $sl_igwn | $sl_awkcmd '{print $3}' | uniq` |
207 | | | #checking if the old default is same as the new one |
208 | | | if [ "$sl_igwogt x" = "$sl_igwgt x" ] |
209 | | | then |
210 | | | if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will not be changed and default is $sl_igwgt" ; fi |
211 | | | else |
212 | | | #the new default is different so we will flush the table, fill new default |
213 | 15 | simandl | if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will be rewritten to default $sl_igwgt" ; fi |
214 | 12 | simandl | #flushing old default route in the table |
215 | | | $sl_ipcmd ro fl ta $sl_igwn |
216 | | | #filling new default |
217 | | | $sl_ipcmd ro add 0.0.0.0/1 via $sl_igwgt ta $sl_igwn |
218 | | | $sl_ipcmd ro add 128.0.0.0/1 via $sl_igwgt ta $sl_igwn |
219 | | | fi |
220 | 9 | simandl | fi |
221 | 7 | simandl | fi |
222 | | | done |
223 | | | |
224 | | | } # s_filltables |
225 | 8 | simandl | |
226 | 7 | simandl | ###################################################################### |
227 | 10 | simandl | # filling rttab with tables from config |
228 | | | # only new tables are created with a new uniq number that is not important because |
229 | | | # usually we handle tables just by their names |
230 | | | # this routine acts only when a new iGW appears - only adding a table is supported |
231 | | | # no deleting is implemented because it seems to be not necessary to delete an old table |
232 | | | # because there is space enough and after reboot table will not be created |
233 | 7 | simandl | s_mktables() |
234 | | | { |
235 | 10 | simandl | if [ $scm_info -gt 0 ]; then echo "Checking tables" ; fi |
236 | | | |
237 | 9 | simandl | sl_igws=`$sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd -E "^igw|^myigw" | $sl_awkcmd '{print $3}'` |
238 | 7 | simandl | for sl_igw in $sl_igws |
239 | | | do |
240 | | | sl_igwrttb=`$sl_catcmd $sl_rttab | $sl_awkcmd '{print $2}' | $sl_grepcmd $sl_igw ` |
241 | | | if [ "$sl_igwrttb x" = " x" ] |
242 | | | then |
243 | | | if [ $scm_info -gt 1 ]; then echo "Creating table for $sl_igw" ; fi |
244 | | | sl_cnt="$sl_rtnmax" |
245 | | | sl_ok="no" |
246 | | | until [ "$sl_cnt" -eq "$sl_rtnmin" ] || [ "$sl_ok" = "yes" ] |
247 | | | do |
248 | | | #space is used to recognized two and three digit numbers |
249 | | | sl_igwrttb=`cat $sl_rttab | awk '{print $1" "}' | grep "$sl_cnt " ` |
250 | | | if [ "$sl_igwrttb x" = " x" ] |
251 | | | then |
252 | | | sl_ok="yes" |
253 | | | echo "$sl_cnt $sl_igw" >> $sl_rttab |
254 | | | fi |
255 | | | sl_cnt=$(($sl_cnt - 1 )) |
256 | 11 | simandl | done |
257 | | | # a new table was created so we should set a flag for rules creation |
258 | | | sl_difftbl=1 |
259 | 7 | simandl | else |
260 | | | if [ $scm_info -gt 1 ]; then echo "Table found for $sl_igw no action taken" ; fi |
261 | | | fi |
262 | 9 | simandl | done |
263 | 7 | simandl | } # s_mktables |
264 | 8 | simandl | |
265 | 7 | simandl | ###################################################################### |
266 | | | s_getcfg() |
267 | | | { |
268 | | | if [ $scm_info -gt 0 ]; then echo "Getting config" ; fi |
269 | | | if [ $scm_info -gt 1 ]; then echo "Using main config $sl_murlcfg" ; fi |
270 | | | if [ $scm_info -gt 1 ]; then echo "Using local config $sl_sedlocnf" ; fi |
271 | | | |
272 | 10 | simandl | rm -f "$sl_sedlocache/$sl_nmcnf.main.tmp" |
273 | 7 | simandl | |
274 | 10 | simandl | $sl_wgetcmd -q -t 3 $sl_murlcfg -O "$sl_sedlocache/$sl_nmcnf.main.tmp" |
275 | | | |
276 | 7 | simandl | if [ -s $sl_sedlocache/$sl_nmcnf.main.tmp ] |
277 | | | then |
278 | | | date > $sl_sedlocache/last_getcnf.txt |
279 | | | cp $sl_sedlocache/$sl_nmcnf.main.tmp $sl_sedlocache/$sl_nmcnf.main |
280 | 10 | simandl | if [ $scm_info -gt 1 ]; then echo "Main config downloaded and accepted" ; fi |
281 | 7 | simandl | else |
282 | 8 | simandl | if [ $scm_info -gt 1 ]; then echo "Main config not downloaded - cached config will be used" ; fi |
283 | | | echo -n "Main config not downloaded " > $sl_sedlocache/last_getcnf.txt |
284 | 7 | simandl | date >> $sl_sedlocache/last_getcnf.txt |
285 | | | fi |
286 | | | |
287 | 10 | simandl | # before generating a new cached config we store the old one for |
288 | | | # comparison with the new one |
289 | | | rm -f "$sl_sedlocache/$sl_nmcnf.old" |
290 | | | if [ -s $sl_sedlocache/$sl_nmcnf ] |
291 | | | then |
292 | | | cp $sl_sedlocache/$sl_nmcnf $sl_sedlocache/$sl_nmcnf.old |
293 | | | else |
294 | | | touch $sl_sedlocache/$sl_nmcnf.old |
295 | | | fi |
296 | | | |
297 | 7 | simandl | # preparing cached config from local and main |
298 | | | # the local config should be processed as the second to have |
299 | | | # higher priority for rules from local config |
300 | | | echo "# generated file" > $sl_sedlocache/$sl_nmcnf |
301 | | | for sl_file in `ls $sl_sedlocache/$sl_nmcnf.main ; ls $sl_sedlocnf` |
302 | | | do |
303 | | | cat $sl_file | grep "^mcnf" | $sl_trcmd ';' '#' | awk '{print $1"\t"$2}' >> $sl_sedlocache/$sl_nmcnf |
304 | | | cat $sl_file | grep "^igw" | $sl_trcmd ';' '#' | awk '{print $1"\t"$2"\t"$3}' >> $sl_sedlocache/$sl_nmcnf |
305 | | | cat $sl_file | grep "^ip" | $sl_trcmd ';' '#' | awk '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6}' >> $sl_sedlocache/$sl_nmcnf |
306 | | | done |
307 | 8 | simandl | |
308 | | | #local gateways taken from local config |
309 | | | cat $sl_sedlocnf | grep "^myigw" | $sl_trcmd ';' '#' | awk '{print $1"\t"$2"\t"$3}' >> $sl_sedlocache/$sl_nmcnf |
310 | | | |
311 | 7 | simandl | #cat $sl_sedlocache/$sl_nmcnf | sort | uniq > $sl_sedlocache/$sl_nmcnf.uniq |
312 | | | #mv $sl_sedlocache/$sl_nmcnf.uniq $sl_sedlocache/$sl_nmcnf |
313 | | | |
314 | 10 | simandl | sl_diffcfg=`diff $sl_sedlocache/$sl_nmcnf $sl_sedlocache/$sl_nmcnf.old | grep -c .` |
315 | | | if [ $sl_diffcfg -gt 0 ] |
316 | | | then |
317 | | | if [ $scm_info -gt 0 ]; then echo "New config is different than the old one" ; fi |
318 | | | else |
319 | | | if [ $scm_info -gt 0 ]; then echo "New config is the same as the old one" ; fi |
320 | | | fi |
321 | | | |
322 | 11 | simandl | # showing number of rules in config and system |
323 | 10 | simandl | sl_numru=`ip ru ls | grep -c lookup` |
324 | | | sl_numip=`grep -c ^ip $sl_sedlocache/$sl_nmcnf` |
325 | | | sl_numru=$(($sl_numru - 3 )) |
326 | | | if [ $sl_numip -gt $sl_numru ] |
327 | | | then |
328 | | | if [ $scm_info -gt 0 ]; then echo "We have less rules ($sl_numru) than new config has ips ($sl_numip)" ; fi |
329 | 11 | simandl | # sl_diffcfg="1" |
330 | 10 | simandl | else |
331 | | | if [ $scm_info -gt 0 ]; then echo "We have $sl_numru rules and $sl_numip ips" ; fi |
332 | | | fi |
333 | | | |
334 | 7 | simandl | } |
335 | 8 | simandl | |
336 | 7 | simandl | ###################################################################### |
337 | | | s_version() |
338 | | | { |
339 | | | echo sedlo $sl_version |
340 | | | } # s_version |
341 | 8 | simandl | |
342 | 7 | simandl | ###################################################################### |
343 | | | s_report() |
344 | | | { |
345 | 9 | simandl | echo Content-type: text/html |
346 | | | echo |
347 | | | echo "Sedlo na routeru `hostname`" |
348 | | | echo "<pre>" |
349 | 7 | simandl | echo "##### SEDLO #####" |
350 | | | echo "date : `date`" |
351 | | | echo "version : $sl_version" |
352 | | | echo "local_config : $sl_sedlocnf" |
353 | 9 | simandl | echo "main_config : <a href=\"$sl_murlcfg\">$sl_murlcfg</a>" |
354 | 7 | simandl | echo "last update : `cat $sl_sedlocache/last_getcnf.txt`" |
355 | | | echo "##### TABLES #####" |
356 | | | cat $sl_rttab |
357 | 9 | simandl | echo ; echo "##### DEFAULT ROUTES IN TABLES #####" |
358 | | | $sl_ipcmd ro ls ta all | $sl_grepcmd table | $sl_grepcmd -v local | $sl_trcmd " " "\t" |
359 | | | echo ; echo "##### RULES FOR IPS #####" |
360 | | | $sl_ipcmd ru ls | $sl_trcmd " " "\t" |
361 | | | echo "</pre>" |
362 | 7 | simandl | } # s_report |
363 | 8 | simandl | |
364 | 9 | simandl | |
365 | | | |
366 | 7 | simandl | ###################################################################### |
367 | | | s_help() |
368 | | | { |
369 | | | echo Pouziti: sedlo [param] |
370 | | | echo param: |
371 | | | echo -V vypise verzi |
372 | | | echo -help vypise napovedu |
373 | | | echo -v malo upovidany |
374 | | | echo -vv hodne upovidany |
375 | | | echo -nogetcfg zajisti ze se nedude znovu nacitat konfigurace a pouzije se predchozi z cache |
376 | | | echo -report vypise prehled pravidel a tabulek |
377 | | | echo -flru odstrani vsechny pravidla |
378 | 11 | simandl | echo -force bezpodminecne znovu obnovi vsechny pravidla |
379 | 7 | simandl | } # s_help |
380 | 8 | simandl | |
381 | 7 | simandl | ###################################################################### |
382 | | | ###################################################################### |
383 | | | |
384 | | | sl_unknown="" |
385 | | | scm_nogetcfg=0 |
386 | | | scm_flru=0 |
387 | | | scm_info=0 |
388 | 11 | simandl | scm_force=0 |
389 | | | sl_diffigw=0 |
390 | | | sl_difftbl=0 |
391 | 7 | simandl | |
392 | | | # parsing input parameters |
393 | | | while [ "a$1" != "a" ] |
394 | | | do |
395 | | | case $1 in |
396 | | | -V) |
397 | | | s_version |
398 | | | exit 0 |
399 | | | ;; |
400 | | | -h) |
401 | | | s_help |
402 | | | exit 0 |
403 | | | ;; |
404 | | | -report) |
405 | | | s_report |
406 | | | exit 0 |
407 | | | ;; |
408 | | | -flru) |
409 | | | scm_flru=1 |
410 | | | shift |
411 | | | ;; |
412 | 11 | simandl | -force) |
413 | | | scm_force=1 |
414 | | | shift |
415 | | | ;; |
416 | 7 | simandl | -help) |
417 | | | s_help |
418 | | | exit 0 |
419 | | | ;; |
420 | | | -nogetcfg) |
421 | | | scm_nogetcfg=1 |
422 | | | shift |
423 | | | ;; |
424 | | | -v) |
425 | | | scm_info=1 |
426 | | | shift |
427 | | | ;; |
428 | | | -vv) |
429 | | | scm_info=2 |
430 | | | shift |
431 | | | ;; |
432 | | | *) |
433 | | | sl_unknown="$sl_unknown$1 " |
434 | | | shift |
435 | | | esac |
436 | | | done |
437 | | | |
438 | | | # printing the list of bad parameters (if there are some) |
439 | | | if [ "a$sl_unknown" != "a" ] |
440 | | | then |
441 | | | echo "$slm_unknown $sl_unknown" |
442 | | | s_help |
443 | | | exit 0 |
444 | | | fi |
445 | | | |
446 | | | if [ $scm_flru -eq 1 ] |
447 | | | then |
448 | | | s_flru |
449 | | | exit 0 |
450 | | | fi |
451 | | | |
452 | | | if [ $scm_nogetcfg -eq 0 ] |
453 | | | then |
454 | | | s_getcfg |
455 | | | fi |
456 | | | |
457 | | | s_mktables |
458 | | | s_filltables |
459 | 15 | simandl | #toto je pro ladici ucely |
460 | 11 | simandl | #echo $sl_difftbl |
461 | | | #echo $sl_diffcfg |
462 | | | #echo $sl_diffigw |
463 | | | #echo $scm_force |
464 | 13 | simandl | #exit 0 |
465 | 15 | simandl | |
466 | 11 | simandl | #flushing and filling rules is done only when |
467 | | | #new table is created |
468 | | | #config is changed |
469 | | | #some igw dissapears or appears |
470 | | | #-force command line parameter was used |
471 | | | if [ $sl_difftbl -gt 0 ] || [ $sl_diffcfg -gt 0 ] || [ $sl_diffigw -gt 0 ] || [ $scm_force -gt 0 ] |
472 | 10 | simandl | then |
473 | | | s_fillrules |
474 | | | fi |
475 | | | |
476 | 7 | simandl | exit 0 |