+ system("/usr/local/bin/addonctrl guardian stop &>/dev/null");
+ }
+}
+
+sub GenerateIgnoreFile() {
+ my %ignored = ();
+
+ # Read-in ignoredfile.
+ &General::readhasharray($ignoredfile, \%ignored);
+
+ # Create the guardian.ignore file if not exist yet.
+ unless (-e "$ignorefile") { system("touch $ignorefile"); }
+
+ # Open ignorefile for writing.
+ open(FILE, ">$ignorefile");
+
+ # Config file header.
+ print FILE "# Autogenerated configuration file.\n";
+ print FILE "# All user modifications will be overwritten.\n\n";
+
+ # Add IFPire interfaces and gateway to the ignore file.
+ #
+ # Assign some temporary variables for the IPFire interfaces.
+ my $green = $netsettings{'GREEN_ADDRESS'};
+ my $blue = $netsettings{'BLUE_ADDRESS'};
+ my $orange = $netsettings{'ORANGE_ADDRESS'};
+
+ # File declarations.
+ my $public_address_file = "${General::swroot}/red/local-ipaddress";
+ my $gatewayfile = "${General::swroot}/red/remote-ipaddress";
+ my $dns1file = "${General::swroot}/red/dns1";
+ my $dns2file = "${General::swroot}/red/dns2";
+
+ # Write the obtained addresses to the ignore file.
+ print FILE "# IPFire local interfaces.\n";
+ print FILE "$green\n";
+
+ # Check if a blue interface exists.
+ if ($blue) {
+ # Add blue address.
+ print FILE "$blue\n";
+ }
+
+ # Check if an orange interface exists.
+ if ($orange) {
+ # Add orange address.
+ print FILE "$orange\n";
+ }
+
+ print FILE "\n# IPFire red interface, gateway and used DNS-servers.\n";
+ print FILE "# Include the corresponding files to obtain the addresses.\n";
+ print FILE "Include_File = $public_address_file\n";
+ print FILE "Include_File = $gatewayfile\n";
+ print FILE "Include_File = $dns1file\n";
+ print FILE "Include_File = $dns2file\n";
+
+ # Add all user defined hosts and networks to the ignore file.
+ #
+ # Check if the hash contains any elements.
+ if (keys (%ignored)) {
+ # Write headline.
+ print FILE "\n# User defined hosts/networks.\n";
+
+ # Loop through the entire hash and write the host/network
+ # and remark to the ignore file.
+ while ( (my $key) = each %ignored) {
+ my $address = $ignored{$key}[0];
+ my $remark = $ignored{$key}[1];
+ my $status = $ignored{$key}[2];
+
+ # Check if the status of the entry is "enabled".
+ if ($status eq "enabled") {
+ # Check if the address/network is valid.
+ if ((&General::validip($address)) || (&General::validipandmask($address))) {
+ # Write the remark to the file.
+ print FILE "# $remark\n";
+
+ # Write the address/network to the ignore file.
+ print FILE "$address\n\n";
+ }
+ }
+ }