sedlo |
Subversion Repositories: |
Rev 11 | Rev 12 | |
---|---|---|
Line 3... | Line 3... | |
# release date : 06/08/2006 |
# release date : 06/08/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.4pre2" |
sl_version="0.0.4pre3" | |
|
| |
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 170... | Line 170... | |
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 $sl_igwn` | |
if [ "$sl_igwnr x" = "0 x" ] |
if [ "$sl_igwnr x" = "0 x" ] | |
then |
then | |
if [ $scm_info -gt 1 ]; then echo "Igw $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 "Igw $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" |
echo "Igw $sl_igwn found in local config - leaving table as is" | |
fi |
fi | |
|
||
else |
else | |
sl_tbl=`$sl_ipcmd ro ls ta $sl_igwn` |
sl_tbl=`$sl_ipcmd ro ls ta $sl_igwn` | |
if [ "$sl_tbl x" != " x" ] |
#if the table is empty we fill it and we set flag for rules recreation | |
if [ "$sl_tbl x" = " x" ] | ||
then |
then | |
$sl_ipcmd ro fl ta $sl_igwn |
sl_diffigw=1 | |
fi |
$sl_ipcmd ro add 0.0.0.0/1 via $sl_igwgt ta $sl_igwn | |
$sl_ipcmd ro add 0.0.0.0/1 via $sl_igwgt ta $sl_igwn |
$sl_ipcmd ro add 128.0.0.0/1 via $sl_igwgt ta $sl_igwn | |
$sl_ipcmd ro add 128.0.0.0/1 via $sl_igwgt ta $sl_igwn |
if [ "$sl_igwtype x" = "myigw x" ] | |
if [ "$sl_igwtype x" = "myigw x" ] |
then | |
then |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn filled with default myigw $sl_igwgt" ; fi | |
if [ $scm_info -gt 1 ]; then echo "Table filled for myigw $sl_igwn" ; fi |
else | |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn filled with default gw $sl_igwgt" ; fi | ||
fi | ||
#the table is not empty so we check if routes are the same | ||
else |
else | |
if [ $scm_info -gt 1 ]; then echo "Table filled for igw $sl_igwn" ; fi |
#picking default gateway from the table | |
sl_igwogt=`$sl_ipcmd ro ls ta $sl_igwn | $sl_awkcmd '{print $3}' | uniq` | ||
#checking if the old default is same as the new one | ||
if [ "$sl_igwogt x" = "$sl_igwgt x" ] | ||
then | ||
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will not be changed and default is $sl_igwgt" ; fi | ||
else | ||
#the new default is different so we will flush the table, fill new default | ||
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will be rewritten to default $sl_igwgt" ; fi | ||
#flushing old default route in the table | ||
$sl_ipcmd ro fl ta $sl_igwn | ||
#filling new default | ||
$sl_ipcmd ro add 0.0.0.0/1 via $sl_igwgt ta $sl_igwn | ||
$sl_ipcmd ro add 128.0.0.0/1 via $sl_igwgt ta $sl_igwn | ||
fi | ||
fi |
fi | |
fi |
fi | |
done |
done | |
|
| |
} # s_filltables |
} # s_filltables | |
Line 306... | 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 | |
|
| |
} |
} | |
|
| |
###################################################################### |
###################################################################### |