sedlo |
Subversion Repositories: |
Rev 12 | Rev 13 | |
---|---|---|
Line 1... | Line 1... | |
#!/bin/bash |
#!/bin/bash | |
# author : Petr Simandl www.simandl.cz |
# author : Petr Simandl www.simandl.cz | |
# release date : 06/08/2006 |
# release date : 08/09/2006 | |
# name : sedlo |
# name : sedlo | |
# description : dynamic side routing tables tool |
# description : dynamic side routing tables tool | |
# license : GPL |
# license : GPL | |
|
| |
sl_version="0.0.4pre3" |
sl_version="0.0.4pre4" | |
|
| |
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin |
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin | |
|
| |
sl_nmcnf="sedlo.conf" |
sl_nmcnf="sedlo.conf" | |
sl_sedlocnf="/etc/$sl_nmcnf" |
sl_sedlocnf="/etc/$sl_nmcnf" | |
Line 167... | Line 167... | |
#testing if the igw without route is in local config |
#testing if the igw without route is in local config | |
#if not we go to flush its table and set flag to redo rules |
#if not we go to flush its table and set flag to redo rules | |
if [ "$sl_myigw x" = " x" ] |
if [ "$sl_myigw x" = " x" ] | |
then |
then | |
#getting num of routes of igw |
#getting num of routes of igw | |
sl_igwnr=`$sl_ipcmd ro ls ta all | $sl_grepcmd -c $sl_igwn` |
sl_igwnr=`$sl_ipcmd ro ls ta all | $sl_grepcmd -c "table ${sl_igwn} "` | |
if [ "$sl_igwnr x" = "0 x" ] |
if [ "$sl_igwnr x" = "0 x" ] | |
then |
then | |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn is already empty - no action taken" ; fi |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn is already empty - no action taken" ; fi | |
else |
else | |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will be flushed and rules rearranged" ; fi |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will be flushed and rules rearranged" ; fi | |
$sl_ipcmd ro fl ta $sl_igwn |
$sl_ipcmd ro fl ta $sl_igwn | |
#because this igw dissapeared we set a flag for rules recreation |
#because this igw dissapeared we set a flag for rules recreation | |
sl_diffigw=1 |
sl_diffigw=1 | |
fi |
fi | |
else |
else | |
echo "Igw $sl_igwn found in local config - leaving table as is" |
if [ $scm_info -gt 1 ]; then echo "Igw $sl_igwn found in local config - leaving table as is" ; fi | |
fi |
fi | |
else |
else | |
sl_tbl=`$sl_ipcmd ro ls ta $sl_igwn` |
sl_tbl=`$sl_ipcmd ro ls ta $sl_igwn` | |
#if the table is empty we fill it and we set flag for rules recreation |
#if the table is empty we fill it and we set flag for rules recreation | |
if [ "$sl_tbl x" = " x" ] |
if [ "$sl_tbl x" = " x" ] | |
Line 323... | Line 323... | |
then |
then | |
if [ $scm_info -gt 0 ]; then echo "We have less rules ($sl_numru) than new config has ips ($sl_numip)" ; fi |
if [ $scm_info -gt 0 ]; then echo "We have less rules ($sl_numru) than new config has ips ($sl_numip)" ; fi | |
# sl_diffcfg="1" |
# sl_diffcfg="1" | |
else |
else | |
if [ $scm_info -gt 0 ]; then echo "We have $sl_numru rules and $sl_numip ips" ; fi |
if [ $scm_info -gt 0 ]; then echo "We have $sl_numru rules and $sl_numip ips" ; fi | |
fi |
||
|
||
#zero rules means this is the firs time we run sedlo and it needs to force rules creation |
||
#checking if there are some rule and if not then we force rules recreation |
||
if [ $sl_numru -eq 0 ] |
||
then |
||
if [ $scm_info -gt 0 ]; then echo "We have zero rules ($sl_numru) - rules recreation will be forced" ; fi |
||
scm_force=1 |
||
fi |
fi | |
|
| |
} |
} | |
|
| |
###################################################################### |
###################################################################### | |
Line 462... | Line 454... | |
s_filltables |
s_filltables | |
#echo $sl_difftbl |
#echo $sl_difftbl | |
#echo $sl_diffcfg |
#echo $sl_diffcfg | |
#echo $sl_diffigw |
#echo $sl_diffigw | |
#echo $scm_force |
#echo $scm_force | |
|
#exit 0 | |
#flushing and filling rules is done only when |
#flushing and filling rules is done only when | |
#new table is created |
#new table is created | |
#config is changed |
#config is changed | |
#some igw dissapears or appears |
#some igw dissapears or appears | |
#-force command line parameter was used |
#-force command line parameter was used |