3
# Shorewall Packet Filtering Firewall RPM configuration program - V4.5
5
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
7
# (c) 2012 - Tom Eastep (teastep@shorewall.net)
9
# Shorewall documentation is available at http://www.shorewall.net
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.
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.
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.
24
# Usage: ./configure.pl <option>=<setting> ...
27
################################################################################################
40
my %aliases = ( VENDOR => 'HOST',
41
SHAREDSTATEDIR => 'VARDIR',
42
DATADIR => 'SHAREDIR',
43
SYSCONFDIR => 'CONFDIR' );
46
die "ERROR: Invalid option specification ( $_ )" unless /^(?:--)?(\w+)=(.*)$/;
51
$pn = $aliases{$pn} if exists $aliases{$pn};
56
my $vendor = $params{HOST};
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;
64
if ( -f '/etc/debian_version' ) {
66
$rcfilename = 'shorewallrc.debian';
67
} elsif ( -f '/etc/redhat-release' ){
69
$rcfilename = 'shorewallrc.redhat';
70
} elsif ( -f '/etc/slackware-version' ) {
71
$vendor = 'slackware';
72
$rcfilename = 'shorewallrc.slackware';
73
} elsif ( -f '/etc/SuSE-release' ) {
75
$rcfilename = 'shorewallrc.suse';
76
} elsif ( -f '/etc/arch-release' ) {
77
$vendor = 'archlinux';
78
$rcfilename = 'shorewallrc.archlinux';
79
} elsif ( `uname` =~ '^Darwin' ) {
81
$rcfilename = 'shorewallrc.apple';
82
} elsif ( `uname` =~ '^Cygwin' ) {
84
$rcfilename = 'shorewallrc.cygwin';
87
$rcfilename = 'shorewallrc.default';
90
$params{HOST} = $vendor;
93
my @localtime = localtime;
94
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
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];;
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];;
102
open $rcfile, '<', $rcfilename or die "Unable to open $rcfilename for input: $!";
104
while ( <$rcfile> ) {
108
die "ERROR: Invalid entry ($_) in $rcfilename, line $." unless /\s*(\w+)=(.*)/;
115
while ( my ( $p, $v ) = each %params ) {
121
open $outfile, '>', 'shorewallrc' or die "Can't open 'shorewallrc' for output: $!";
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];
125
print $outfile "# Input: @ARGV\n#\n" if @ARGV;
146
my $val = $options{$_} || '';
149
print $outfile "$_=$val\n";