jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [networks/] [setup] - Blame information for rev 6

 

Line No. Rev Author Line
11simandl#!/usr/bin/env sh
2 
3if ! [ -e settings ]; then OUTFILE="settings"; else OUTFILE="settings.new"; fi
4 
5#
6# configure path to "iptables"
7#
8COMMAND=`locate iptables|grep bin/iptables\$|head -n 1`
9if [ "$COMMAND" = "" ]; then COMMAND=`locate ipchains|grep bin/ipchains\$|head -n 1`; fi
10 
11cat > $OUTFILE <<EOF
12# path to iptables or ipchains command
13#
14EOF
15echo "IPTABLES=\"$COMMAND\"" >> $OUTFILE
16echo >> $OUTFILE
17 
18cat >> $OUTFILE << EOF
19 
20# Which kind of legend shall be used
21# set STYLE="bytes" to display all values in bytes/s
22# set STYLE="bits" to display all values in bits/s
23#
24EOF
25 
26var=`cat settings|grep "^STYLE="`
27if [ "$var" = "" ]; then var="STYLE=\"bytes\""; fi
28echo "$var" >> $OUTFILE
29 
30#
31# configure interfaces
32#
33 
34INTERFACES=`netstat -i|grep [0-9] |awk '{print $1}'`
35 
36if [ "$OUTFILE" = "settings.new" ]; then
37 INTIF=`cat settings | grep "^INTIF=" | sed -e "s/INTIF=//g ; s/\"//g"`
38 EXTIF=`cat settings | grep "^EXTIF=" | sed -e "s/EXTIF=//g ; s/\"//g"`
39else
40 INTIF=""
41 EXTIF=""
42 fi
43 
44if [ "$INTIF" = "" ] || [ "$EXTIF" = "" ]; then
45 echo
46 echo "Configuring local interfaces.
47(i)nternal means an interface pointiong to your local machines (intranet)
48(e)xternal means an interface connecten with the internet
49(n)one means you don't want to account this interface.
50 
51Please answer these:"
52 for nn in $INTERFACES; do
53 where="x"
54 while [ "$where" != "i" ] && [ "$where" != "e" ] && [ "$where" != "n" ]; do
55 echo -n "found: $nn - (i)nternal, (e)xternal or (n)one ? "
56 read where
57 case $where in
58 n) ;;
59 i) INTIF="$INTIF,$nn" ;;
60 e) EXTIF="$EXTIF,$nn" ;;
61 *) echo "please answer with \"i\" \"e\" or \"n\"" ;;
62 esac
63 echo
64 done
65 done
66 fi
67 
68cat >> $OUTFILE << EOF
69 
70# list of interfaces for internal / external hosts
71# INTIF=<interfaces connected to your local network (intranet)>
72# EXTIF=<interfaces connected to the internet>
73#
74EOF
75 
76echo "INTIF=\"$INTIF\"" |sed -e "s/=\",/=\"/g" >> $OUTFILE
77echo "EXTIF=\"$EXTIF\"" |sed -e "s/=\",/=\"/g" >> $OUTFILE
78echo >> $OUTFILE
79 
80#
81# write template for the rest
82#
83echo "# list hosts on internal devices here, multiple lines of the form:" >> $OUTFILE
84echo "# DEVINT=\"<host>,<description>\"" >> $OUTFILE
85echo "# DEVINT=\"!<host>,<description>\"" >> $OUTFILE
86echo "#" >> $OUTFILE
87if [ "$OUTFILE" = "settings.new" ]; then
88 cat settings|grep "^DEVINT=" >> $OUTFILE
89 fi
90echo >> $OUTFILE
91 
92echo "# list hosts on external devices here, multiple lines of the form:" >> $OUTFILE
93echo "# DEVEXT=\"<host>,<description>\"" >> $OUTFILE
94echo "# DEVEXT=\"!<host>,<description>\"" >> $OUTFILE
95echo "#" >> $OUTFILE
96if [ "$OUTFILE" = "settings.new" ]; then
97 cat settings|grep "^DEVEXT=" >> $OUTFILE
98 fi
99 
100echo
101echo "Please check the settings file and adapt it to satisfy your needs."
102echo "maybe you have to configure some destination networks."
103if [ "$OUTFILE" = "settings.new" ]; then
104 mkdir -p backup
105 NOW=`date +%Y%m%d-%H%M%S`
106 mv -f settings backup/settings-$NOW
107 mv -f settings.new settings
108 echo "a backup of the previous settings has been saved."
109 fi
110echo
111 

Powered by WebSVN 2.2.1