~ubuntu-branches/ubuntu/saucy/shorewall/saucy-proposed

« back to all changes in this revision

Viewing changes to configure.pl

  • Committer: Package Import Robot
  • Author(s): Roberto C. Sanchez
  • Date: 2012-04-14 21:57:42 UTC
  • mfrom: (1.3.46)
  • Revision ID: package-import@ubuntu.com-20120414215742-0ejkotwovqesavu7
Tags: 4.5.2.2-1
* New Upstream Version
* Convert to debhelper compatibility level 8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/perl -w
 
2
#
 
3
#     Shorewall Packet Filtering Firewall RPM configuration program - V4.5
 
4
#
 
5
#     This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
 
6
#
 
7
#     (c) 2012 - Tom Eastep (teastep@shorewall.net)
 
8
#
 
9
#       Shorewall documentation is available at http://www.shorewall.net
 
10
#
 
11
#       This program is free software; you can redistribute it and/or modify
 
12
#       it under the terms of Version 2 of the GNU General Public License
 
13
#       as published by the Free Software Foundation.
 
14
#
 
15
#       This program is distributed in the hope that it will be useful,
 
16
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
18
#       GNU General Public License for more details.
 
19
#
 
20
#       You should have received a copy of the GNU General Public License
 
21
#       along with this program; if not, write to the Free Software
 
22
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
23
#
 
24
#       Usage: ./configure.pl <option>=<setting> ...
 
25
#
 
26
#
 
27
################################################################################################
 
28
use strict;
 
29
 
 
30
#
 
31
# Build updates this
 
32
#
 
33
use constant { 
 
34
    VERSION => '4.5.2.1'
 
35
};
 
36
 
 
37
my %params;
 
38
my %options;
 
39
 
 
40
my %aliases = ( VENDOR         => 'HOST',
 
41
                SHAREDSTATEDIR => 'VARDIR',
 
42
                DATADIR        => 'SHAREDIR',
 
43
                SYSCONFDIR     => 'CONFDIR' );
 
44
 
 
45
for ( @ARGV ) {
 
46
    die "ERROR: Invalid option specification ( $_ )" unless /^(?:--)?(\w+)=(.*)$/;
 
47
 
 
48
    my $pn = uc $1;
 
49
    my $pv = $2 || '';
 
50
 
 
51
    $pn = $aliases{$pn} if exists $aliases{$pn};
 
52
 
 
53
    $params{$pn} = $pv;
 
54
}
 
55
 
 
56
my $vendor = $params{HOST};
 
57
my $rcfile;
 
58
my $rcfilename;
 
59
 
 
60
if ( defined $vendor ) {
 
61
    $rcfilename = $vendor eq 'linux' ? 'shorewallrc.default' : 'shorewallrc.' . $vendor;
 
62
    die qq("ERROR: $vendor" is not a recognized host type) unless -f $rcfilename;
 
63
} else {
 
64
    if ( -f '/etc/debian_version' ) {
 
65
        $vendor = 'debian';
 
66
        $rcfilename = 'shorewallrc.debian';
 
67
    } elsif ( -f '/etc/redhat-release' ){
 
68
        $vendor = 'redhat';
 
69
        $rcfilename = 'shorewallrc.redhat';
 
70
    } elsif ( -f '/etc/slackware-version' ) {
 
71
        $vendor = 'slackware';
 
72
        $rcfilename = 'shorewallrc.slackware';
 
73
    } elsif ( -f '/etc/SuSE-release' ) {
 
74
        $vendor = 'suse';
 
75
        $rcfilename = 'shorewallrc.suse';
 
76
    } elsif ( -f '/etc/arch-release' ) {
 
77
        $vendor = 'archlinux';
 
78
        $rcfilename = 'shorewallrc.archlinux';
 
79
    } elsif ( `uname` =~ '^Darwin' ) {
 
80
        $vendor = 'apple';
 
81
        $rcfilename = 'shorewallrc.apple';
 
82
    } elsif ( `uname` =~ '^Cygwin' ) {
 
83
        $vendor = 'cygwin';
 
84
        $rcfilename = 'shorewallrc.cygwin';
 
85
    } else {
 
86
        $vendor = 'linux';
 
87
        $rcfilename = 'shorewallrc.default';
 
88
    }
 
89
 
 
90
    $params{HOST} = $vendor;
 
91
}
 
92
 
 
93
my @localtime = localtime;
 
94
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
 
95
 
 
96
if ( $vendor eq 'linux' ) {
 
97
    printf "INFO: Creating a generic Linux installation - %s %2d %04d %02d:%02d:%02d\n\n", $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];;
 
98
} else {
 
99
    printf "INFO: Creating a %s-specific installation - %s %2d %04d %02d:%02d:%02d\n\n", $vendor, $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];;
 
100
}
 
101
 
 
102
open $rcfile, '<', $rcfilename or die "Unable to open $rcfilename for input: $!";
 
103
 
 
104
while ( <$rcfile> ) {
 
105
    s/\s*#.*//;
 
106
    unless ( /^\s*$/ ) {
 
107
        chomp;
 
108
        die "ERROR: Invalid entry ($_) in $rcfilename, line $." unless /\s*(\w+)=(.*)/;
 
109
        $options{$1} = $2;
 
110
    }
 
111
}
 
112
 
 
113
close $rcfile;
 
114
 
 
115
while ( my ( $p, $v ) = each %params ) {
 
116
    $options{$p} = ${v};
 
117
}
 
118
 
 
119
my $outfile;
 
120
 
 
121
open $outfile, '>', 'shorewallrc' or die "Can't open 'shorewallrc' for output: $!";
 
122
 
 
123
printf $outfile "#\n# Created by Shorewall Core version %s configure.pl - %s %2d %04d %02d:%02d:%02d\n#\n", VERSION, $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];
 
124
 
 
125
print  $outfile "# Input: @ARGV\n#\n" if @ARGV;
 
126
 
 
127
for ( qw/ HOST
 
128
          PREFIX
 
129
          SHAREDIR
 
130
          LIBEXECDIR
 
131
          PERLLIBDIR
 
132
          CONFDIR
 
133
          SBINDIR
 
134
          MANDIR 
 
135
          INITDIR
 
136
          INITSOURCE
 
137
          INITFILE
 
138
          AUXINITSOURCE
 
139
          AUXINITFILE
 
140
          SYSTEMD
 
141
          SYSCONFFILE
 
142
          SYSCONFDIR
 
143
          ANNOTATED
 
144
          VARDIR / ) {
 
145
 
 
146
    my $val = $options{$_} || '';
 
147
 
 
148
    print          "$_=$val\n";
 
149
    print $outfile "$_=$val\n";
 
150
}
 
151
 
 
152
close $outfile;
 
153
 
 
154
1;