jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [networks/] [setup.pl] - Blame information for rev 11

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: setup.pl,v 1.10 2004/07/12 07:50:14 bernisys Exp $
4 
5# include PERL libraries
6use strict;
7use warnings;
8use diagnostics;
9 
10# include HotSaNIC libraries
11use lib "../../lib";
12use lib "./platform";
13use HotSaNICparser;
14use HotSaNICshellio;
15use HotSaNIClog;
16use common;
17 
18$|=1;
19 
20(my $VERSION = '$Revision: 1.10 $') =~ s/.*(\d+\.\d+).*/$1/;
21(my $IDENTIFIER = '$Id: setup.pl,v 1.10 2004/07/12 07:50:14 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;
22 
23my $MODNAME=HotSaNICparser::get_module_name();
24my %MODCONF=HotSaNICmod::common::configure();
25my $OUTFILE="settings.new";
26if ( ! -e "settings" ) { $OUTFILE="settings"; }
27open OUTFILE,">$OUTFILE" || die "could not open ".HotSaNICparser::get_module_name()." settings file for writing.\n";
28 
29if ( ($MODCONF{INTIF} eq "") or ($MODCONF{EXTIF} eq "") ) { ($MODCONF{INTIF},$MODCONF{EXTIF})=get_interfaces(); }
30if (@{$MODCONF{DEVINT}}) { $MODCONF{DEVINT}="DEVINT=\"".join("\"\nDEVINT=\"",@{$MODCONF{DEVINT}})."\""; }
31if (@{$MODCONF{DEVEXT}}) { $MODCONF{DEVEXT}="DEVEXT=\"".join("\"\nDEVEXT=\"",@{$MODCONF{DEVEXT}})."\""; }
32 
33print OUTFILE "# SHORT DESCRIPTION
34#
35# path to iptables or ipchains command
36#
37IPTABLES=\"$MODCONF{IPTABLES}\"
38 
39# Which kind of legend shall be used
40# set GRAPH_BASE=\"bytes\" to display all values in bytes/s
41# set GRAPH_BASE=\"bits\" to display all values in bits/s
42#
43# This item was previously named \"STYLE\"
44#
45GRAPH_BASE=\"$MODCONF{GRAPH_BASE}\"
46 
47# list of interfaces for internal / external hosts
48# INTIF=<interfaces connected to your local network (intranet)>
49# EXTIF=<interfaces connected to the internet>
50#
51INTIF=\"$MODCONF{INTIF}\"
52EXTIF=\"$MODCONF{EXTIF}\"
53 
54# list hosts on INTERNAL devices here, multiple lines of the form:
55# DEVINT=\"<host>,<description>\"
56# DEVINT=\"!<host>,<description>\"
57# DEVINT=\"<network>/<netmask>,<description>\"
58# DEVINT=\"!<network>/<netmask>,<description>\"
59#
60$MODCONF{DEVINT}
61 
62# list hosts on EXTERNAL devices here, multiple lines of the form:
63# DEVEXT=\"<host>,<description>\"
64# DEVEXT=\"!<host>,<description>\"
65# DEVEXT=\"<network>/<netmask>,<description>\"
66# DEVEXT=\"!<network>/<netmask>,<description>\"
67#
68$MODCONF{DEVEXT}
69";
70 
71close OUTFILE;
72 
73if ($OUTFILE eq "settings.new") {
74 HotSaNICparser::backup_file("settings");
75 rename "settings.new","settings";
76 }
77 
78print "Please check the settings file and adapt it to satisfy your needs.\n";
79 
80sub get_interfaces {
81 my $INT="";
82 my $EXT="";
83 print "Configuring local interfaces.
84(i)nternal means an interface pointiong to your local machines (intranet)
85(e)xternal means an interface connecten with the internet
86(n)one means you don't want to account this interface.\n";
87 open LIST,"ifconfig|";
88 while (<LIST>) {
89 if (/^[^\s]/) {
90 my ($interface)=split;
91 print "found $interface - (i)nternal, (e)xternal or (n)one?";
92 my $input=lc HotSaNICshellio::readkey_list("ien","n");
93 if ($input eq "i") {
94 if ($INT ne "") { $INT=$INT.",$interface"; }
95 else { $INT=$interface; }
96 }
97 elsif ($input eq "e") {
98 if ($EXT ne "") { $EXT=$EXT.",$interface"; }
99 else { $EXT=$interface; }
100 }
101 }
102 }
103 return ($INT,$EXT);
104 }
105 
106 

Powered by WebSVN 2.2.1