jablonka.czprosek.czf

sedlo

Subversion Repositories:
[/] [trunk/] [sedlo] - Blame information for rev 2

 

Line No. Rev Author Line
12simandl#!/bin/bash
2# author : Petr Simandl www.simandl.cz
3# release date : 19/08/2004
4# name : sedlo
5# description : dynamic side routing tables tool
6# license : GPL
7 
8sl_version="0.0.1"
9 
10PATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin
11 
12sl_nmcnf="sedlo.conf"
13sl_sedlocnf="/etc/$sl_nmcnf"
14sl_sedlocache="/var/cache/sedlo"
15 
16sl_rttab="/etc/iproute2/rt_tables"
17sl_rtnmin=110
18sl_rtnmax=125
19 
20sl_ipcmd=`which wget`
21sl_hnmcmd=`which hostname`
22sl_awkcmd=`which awk`
23 
24 
25sl_time=`date '+%Y%m%d%H%M%S'`
26 
27if [ -e $sl_sedlocnf ]
28 then
29 sl_nop=1
30 else
31 echo "$sl_sedlocnf not found"
32 exit 1
33fi
34 
35if [ -e $sl_rttab ]
36 then
37 sl_nop=1
38 else
39 echo "$sl_rttab not found"
40 exit 1
41fi
42 
43sl_murlcfg=`cat $sl_sedlocnf | grep mcnf | uniq | awk '{print $2}'`
44 
45######################################################################
46s_mktables()
47{
48echo s_mktables
49 
50sl_igws=`cat $sl_sedlocache/$sl_nmcnf | grep "^igw" | awk '{print $3}'`
51 
52for sl_igw in $sl_igws
53 do
54 sl_igwrttb=`cat $sl_rttab | awk '{print $2}' | grep $sl_igw `
55 if [ "$sl_igwrttb x" = " x" ]
56 then
57 echo "Table for $sl_igw not found - creating"
58 sl_cnt="$sl_rtnmax"
59 sl_ok="no"
60 until [ "$sl_cnt" -eq "$sl_rtnmin" ] || [ "$sl_ok" = "yes" ]
61 do
62 #space is used to recognized two and three digit numbers
63 sl_igwrttb=`cat $sl_rttab | awk '{print $1" "}' | grep "$sl_cnt " `
64 if [ "$sl_igwrttb x" = " x" ]
65 then
66 sl_ok="yes"
67 echo "$sl_cnt $sl_igw" >> $sl_rttab
68 fi
69 sl_cnt=$(($sl_cnt - 1 ))
70 done
71 
72 else
73 echo "Table for $sl_igw found"
74 fi
75 
76 done
77}
78######################################################################
79s_getcfg()
80{
81echo s_getcfg
82wget $sl_murlcfg -O "$sl_sedlocache/$sl_nmcnf.main" -q
83echo "# generated file" > $sl_sedlocache/$sl_nmcnf
84for sl_file in `ls $sl_sedlocnf $sl_sedlocache/$sl_nmcnf.main `
85do
86cat $sl_file | grep "^mcnf" | awk '{print $1"\t"$2}' >> $sl_sedlocache/$sl_nmcnf
87cat $sl_file | grep "^igw" | awk '{print $1"\t"$2"\t"$3}' >> $sl_sedlocache/$sl_nmcnf
88cat $sl_file | grep "^ip" | awk '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6}' >> $sl_sedlocache/$sl_nmcnf
89done
90cat $sl_sedlocache/$sl_nmcnf | sort | uniq > $sl_sedlocache/$sl_nmcnf.uniq
91mv $sl_sedlocache/$sl_nmcnf.uniq $sl_sedlocache/$sl_nmcnf
92 
93}
94######################################################################
95s_version()
96{
97 echo sedlo $sl_version
98 exit 0
99}
100######################################################################
101s_help()
102{
103 echo Pouziti: sedlo [param]
104 echo param:
105 echo -v vypise verzi
106 exit 0
107}
108######################################################################
109######################################################################
110 
111s_getcfg
112 
113s_mktables
114exit 0

Powered by WebSVN 2.2.1