# $Id: autoupdate.pl,v 1.1 2007/03/14 00:00:00 marco.s Exp $
#
use strict;
+use File::Path;
require "/var/ipfire/general-functions.pl";
system("/usr/bin/squidGuard -d -c $target/update.conf -C all");
+ &cleanupdbdir();
system("cp -r $target/blacklists/* $dbdir");
system("chown -R nobody.nobody $dbdir");
}
# -------------------------------------------------------------------
+
+sub cleanupdbdir {
+ # Open the database directory and do a directory listing.
+ opendir(DIR, "$dbdir") or die "Cannot open $dbdir. $!\n";
+
+ # Loop through the directory.
+ while (my $item = readdir(DIR)) {
+ # Skip . and ..
+ next if ($item eq ".");
+ next if ($item eq "..");
+
+ # Generate absolute path.
+ my $abs_path = "$dbdir/$item";
+
+ # Skip anything which is not a directory.
+ next unless (-d "$abs_path");
+
+ # Remove the directory and the content.
+ &File::Path::remove_tree($abs_path);
+ }
+
+ # Close directory handle.
+ closedir(DIR);
+}