jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [networks/] [setup.pl] - Rev 1

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: setup.pl,v 1.10 2004/07/12 07:50:14 bernisys Exp $

# include PERL libraries
use strict;
use warnings;
use diagnostics;

# include HotSaNIC libraries
use lib "../../lib";
use lib "./platform";
use HotSaNICparser;
use HotSaNICshellio;
use HotSaNIClog;
use common;

$|=1;

(my $VERSION = '$Revision: 1.10 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: setup.pl,v 1.10 2004/07/12 07:50:14 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;

my $MODNAME=HotSaNICparser::get_module_name();
my %MODCONF=HotSaNICmod::common::configure();
my $OUTFILE="settings.new";
if ( ! -e "settings" ) { $OUTFILE="settings"; }
open OUTFILE,">$OUTFILE" || die "could not open ".HotSaNICparser::get_module_name()." settings file for writing.\n";

if ( ($MODCONF{INTIF} eq "") or ($MODCONF{EXTIF} eq "") ) { ($MODCONF{INTIF},$MODCONF{EXTIF})=get_interfaces(); }
if (@{$MODCONF{DEVINT}}) { $MODCONF{DEVINT}="DEVINT=\"".join("\"\nDEVINT=\"",@{$MODCONF{DEVINT}})."\""; }
if (@{$MODCONF{DEVEXT}}) { $MODCONF{DEVEXT}="DEVEXT=\"".join("\"\nDEVEXT=\"",@{$MODCONF{DEVEXT}})."\""; }

print OUTFILE "# SHORT DESCRIPTION
#
# path to iptables or ipchains command
#
IPTABLES=\"$MODCONF{IPTABLES}\"

# Which kind of legend shall be used
# set  GRAPH_BASE=\"bytes\"  to display all values in bytes/s
# set  GRAPH_BASE=\"bits\"   to display all values in bits/s
#
# This item was previously named \"STYLE\"
#
GRAPH_BASE=\"$MODCONF{GRAPH_BASE}\"

# list of interfaces for internal / external hosts
#   INTIF=<interfaces connected to your local network (intranet)>
#   EXTIF=<interfaces connected to the internet>
#
INTIF=\"$MODCONF{INTIF}\"
EXTIF=\"$MODCONF{EXTIF}\"

# list hosts on INTERNAL devices here, multiple lines of the form:
#  DEVINT=\"<host>,<description>\"
#  DEVINT=\"!<host>,<description>\"
#  DEVINT=\"<network>/<netmask>,<description>\"
#  DEVINT=\"!<network>/<netmask>,<description>\"
#
$MODCONF{DEVINT}

# list hosts on EXTERNAL devices here, multiple lines of the form:
#  DEVEXT=\"<host>,<description>\"
#  DEVEXT=\"!<host>,<description>\"
#  DEVEXT=\"<network>/<netmask>,<description>\"
#  DEVEXT=\"!<network>/<netmask>,<description>\"
#
$MODCONF{DEVEXT}
";

close OUTFILE;

if ($OUTFILE eq "settings.new") {
  HotSaNICparser::backup_file("settings");
  rename "settings.new","settings";
  }

print "Please check the settings file and adapt it to satisfy your needs.\n";

sub get_interfaces {
  my $INT="";
  my $EXT="";
  print "Configuring local interfaces.
(i)nternal means an interface pointiong to your local machines (intranet)
(e)xternal means an interface connecten with the internet
(n)one means you don't want to account this interface.\n";
  open LIST,"ifconfig|";
  while (<LIST>) {
    if (/^[^\s]/) {
      my ($interface)=split;
      print "found $interface - (i)nternal, (e)xternal or (n)one?";
      my $input=lc HotSaNICshellio::readkey_list("ien","n");
      if ($input eq "i") {
        if ($INT ne "") { $INT=$INT.",$interface"; }
        else { $INT=$interface; }
        }
      elsif ($input eq "e") {
        if ($EXT ne "") { $EXT=$EXT.",$interface"; }
        else { $EXT=$interface; }
        }
      }
    }
  return ($INT,$EXT);
  }



Powered by WebSVN 2.2.1