Make firewall convert scripts more robust.

The converter scripts procude a lot of error, when they get executed on a system with
a previously installed version of the New Firewall or they get run twice.

In this case the scripts will detect that their input files are missing and will exit with
an error message. The scripts now also check if the input files are empty (no corresponding
rules created) and will exit with an nothing to do message.
This commit is contained in:
Stefan Schantl
2014-01-18 18:11:09 +01:00
parent 0053269b90
commit 37c84696a2
4 changed files with 55 additions and 4 deletions

View File

@@ -36,6 +36,17 @@ my ($key,$flag,$prot,$ipfireport,$target,$targetport,$active,$alias,$source,$rem
my ($key1,$flag1,$prot1,$ipfireport1,$target1,$targetport1,$active1,$alias1,$source1,$remark1);
my $count=0;
my $jump;
if (! -e "$portfwconfig") {
print "Config file for portforward not found. Exiting!\n";
exit(1);
}
if (! -s "$portfwconfig") {
print "Empty portforward configuration file. Nothing to do. Exiting...\n";
exit(0);
}
if(! -d "/var/log/converters"){ mkdir("/var/log/converters");}
open(FILE, $portfwconfig) or die 'Unable to open config file.';
my @current = <FILE>;