#srv/web/ipfire/html/images/stock_up-16.png
#srv/web/ipfire/html/images/table-header.gif
#srv/web/ipfire/html/images/up.gif
-#srv/web/ipfire/html/images/updxl-gr.gif
-#srv/web/ipfire/html/images/updxl-led-blue.gif
-#srv/web/ipfire/html/images/updxl-led-green.gif
-#srv/web/ipfire/html/images/updxl-led-red.gif
-#srv/web/ipfire/html/images/updxl-led-yellow.gif
-#srv/web/ipfire/html/images/updxl-rd.gif
-#srv/web/ipfire/html/images/updxl-src-adobe.gif
-#srv/web/ipfire/html/images/updxl-src-symantec.gif
-#srv/web/ipfire/html/images/updxl-src-unknown.gif
-#srv/web/ipfire/html/images/updxl-src-windows.gif
-#srv/web/ipfire/html/images/updxl-yl.gif
+#srv/web/ipfire/html/images/updbooster
+#srv/web/ipfire/html/images/updbooster/updxl-globe.gif
+#srv/web/ipfire/html/images/updbooster/updxl-led-gray.gif
+#srv/web/ipfire/html/images/updbooster/updxl-led-yellow.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-apple.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-avira.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-trendmicro.gif
+#srv/web/ipfire/html/images/updbooster/updxl-yl.gif
+#srv/web/ipfire/html/images/updbooster/updxl-gr.gif
+#srv/web/ipfire/html/images/updbooster/updxl-led-green.gif
+#srv/web/ipfire/html/images/updbooster/updxl-rd.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-avast.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-linux.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-unknown.gif
+#srv/web/ipfire/html/images/updbooster/updxl-led-blue.gif
+#srv/web/ipfire/html/images/updbooster/updxl-led-red.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-adobe.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-avg.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-symantec.gif
+#srv/web/ipfire/html/images/updbooster/updxl-src-windows.gif
#srv/web/ipfire/html/images/urlfilter
#srv/web/ipfire/html/images/urlfilter/1x1.gif
#srv/web/ipfire/html/images/urlfilter/bg_cool_tux.jpg
etc/squid
etc/init.d/connectd
-usr/lib/squid
+usr/lib/squid/
usr/sbin/squid
-srv/web/ipfire/cgi-bin/updatexlrator.cgi
bin/ntfs-3g
lib/libntfs-3g.so
lib/libntfs-3g.so.36
lib/libntfs-3g.so.36.0.0
+srv/web/ipfire/html/images/updbooster
+srv/web/ipfire/cgi-bin/updatexlrator.cgi
+var/ipfire/updatexlrator/bin/
+usr/sbin/updxlrator
#
# This code is distributed under the terms of the GPL
#
-# (c) 2006 marco.s
+# (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
#
-# $Id: checkup,v 1.0 2006/08/30 00:00:00 marco.s Exp $
+# $Id: checkup,v 2.0 2007/06/17 00:00:00 marco.s Exp $
#
use strict;
-use IO::Socket;
use HTTP::Date;
my $swroot='/var/ipfire';
-my $scriptpath=substr($0,0,rindex($0,"/"));
my $apphome="/var/ipfire/updatexlrator";
my $logfile="/var/log/updatexlrator/checkup.log";
-my $debug=(-e "$apphome/debug");
-my $repository='/srv/web/ipfire/html/updatecache';
+my $repository='/var/updatecache';
+my $useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+my %proxysettings=();
my %xlratorsettings=();
my $download=0;
my $updatefile='';
my $sourceurl='';
-my $remote_size=0;
-my $local_size=0;
-my $remote_mtime=0;
-my $local_mtime=0;
+my @sources=();
my @updatelist=();
-my @metadata=();
-
-@updatelist = <$repository/*>;
+my $logging=0;
my $sfUnknown = "0";
my $sfOk = "1";
my $sfOutdated = "2";
+my $sfNoSource = "3";
if (-e "$swroot/updatexlrator/settings")
{
&readhash("$swroot/updatexlrator/settings", \%xlratorsettings);
if ($xlratorsettings{'FULL_AUTOSYNC'} eq 'on') { $download=1; };
+ if ($xlratorsettings{'ENABLE_LOG'} eq 'on') { $logging=1; };
}
-foreach (@updatelist)
-{
- if (!-d $_)
- {
- $updatefile = substr($_,rindex($_,"/")+1);
- if (-e "$repository/metadata/$updatefile")
- {
- open (FILE,"$repository/metadata/$updatefile");
- @metadata = <FILE>;
- close FILE;
- chomp(@metadata);
- $sourceurl = $metadata[0];
+if (-e "$swroot/proxy/settings") { &readhash("$swroot/proxy/settings", \%proxysettings); }
- $remote_size = &getdownloadsize($sourceurl);
- $local_size = (-s "$repository/$updatefile");
+if (-e "$swroot/proxy/advanced/settings")
+{
+ %proxysettings=();
+ &readhash("$swroot/proxy/advanced/settings", \%proxysettings);
+}
- $remote_mtime = &getlastmod($sourceurl);
- $local_mtime = &getmtime("$repository/$updatefile");
+foreach (<$repository/*>)
+{
+ if (-d $_)
+ {
+ unless (/^$repository\/download$/) { push(@sources,$_); }
+ }
+}
- if ($remote_mtime eq 0)
- {
- $metadata[2] = $sfUnknown;
- if ($debug) { &writelog("$updatefile - WARNING: Source not found"); }
- print "$updatefile - WARNING: Source not found\n";
- }
- elsif (($local_mtime eq $remote_mtime) && ($local_size == $remote_size))
- {
- $metadata[2] = $sfOk;
- $metadata[3] = time;
- if ($debug) { &writelog("$updatefile"); }
- print "$updatefile\n";
- }
- else
- {
- $metadata[2] = $sfOutdated;
- $metadata[3] = time;
- if ($debug) { &writelog("$updatefile - WARNING: Out of date"); }
- print "$updatefile - WARNING: Out of date\n";
- if ($download)
- {
- if ($debug)
- {
- 1 while $remote_size =~ s/^(-?\d+)(\d{3})/$1.$2/;
- print "Please wait, retrieving file ($remote_size Byte) from source ...";
- `$scriptpath/../bin/wget -nd -nv -O $repository/$updatefile $sourceurl >>$logfile 2>&1`;
- print "\n";
- } else
- {
- `$scriptpath/../bin/wget -nd -nv -O $repository/$updatefile $sourceurl 2>&1`;
- }
- $local_mtime = &getmtime("$repository/$updatefile");
- if ($local_mtime eq $remote_mtime) { $metadata[2] = $sfOk; }
- }
- }
- open (FILE,">$repository/metadata/$updatefile");
- foreach (@metadata) { print FILE "$_\n"; }
+foreach (@sources)
+{
+ @updatelist=<$_/*>;
+ foreach(@updatelist)
+ {
+ if (-e "$_/source.url")
+ {
+ open (FILE,"$_/source.url");
+ $sourceurl=<FILE>;
close FILE;
+ chomp($sourceurl);
+ $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
+ &checksource($_);
}
}
}
# -------------------------------------------------------------------
-sub getlastmod
+sub writelog
{
- my $remote=0;
- my @response=();
- my $lastmoddate=0;
-
- my $url = $_[0];
-
- $url =~ s@^(.*)://([^/]*)@@;
-
- my $proto = $1;
- my $fqhn = $2;
-
- if ((-e "$swroot/red/active") && ($proto eq 'http'))
- {
- $remote = IO::Socket::INET->new(
- PeerHost => $fqhn,
- PeerPort => 'http(80)',
- Timeout => 1
- );
- }
-
- if ($remote)
+ print "$_[0]\n";
+ if ($logging)
{
- print $remote "HEAD $url HTTP/1.0\n";
- print $remote "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\n";
- print $remote "Host: $fqhn\n";
- print $remote "Accept: */*\n\n";
- while (<$remote>) { push(@response,$_); }
- close $remote;
- if ($response[0] =~ /^HTTP\/\d+\.\d+\s\d+\sOK\s*$/)
- {
- foreach (@response)
- {
- if (/^Last-Modified: /i)
- {
- s/^Last-Modified: //i;
- $lastmoddate=HTTP::Date::str2time($_);
- }
- }
- }
+ open (LOGFILE,">>$logfile");
+ my @now = localtime(time);
+ printf LOGFILE "%04d-%02d-%02d %02d:%02d:%02d %s\n",$now[5]+1900,$now[4]+1,$now[3],$now[2],$now[1],$now[0],$_[0];
+ close LOGFILE;
}
- return $lastmoddate;
}
# -------------------------------------------------------------------
-sub getdownloadsize
+sub setcachestatus
{
- my $remote=0;
- my @response=();
- my $contentlength=0;
+ open (FILE,">$_[0]");
+ print FILE "$_[1]\n";
+ close FILE;
+}
- my $url = $_[0];
+# -------------------------------------------------------------------
- $url =~ s@^(.*)://([^/]*)@@;
+sub checksource
+{
+ my @http_header=();
+ my $http_result='000 n/a';
+ my $returncode=0;
+ my $localfile='';
+ my $remote_size=0;
+ my $remote_mtime=0;
+ my $login='';
+ my $url='';
+ my $cdir=$_[0];
+
+ open (FILE,"$cdir/source.url");
+ $url=<FILE>;
+ close FILE;
+ chomp($url);
+
+ $localfile = $cdir . substr($url,rindex($url,'/'),length($url));
+
+ if (($proxysettings{'UPSTREAM_PROXY'}) && ($proxysettings{'UPSTREAM_USER'}))
+ {
+ $login = "--proxy-user=\"$proxysettings{'UPSTREAM_USER'}\"";
+ if ($proxysettings{'UPSTREAM_PASSWORD'})
+ {
+ $login .= " --proxy-password=\"$proxysettings{'UPSTREAM_PASSWORD'}\"";
+ }
+ }
- my $proto = $1;
- my $fqhn = $2;
+ $ENV{'http_proxy'} = $proxysettings{'UPSTREAM_PROXY'};
+ @http_header = `wget $login --user-agent="$useragent" --spider -S $url 2>&1`;
+ $ENV{'http_proxy'} = '';
+ &writelog(@http_header);
- if ((-e "$swroot/red/active") && ($proto eq 'http'))
+ foreach (@http_header)
{
- $remote = IO::Socket::INET->new(
- PeerHost => $fqhn,
- PeerPort => 'http(80)',
- Timeout => 1
- );
+ chomp;
+ if (/^\s*HTTP\/\d+\.\d+\s\d+\s+\w+/) { $http_result = $_; $http_result =~ s/^\s*HTTP\/\d+\.\d+\s+//; }
+ if (/^\s*Content-Length:\s/) { $remote_size = $_; $remote_size =~ s/[^0-9]//g; }
+ if (/^\s*Last-Modified:\s/) { $remote_mtime = $_; $remote_mtime =~ s/^\s*Last-Modified:\s//; $remote_mtime = HTTP::Date::str2time($remote_mtime) }
}
- if ($remote)
+ &writelog($localfile);
+ &writelog("HTTP result: $http_result");
+ &writelog("Source size: $remote_size");
+ &writelog("Cached size: " . (-s $localfile));
+ &writelog("Source time: $remote_mtime");
+ &writelog("Cached time: " . getmtime($localfile));
+
+ if ($http_result =~ /\d+\s+OK$/)
{
- print $remote "HEAD $url HTTP/1.0\n";
- print $remote "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\n";
- print $remote "Host: $fqhn\n";
- print $remote "Accept: */*\n\n";
- while (<$remote>) { push(@response,$_); }
- close $remote;
- if ($response[0] =~ /^HTTP\/\d+\.\d+\s\d+\sOK\s*$/)
+ if (($remote_size == -s $localfile) && ($remote_mtime == getmtime($localfile)))
{
- foreach (@response)
+ &writelog("Status: Ok");
+ &setcachestatus("$cdir/status",$sfOk);
+ } else {
+ &writelog("Status: Outdated");
+ &setcachestatus("$cdir/status",$sfOutdated);
+ if ($download)
{
- if (/^Content-Length: /i)
- {
- s/^Content-Length: //i;
- $contentlength=int($_);
- }
+ &writelog("Retrieving file from source: $remote_size bytes");
+ $_ = system("wget $login --user-agent=\"$useragent\" -q -O $localfile $url");
+ &writelog("Download finished with code: $_");
+ if ($_ == 0) { &setcachestatus("$cdir/status",$sfOk); }
}
}
+ } else {
+ $_ = $http_result;
+ s/\D+//;
+ if ($_ eq '404')
+ {
+ &writelog("Status: No source");
+ &setcachestatus("$cdir/status",$sfNoSource);
+ } else {
+ &writelog("Status: Error");
+ &setcachestatus("$cdir/status",$sfUnknown);
+ }
}
- return $contentlength;
-}
-
-# -------------------------------------------------------------------
-
-sub writelog
-{
- open (LOGFILE,">>$logfile");
- my @now = localtime(time);
- printf LOGFILE "%02d:%02d:%02d %s\n",$now[2],$now[1],$now[0],$_[0];
- close LOGFILE;
+
+ &setcachestatus("$cdir/checkup.log",time);
}
# -------------------------------------------------------------------
--- /dev/null
+#!/usr/bin/perl
+#
+# This code is distributed under the terms of the GPL
+#
+# (c) 2007-2008 marco.s - http://update-accelerator.advproxy.net
+#
+# $Id: convert,v 1.0 2007/09/12 00:00:00 marco.s Exp $
+#
+
+use strict;
+
+my $updcache='/var/updatecache/';
+my @metadata=();
+my $filename='';
+my $uuid='';
+my $vendorid='';
+my @cachedirs=qw(download);
+my $i=0;
+my $n=0;
+my $verbose=1;
+my $logging=1;
+my $logfile="/var/log/updatexlrator/convert.log";
+
+if (@ARGV[0] eq '-nv') { $verbose = 0; }
+if (!-d "/var/log/updatexlrator") { $logging = 0; }
+
+&writelog("Converting cached objects from Update Accelerator 1.0 to 2.x");
+&writelog("------------------------------------------------------------");
+
+(-d "$updcache/metadata") || die "No version 1.0 cache found.\n";
+
+if (`ps --no-heading -C wget`)
+{
+ &writelog("WARNING: Download in progress");
+ print "\n";
+ system("killall -9 -i wget");
+ print "\n";
+}
+
+foreach (<$updcache/metadata/*>)
+{
+ $filename = substr($_,rindex($_,'/')+1,length($_));
+ if ((-f "$updcache/$filename") && (-f "$updcache/metadata/$filename"))
+ {
+ &writelog("$filename");
+ open (FILE,$_);
+ @metadata = <FILE>;
+ close FILE;
+ chomp(@metadata);
+ if (@metadata >= 5)
+ {
+ $uuid = `echo $metadata[0] | md5sum`;
+ $uuid =~ s/[^0-9a-f]//g;
+ $uuid =~ s/([a-f\d]{8})([a-f\d]{4})([a-f\d]{4})([a-f\d]{4})([a-f\d]{12})/$1-$2-$3-$4-$5/;
+ $vendorid = $metadata[1];
+ $vendorid =~ tr/A-Z/a-z/;
+ unless (-d "$updcache/$vendorid")
+ {
+ system("mkdir $updcache/$vendorid");
+ push(@cachedirs,$vendorid);
+ }
+ system("chmod 775 $updcache/$vendorid");
+ unless (-d "$updcache/$vendorid/$uuid") { system("mkdir $updcache/$vendorid/$uuid"); }
+ system("chmod 775 $updcache/$vendorid/$uuid");
+ open (FILE,">$updcache/$vendorid/$uuid/source.url");
+ print FILE "$metadata[0]\n";
+ close FILE;
+ open (FILE,">$updcache/$vendorid/$uuid/status");
+ print FILE "$metadata[2]\n";
+ close FILE;
+ open (FILE,">$updcache/$vendorid/$uuid/checkup.log");
+ print FILE "$metadata[3]\n";
+ close FILE;
+ open (FILE,">$updcache/$vendorid/$uuid/access.log");
+ for($i=4;$i<@metadata;$i++)
+ {
+ print FILE "$metadata[$i]\n";
+ }
+ close FILE;
+ system("mv $updcache/$filename $updcache/$vendorid/$uuid");
+ system("chmod 664 $updcache/$vendorid/$uuid/*");
+ $n++;
+ } else { &writelog("WARNING: Insufficient metadata for $filename"); }
+ }
+}
+
+if (($n) && (-d "$updcache/metadata")) { system("rm -r $updcache/metadata"); }
+
+foreach (@cachedirs) { system("chown -R nobody:squid $updcache/$_"); }
+
+if ($n) { &writelog("------------------------------------------------------------"); }
+
+$verbose=1;
+&writelog("$n objects converted.");
+
+# -------------------------------------------------------------------
+
+sub writelog
+{
+ if ($verbose) { print "$_[0]\n"; }
+ if ($logging)
+ {
+ open (LOGFILE,">>$logfile");
+ my @now = localtime(time);
+ printf LOGFILE "%04d-%02d-%02d %02d:%02d:%02d %s\n",$now[5]+1900,$now[4]+1,$now[3],$now[2],$now[1],$now[0],$_[0];
+ close LOGFILE;
+ }
+}
+
+# -------------------------------------------------------------------
#
# This code is distributed under the terms of the GPL
#
-# (c) 2006 marco.s
+# (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
#
-# $Id: download,v 1.0 2006/08/30 00:00:00 marco.s Exp $
+# $Id: download,v 2.0 2008/04/06 00:00:00 marco.s Exp $
#
use strict;
+use HTTP::Date;
+my $swroot='/var/ipfire';
+my $apphome="$swroot/updatexlrator";
my $logfile="/var/log/updatexlrator/download.log";
-my $debug = 1;
-my $updcachedir="/var/updatecache";
-my $updfile='';
-my @metadata=();
+my $logging=0;
+my $repository='/var/updatecache';
+my $login='';
+my $dlrate='';
+my $uuid='';
+my $wget="$apphome/bin/wget";
+my $useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+my %xlratorsettings=();
+my %proxysettings=();
+my @http_header=();
+my $remote_mtime=0;
+my $updatefile='';
+my $unique=0;
+my $mirror=1;
my $sfOk="1";
-my $dsturl=@ARGV[0]; if ($dsturl eq '') { exit; }
+my $vendorid = @ARGV[0]; if ($vendorid eq '') { exit; }
+my $sourceurl = @ARGV[1]; if ($sourceurl eq '') { exit; }
+my $cfmirror = @ARGV[2]; if ($cfmirror eq '') { exit; }
-$dsturl =~ s@\%2f@/@ig;
-$updfile = substr($dsturl,rindex($dsturl,"/")+1);
+umask(0002);
-# ---------------------------------------------------------------
-# Retrieve file
-# ---------------------------------------------------------------
+$sourceurl =~ s@\%2f@/@ig;
+$sourceurl =~ s@\%7e@~@ig;
+$updatefile = substr($sourceurl,rindex($sourceurl,"/")+1);
+$updatefile =~ s@\%20@ @ig;
+$vendorid =~ tr/A-Z/a-z/;
-if ($debug)
+unless (-d "$repository/download/$vendorid")
{
- &writelog("Retrieving file for local cache: $updfile");
- `/usr/bin/wget -nc -nd -nv -P $updcachedir/download $dsturl >>$logfile 2>&1`;
-} else
+ system("mkdir $repository/download/$vendorid");
+ system("$apphome/bin/setperms download/$vendorid");
+}
+
+exit if (-e "$repository/download/$vendorid/$updatefile");
+
+system("touch $repository/download/$vendorid/$updatefile");
+
+if ($cfmirror)
+{
+ $uuid = `echo $updatefile | md5sum`;
+} else {
+ $uuid = `echo $sourceurl | md5sum`;
+}
+
+$uuid =~ s/[^0-9a-f]//g;
+$uuid =~ s/([a-f\d]{8})([a-f\d]{4})([a-f\d]{4})([a-f\d]{4})([a-f\d]{12})/$1-$2-$3-$4-$5/;
+
+if (-e "$swroot/updatexlrator/settings")
+{
+ &readhash("$swroot/updatexlrator/settings", \%xlratorsettings);
+ if ($xlratorsettings{'ENABLE_LOG'} eq 'on') { $logging=1; };
+ if ($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') { $dlrate = "--limit-rate=" . int($xlratorsettings{'MAX_DOWNLOAD_RATE'} / 8) . "k" };
+}
+
+if (-e "$swroot/proxy/settings") { &readhash("$swroot/proxy/settings", \%proxysettings); }
+
+if (-e "$swroot/proxy/advanced/settings")
+{
+ %proxysettings=();
+ &readhash("$swroot/proxy/advanced/settings", \%proxysettings);
+}
+
+if (($proxysettings{'UPSTREAM_PROXY'}) && ($proxysettings{'UPSTREAM_USER'}))
{
- `/usr/bin/wget -nc -nd -nv -P $updcachedir/download $dsturl 2>&1`;
+ $login = "--proxy-user=\"$proxysettings{'UPSTREAM_USER'}\"";
+ if ($proxysettings{'UPSTREAM_PASSWORD'})
+ {
+ $login .= " --proxy-password=\"$proxysettings{'UPSTREAM_PASSWORD'}\"";
+ }
}
-if ($debug) { &writelog("Moving file into the cache directory -> \"$updcachedir/$updfile\""); }
-system("mv $updcachedir/download/$updfile $updcachedir");
+if ($xlratorsettings{'MAX_DOWNLOAD_RATE'} eq '')
+{
+ &writelog("Retrieving file for local cache: $updatefile");
+} else {
+ &writelog("Retrieving file for local cache at max. " . $xlratorsettings{'MAX_DOWNLOAD_RATE'} . " kBit/s: $updatefile");
+}
-# ---------------------------------------------------------------
-# Write metadata
-# ---------------------------------------------------------------
+$ENV{'http_proxy'} = $proxysettings{'UPSTREAM_PROXY'};
+@http_header = `$wget $login --user-agent="$useragent" --spider -S $sourceurl 2>&1`;
+$ENV{'http_proxy'} = '';
-if ($debug) { &writelog("Writing metadata \"$updcachedir/metadata/$updfile\""); }
+foreach (@http_header)
+{
+ chomp;
+ if (/^\s*Content-Length:\s/) { s/[^0-9]//g; &writelog("Remote file size: $_ bytes"); }
+ if (/^\s*Last-Modified:\s/) { s/^\s*Last-Modified:\s//; $remote_mtime = HTTP::Date::str2time($_); &writelog("Remote file date: $_"); }
+}
-open(FILE,"$updcachedir/metadata/$updfile");
-@metadata = <FILE>;
-close(FILE);
-chomp @metadata;
-$metadata[2]="$sfOk";
-$metadata[3]=time;
-open(FILE,">$updcachedir/metadata/$updfile");
-foreach (@metadata) { print FILE "$_\n"; }
-print FILE time."\n";
-close(FILE);
+$ENV{'http_proxy'} = $proxysettings{'UPSTREAM_PROXY'};
+unlink "$repository/download/$vendorid/$updatefile";
+$_ = system("$wget $login $dlrate --user-agent=\"$useragent\" -q -nc -P $repository/download/$vendorid $sourceurl");
+$ENV{'http_proxy'} = '';
-# ===============================================================
+if ($_ == 0)
+{
+ &writelog("Download finished with result code: OK");
+
+ unless (-d "$repository/$vendorid")
+ {
+ system("mkdir $repository/$vendorid");
+ system("$apphome/bin/setperms $vendorid");
+ }
+
+ unless (-d "$repository/$vendorid/$uuid")
+ {
+ system("mkdir $repository/$vendorid/$uuid");
+ system("$apphome/bin/setperms $vendorid/$uuid");
+ }
+
+ &writelog("Moving file to the cache directory: $vendorid/$uuid");
+ $updatefile =~ s@ @\\ @ig;
+ system("mv $repository/download/$vendorid/$updatefile $repository/$vendorid/$uuid");
+ # Workaround for IPCop's mv bug:
+ utime time,$remote_mtime,"$repository/$vendorid/$uuid/$updatefile";
+ $updatefile =~ s@\\ @ @ig;
+
+ &setcachestatus("$repository/$vendorid/$uuid/source.url",$sourceurl);
+ &setcachestatus("$repository/$vendorid/$uuid/status",$sfOk);
+ &setcachestatus("$repository/$vendorid/$uuid/checkup.log",time);
+ &setcachestatus("$repository/$vendorid/$uuid/access.log",time);
+
+ system("$apphome/bin/setperms $vendorid/$uuid/*");
+
+} else {
+ &writelog("Download finished with result code: ERROR");
+ if (-e "$repository/download/$vendorid/$updatefile") { unlink ("$repository/download/$vendorid/$updatefile"); }
+}
+
+
+# -------------------------------------------------------------------
+
+sub readhash
+{
+ my $filename = $_[0];
+ my $hash = $_[1];
+ my ($var, $val);
+
+ if (-e $filename)
+ {
+ open(FILE, $filename) or die "Unable to read file $filename";
+ while (<FILE>)
+ {
+ chop;
+ ($var, $val) = split /=/, $_, 2;
+ if ($var)
+ {
+ $val =~ s/^\'//g;
+ $val =~ s/\'$//g;
+
+ # Untaint variables read from hash
+ $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
+ $val =~ /([\w\W]*)/; $val = $1;
+ $hash->{$var} = $val;
+ }
+ }
+ close FILE;
+ }
+}
+
+# -------------------------------------------------------------------
sub writelog
{
- open (LOGFILE,">>$logfile");
- my @now = localtime(time);
- printf LOGFILE "%02d:%02d:%02d %s\n",$now[2],$now[1],$now[0],$_[0];
- close LOGFILE;
+ if ($logging)
+ {
+ open (LOGFILE,">>$logfile");
+ my @now = localtime(time);
+ printf LOGFILE "%04d-%02d-%02d %02d:%02d:%02d [%d] %s\n",$now[5]+1900,$now[4]+1,$now[3],$now[2],$now[1],$now[0],$$,$_[0];
+ close LOGFILE;
+ }
+}
+
+# -------------------------------------------------------------------
+
+sub setcachestatus
+{
+ open (FILE,">$_[0]");
+ print FILE "$_[1]\n";
+ close FILE;
}
-# ===============================================================
+# -------------------------------------------------------------------
--- /dev/null
+#!/usr/bin/perl
+#
+# This code is distributed under the terms of the GPL
+#
+# (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
+#
+# $Id: lscache,v 1.0 2007/09/11 00:00:00 marco.s Exp $
+#
+
+use strict;
+use Getopt::Std;
+
+my $swroot='/var/ipfire';
+my $apphome="$swroot/updatexlrator";
+my $repository='/var/updatecache';
+my $updatefile='';
+my $sourceurl='';
+my $filesize=0;
+my $totalfilesize=0;
+my $cachedtraffic=0;
+my @updatelist=();
+my @sources=();
+my @requests=();
+my @filelist=();
+my $objectdir='';
+my @tmp;
+my $counts=0;
+my $filedate;
+my $lastaccess;
+my $vendorid;
+my @vendors=();
+my $numfiles=0;
+my $cachehits=0;
+my $efficiency='0.0';
+my %vendorstats=();
+my $maxlength_filesize=0;
+my $maxlength_request=0;
+my $maxlength_vendorid=0;
+
+
+getopts('adfs');
+
+foreach (<$repository/*>)
+{
+ if (-d $_)
+ {
+ unless ((/^$repository\/download$/) || (/^$repository\/lost\+found$/)) { push(@sources,$_); }
+ }
+}
+
+foreach (@sources)
+{
+ $vendorid=substr($_,rindex($_,'/')+1,length($_));
+ push(@vendors,$vendorid);
+ @updatelist=<$_/*>;
+ foreach $objectdir (@updatelist)
+ {
+ if (-e "$objectdir/source.url")
+ {
+ open (FILE,"$objectdir/source.url");
+ $sourceurl=<FILE>;
+ close FILE;
+ chomp($sourceurl);
+ $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
+ #
+ # Get filesize and calculate max length for output
+ #
+ $filesize = (-s "$objectdir/$updatefile");
+ if (length($filesize) > $maxlength_filesize) { $maxlength_filesize = length($filesize); }
+ #
+ # Total file size
+ #
+ $totalfilesize += $filesize;
+ #
+ # File size for this source
+ #
+ $vendorstats{$vendorid . "_filesize"} += $filesize;
+ #
+ # Number of requests from cache for this source
+ #
+ open (FILE,"$objectdir/access.log");
+ @requests=<FILE>;
+ close FILE;
+ chomp(@requests);
+ $counts = @requests;
+ $counts--;
+ $vendorstats{$vendorid . "_requests"} += $counts;
+ $cachehits += $counts;
+ #
+ # Calculate cache hits max length for output
+ #
+ if (length($cachehits) > $maxlength_request) { $maxlength_request = length($cachehits); }
+ #
+ # Get last cache access date
+ #
+ my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($requests[-1]);
+ $DAYdt = sprintf ("%.02d",$DAYdt);
+ $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
+ $YEARdt = sprintf ("%.04d",$YEARdt+1900);
+ if (($counts) && ($requests[-1] =~ /^\d+/) && ($requests[-1] >= 1))
+ {
+ $lastaccess = $YEARdt."-".$MONTHdt."-".$DAYdt;
+ } else {
+ $lastaccess = ' ';
+ }
+ #
+ # Get file modification time
+ #
+ ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime(&getmtime("$objectdir/$updatefile"));
+ $DAYdt = sprintf ("%.02d",$DAYdt);
+ $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
+ $YEARdt = sprintf ("%.04d",$YEARdt+1900);
+ $filedate = $YEARdt."-".$MONTHdt."-".$DAYdt;
+ #
+ # Total number of files in cache
+ #
+ $numfiles++;
+ #
+ # Number of files for this source
+ #
+ $vendorstats{$vendorid . "_files"}++;
+ #
+ # Count cache status occurences
+ #
+ open (FILE,"$objectdir/status");
+ $_=<FILE>;
+ close FILE;
+ chomp;
+ $vendorstats{$vendorid . "_" . $_}++;
+ #
+ # Calculate cached traffic for this source
+ #
+ $vendorstats{$vendorid . "_cachehits"} += $counts * $filesize;
+ #
+ # Calculate total cached traffic
+ #
+ $cachedtraffic += $counts * $filesize;
+ #
+ # Calculate vendor ID max length for output
+ #
+ if (length($vendorid) > $maxlength_vendorid) { $maxlength_vendorid = length($vendorid); }
+ #
+ # Add record to filelist
+ #
+ push (@filelist,"$filesize;$filedate;$counts;$lastaccess;$vendorid;$objectdir;$updatefile");
+ }
+ }
+}
+
+@filelist || die "No matching files found in cache\n";
+
+#
+# Process statistics for output
+#
+
+if ($Getopt::Std::opt_s)
+{
+ foreach (@vendors)
+ {
+ print "$_\n";
+ printf "%5d %s", $vendorstats{$_ . "_files"}, "files in cache\n";
+ printf "%5d %s", $vendorstats{$_ . "_requests"}, "files from cache\n";
+ printf "%5d %s", $vendorstats{$_ . "_1"}, "files 'Ok'\n";
+ printf "%5d %s", $vendorstats{$_ . "_3"}, "files 'No source'\n";
+ printf "%5d %s", $vendorstats{$_ . "_2"}, "files 'Outdated'\n";
+ printf "%5d %s", $vendorstats{$_ . "_0"}, "files 'Unknown'\n";
+ unless ($vendorstats{$_ . "_filesize"}) { $vendorstats{$_ . "_filesize"} = '0'; }
+ 1 while $vendorstats{$_ . "_filesize"} =~ s/^(-?\d+)(\d{3})/$1.$2/;
+ printf "%15s %s", $vendorstats{$_ . "_filesize"}, "bytes in cache\n";
+ unless ($vendorstats{$_ . "_cachehits"}) { $vendorstats{$_ . "_cachehits"} = '0'; }
+ 1 while $vendorstats{$_ . "_cachehits"} =~ s/^(-?\d+)(\d{3})/$1.$2/;
+ printf "%15s %s", $vendorstats{$_ . "_cachehits"}, "bytes from cache\n\n";
+ }
+
+ if ($numfiles) { $efficiency = sprintf("%.1f", $cachehits / $numfiles); }
+ 1 while $totalfilesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
+ 1 while $cachedtraffic =~ s/^(-?\d+)(\d{3})/$1.$2/;
+ print "\nTotal files in cache: $numfiles\n";
+ print "Total cache size: $totalfilesize bytes\n";
+ print "Delivered from cache: $cachedtraffic bytes\n";
+ print "Cache efficiency index: $efficiency\n";
+
+ exit;
+}
+
+#
+# Process filelist for output
+#
+
+foreach (@filelist)
+{
+ @tmp = split(';');
+ printf "%$maxlength_filesize\d %s ",$tmp[0],$tmp[1];
+ if ($Getopt::Std::opt_a) { printf "%$maxlength_request\d %s ",$tmp[2],$tmp[3]; }
+ if ($Getopt::Std::opt_d) { printf "%-$maxlength_vendorid\s ",$tmp[4]; }
+ if ($Getopt::Std::opt_f) { print "$tmp[5]/"; }
+ print "$tmp[6]\n";
+}
+
+
+# -------------------------------------------------------------------
+
+sub getmtime
+{
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]);
+
+ return $mtime;
+}
+
+# -------------------------------------------------------------------
+
+sub VERSION_MESSAGE
+{
+ $Getopt::Std::STANDARD_HELP_VERSION=1;
+ print <<EOM
+lscache (Update Accelerator coreutils) 1.00
+Copyright (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
+EOM
+;
+}
+
+# -------------------------------------------------------------------
+
+sub HELP_MESSAGE
+{
+ print <<EOM
+
+Usage: lscache [-adf | -s]
+
+Shows details about the Update Accelerator cache content
+
+File listing:
+ -a list number of cache hits and last access date
+ -d list download source
+ -f list full cache path
+
+Statistics:
+ -s show statistics by source
+
+ --help display this help
+ --version output version information
+EOM
+;
+}
+
+# -------------------------------------------------------------------
#
# This code is distributed under the terms of the GPL
#
-# (c) 2006 marco.s
+# (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
#
-# $Id: updxlrator,v 1.0 2006/10/03 00:00:00 marco.s Exp $
+# $Id: updxlrator,v 2.0 2008/04/06 00:00:00 marco.s Exp $
#
use strict;
-
-use IO::Socket;
+use HTTP::Date;
$|=1;
my $swroot="/var/ipfire";
my $updcachedir="/var/updatecache";
+my $apphome="/var/ipfire/updatexlrator";
+my $logfile="/var/log/updatexlrator/cache.log";
+my $wget="$apphome/bin/wget";
+my $debug=(-e "$apphome/debug");
+my $http_port='81';
my %netsettings=();
+my %proxysettings=();
my %xlratorsettings=();
-my $http_port="81";
-my $logfile="/var/log/updatexlrator/cache.log";
my $logging=0;
my $passive_mode=0;
my $maxusage=0;
my $nice='';
my @tmp=();
-my $now='';
my $request='';
-my $from_local_cache=0;
-my $dsturl='';
+my $xlrator_url=0;
+my $source_url='';
my $hostaddr='';
my $username='';
my $method='';
-my @metadata=();
-
-my $sfNoSource = "0";
-my $sfOk = "1";
-my $sfOutdated = "2";
-
-unless (-d "$updcachedir/metadata")
-{
- unless (-d "$updcachedir") { mkdir "$updcachedir"; }
- mkdir "$updcachedir/metadata";
- system("chown nobody.squid $updcachedir");
- system("chmod 775 $updcachedir");
- system("chown nobody.squid $updcachedir/metadata");
- system("chmod 775 $updcachedir/metadata");
-}
+my $unique = 0;
+my $mirror = 1;
readhash("${swroot}/ethernet/settings", \%netsettings);
if ($xlratorsettings{'ENABLE_LOG'} eq 'on') { $logging=1; };
if ($xlratorsettings{'PASSIVE_MODE'} eq 'on') { $passive_mode=1; };
$maxusage=$xlratorsettings{'MAX_DISK_USAGE'};
- if ($xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} eq 'on') { $nice='/bin/nice --adjustment=15 '; };
+ if ($xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} eq 'on') { $nice='/usr/bin/nice --adjustment=15 '; };
}
if (!$maxusage) { $maxusage=75; };
while (<>) {
$request=$_;
- $from_local_cache=0;
@tmp=split(/ /,$request);
chomp(@tmp);
- $dsturl =$tmp[0];
- $hostaddr=$tmp[1]; while ($hostaddr =~ /.*\/$/) { chop $hostaddr; }
- $username=$tmp[2]; if ($username eq '') { $username='-'; };
- $method =$tmp[3];
+ $source_url = $tmp[0];
+ $hostaddr = $tmp[1]; while ($hostaddr =~ /.*\/$/) { chop $hostaddr; }
+ $username = $tmp[2]; if ($username eq '') { $username='-'; };
+ $method = $tmp[3];
+
+ $xlrator_url = $source_url;
if (($method eq 'GET') || ($method eq 'HEAD'))
{
# -----------------------------------------------------------
if (
- (($dsturl =~ m@^http://[^/]*\.microsoft\.com/.*\.(exe|psf|msi)$@i) ||
- ($dsturl =~ m@^http://[^/]*\.windowsupdate\.com/.*\.(exe|psf|cab)$@i))
- && ($dsturl !~ m@^http://[^/]*\.microsoft\.com/.*(/autoupd|selfupdate/).*\.cab@i)
- && ($dsturl !~ m@\&@)
+ (($source_url =~ m@^http://[^/]*\.microsoft\.com/.*\.(exe|psf|msi|msp|cab)$@i) ||
+ ($source_url =~ m@^http://[^/]*\.windowsupdate\.com/.*\.(exe|psf|msi|msp|cab)$@i))
+ && ($source_url !~ m@^http://[^/]*\.microsoft\.com/.*(/autoupd|selfupdate/).*\.cab@i)
+ && ($source_url !~ m@\&@)
)
{
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Microsoft");
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Microsoft",$unique);
}
# -----------------------------------------------------------
# Section: Adobe Downloads
# -----------------------------------------------------------
- if ($dsturl =~ m@^http://(ar)?download\.adobe\.com/.*\.(exe|bin|dmg|idx|gz)$@i)
+ if (
+ ($source_url =~ m@^http://(ar)?download\.adobe\.com/.*\.(exe|msi|bin|dmg|idx|gz)$@i) ||
+ ($source_url =~ m@^http://swupdl\.adobe\.com/updates/.*\.(exe|msi|bin|dmg|idx|gz|[a-z][a-z]_[A-Z][A-Z])$@i) ||
+ ($source_url =~ m@^http://swupmf\.adobe\.com/manifest/.*\.upd$@i)
+ )
+ {
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Adobe",$unique);
+ }
+
+ # -----------------------------------------------------------
+ # Section: Linux Downloads
+ # -----------------------------------------------------------
+
+ if ($source_url =~ m@^[h|f]t?tp://[^?]+\.(deb|rpm)$@i)
{
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Adobe");
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Linux",$mirror);
+ }
+
+ # -----------------------------------------------------------
+ # Section: Trend Micro Downloads
+ # -----------------------------------------------------------
+
+ if (
+ ($source_url =~ m@^http://[^/]*\.trendmicro\.com/activeupdate/.*@i) &&
+ ($source_url !~ m@.*/tmnotify\.dat$@i) &&
+ ($source_url !~ m@.*/ini_xml\.zip$@i) &&
+ ($source_url !~ m@.*/server\.ini$@i)
+ )
+ {
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"TrendMicro",$mirror);
}
# -----------------------------------------------------------
# Section: Symantec Downloads
# -----------------------------------------------------------
- if ($dsturl =~ m@^[f|h]t?tp://[^/]*\.symantec(liveupdate)?\.com/.*\.(exe|zip|xdb)$@i)
+ if ($source_url =~ m@^[h|f]tt?p://[^/]*\.symantec(liveupdate)?\.com/.*\.(exe|zip|vdb|xdb)$@i)
{
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Symantec");
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Symantec",$unique);
}
-
+
# -----------------------------------------------------------
- # Section: Avira Downloads
+ # Section: Apple Downloads
# -----------------------------------------------------------
-
- if ($dsturl =~ m@^http://dl[0-9]\.avgate\.net/.*\.(htm|html|gz)$@i)
+
+ if (
+ (($source_url =~ m@^http://swcdn\.apple\.com/content/downloads/.*\.(tar)$@i) ||
+ ($source_url =~ m@^http://appldnld\.apple\.com\.edgesuite\.net/.*\.(exe|dmg)$@i) ||
+ ($source_url =~ m@^http://.*\.g.akamai.net/.*/3093/1/.*\.(tar|pkg|dmg|exe)$@i))
+ )
{
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Avira");
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Apple",$unique);
}
-
- # -----------------------------------------------------------
- # Section: Avast Downloads
- # -----------------------------------------------------------
-
- if ($dsturl =~ m@^http://download[0-99]\.avast\.com/.*\.(exe|zip|vps|stamp|vpu)$@i)
- {
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Avast");
- }
-
- # -----------------------------------------------------------
- # Section: IPFire Downloads
- # -----------------------------------------------------------
-
- if ($dsturl =~ m@^[f|h]t?tp://.*\.(ipfire)$@i)
- {
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"IPFire");
- }
-
- # -----------------------------------------------------------
- # Section: Linux Downloads
- # -----------------------------------------------------------
-
- if ($dsturl =~ m@^[f|h]t?tp://.*\.(deb|rpm)$@i)
- {
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Linux");
+
+ # -----------------------------------------------------------
+ # Section: Avast Downloads
+ # -----------------------------------------------------------
+
+ if ($source_url =~ m@^http://download[\d]+\.avast\.com/.*\.(exe|vpu)$@i)
+ {
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Avast",$mirror);
}
+
+ # -----------------------------------------------------------
- # -----------------------------------------------------------
-
- # -----------------------------------------------------------
- # Section: Apple Downloads
- # -----------------------------------------------------------
-
- if ($dsturl =~ m@^[f|h]t?tp://swcdn\.apple.*\.(pkm|tar)$@i)
- {
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Apple");
+ # -----------------------------------------------------------
+ # Section: Avira Downloads
+ # -----------------------------------------------------------
+
+ if ($source_url =~ m@^http://dl[0-9]\.avgate\.net/.*\.(htm|html|gz)$@i)
+ {
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Avira",$mirror);
}
# -----------------------------------------------------------
- # Section: AVG Downloads
+ # Section: IPFire Downloads
# -----------------------------------------------------------
- if ($dsturl =~ m@^http://[^/]*\.(grisoft|avg)\.com/.*\.(bin)$@i)
+ if ($source_url =~ m@^[f|h]t?tp://.*\.(ipfire)$@i)
{
- $from_local_cache = &cache_access($dsturl,$hostaddr,$username,"AVG");
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"IPFire",$mirror);
}
+ }
- # -----------------------------------------------------------
- # Section: Kaspersky Downloads
- # not working properly
- # -----------------------------------------------------------
-
- #if ($dsturl =~ m@^http://dnl-.*\.kaspersky-labs\.com\/(diffs|bases|AutoPatches).*$@i)
- #{
- #$from_local_cache = &cache_access($dsturl,$hostaddr,$username,"Kaspersky");
- #}
-
- # -----------------------------------------------------------
+ # -----------------------------------------------------------
+ # Section: AVG Downloads
+ # -----------------------------------------------------------
+ if ($source_url =~ m@^http://[^/]*\.(grisoft|avg)\.com/.*\.(bin)$@i)
+ {
+ $xlrator_url = &check_cache($source_url,$hostaddr,$username,"AVG",$mirror);
}
- if ($from_local_cache) { $request="http://$netsettings{'GREEN_ADDRESS'}:$http_port/updatecache/".substr($dsturl,rindex($dsturl,"/")+1)." $hostaddr $username $method\n"; }
+ $request="$xlrator_url $hostaddr $username $method\n";
print $request;
}
sub writelog
{
- open(LOGFILE,">>$logfile");
- print LOGFILE time." $_[0] $_[1] $_[2] $_[3] $_[4]\n";
- close(LOGFILE);
+ if ($logging)
+ {
+ open(LOGFILE,">>$logfile");
+ print LOGFILE time." $_[0] $_[1] $_[2] $_[3] $_[4]\n";
+ close(LOGFILE);
+ }
}
# -------------------------------------------------------------------
-sub diskfree
+sub debuglog
{
- open(DF,"/bin/df --block-size=1 $_[0]|");
- while(<DF>)
+ if ($debug)
{
- unless ($_ =~ m/^Filesystem/ )
- {
- my ($device,$size,$used,$free,$percent,$mount) = split;
- if ($free =~ m/^(\d+)$/)
- {
- close DF;
- return $free;
- }
- }
+ open(LOGFILE,">>/var/log/updatexlrator/debug.log");
+ my @now = localtime(time);
+ printf LOGFILE "%04d-%02d-%02d %02d:%02d:%02d [%d] [%s] %s\n",$now[5]+1900,$now[4]+1,$now[3],$now[2],$now[1],$now[0],$$,"updxlrator",$_[0];
+ close(LOGFILE);
}
+}
+
+# -------------------------------------------------------------------
+
+sub setcachestatus
+{
+ open (FILE,">>$_[0]");
+ print FILE "$_[1]\n";
+ close FILE;
+}
+
+# -------------------------------------------------------------------
+
+sub diskfree
+{
+ open(DF,"/bin/df --block-size=1 $_[0]|");
+ my @dfdata = <DF>;
close DF;
+ shift(@dfdata);
+ chomp(@dfdata);
+ my $dfstr = join(' ',@dfdata);
+ my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
+ if ($free =~ m/^(\d+)$/)
+ {
+ return $free;
+ }
}
# -------------------------------------------------------------------
sub diskusage
{
open(DF,"/bin/df $_[0]|");
- while(<DF>)
+ my @dfdata = <DF>;
+ close DF;
+ shift(@dfdata);
+ chomp(@dfdata);
+ my $dfstr = join(' ',@dfdata);
+ my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
+ if ($percent =~ m/^(\d+)%$/)
{
- unless ($_ =~ m/^Filesystem/ )
- {
- my ($device,$size,$used,$free,$percent,$mount) = split;
- if ($percent =~ m/^(\d+)%$/)
- {
- close DF;
- $percent =~ s/%$//;
- return $percent;
- }
- }
+ $percent =~ s/%$//;
+ return $percent;
}
- close DF;
}
# -------------------------------------------------------------------
-sub getdownloadsize
+sub getmtime
{
- my $remote=0;
- my @response=();
- my $contentlength=0;
-
- my $url = $_[0];
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]);
- $url =~ s@^(.*)://([^/]*)@@;
+ return $mtime;
+}
- my $proto = $1;
- my $fqhn = $2;
+# -------------------------------------------------------------------
- if ((-e "$swroot/red/active") && ($proto eq 'http'))
+sub check_cache
+{
+ my $updsource="UPDCACHE";
+ my $updfile='';
+ my $cacheurl='';
+ my $vendorid='';
+ my $uuid='';
+ my @http_header=();
+ my $remote_size=0;
+ my $remote_mtime=0;
+ my $login='';
+ my $useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+
+ my $sourceurl=$_[0];
+ my $cfmirror=$_[4];
+
+ $sourceurl =~ s@\%2f@/@ig;
+ $updfile = substr($sourceurl,rindex($sourceurl,"/")+1);
+ $updfile =~ s@\%20@ @ig;
+
+ if ($cfmirror)
{
- $remote = IO::Socket::INET->new(
- PeerHost => $fqhn,
- PeerPort => 'http(80)',
- Timeout => 1
- );
+ $uuid = `echo $updfile | md5sum`;
+ } else {
+ $uuid = `echo $sourceurl | md5sum`;
}
- if ($remote)
+ $uuid =~ s/[^0-9a-f]//g;
+ $uuid =~ s/([a-f\d]{8})([a-f\d]{4})([a-f\d]{4})([a-f\d]{4})([a-f\d]{12})/$1-$2-$3-$4-$5/;
+
+ $vendorid = $_[3];
+ $vendorid =~ tr/A-Z/a-z/;
+
+ &debuglog("Processing URL $sourceurl");
+ &debuglog("Vendor ID is $vendorid");
+ &debuglog("UUID is $uuid");
+
+ if (($proxysettings{'UPSTREAM_PROXY'}) && ($proxysettings{'UPSTREAM_USER'}))
{
- print $remote "HEAD $url HTTP/1.0\n";
- print $remote "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\n";
- print $remote "Host: $fqhn\n";
- print $remote "Accept: */*\n\n";
- while (<$remote>) { push(@response,$_); }
- close $remote;
- if ($response[0] =~ /^HTTP\/\d+\.\d+\s\d+\sOK\s*$/)
+ $login = "--proxy-user=\"$proxysettings{'UPSTREAM_USER'}\"";
+ if ($proxysettings{'UPSTREAM_PASSWORD'})
{
- foreach (@response)
- {
- if (/^Content-Length: /i)
- {
- s/^Content-Length: //i;
- $contentlength=$_;
- }
- }
+ $login .= " --proxy-password=\"$proxysettings{'UPSTREAM_PASSWORD'}\"";
}
}
- return $contentlength;
-}
-# -------------------------------------------------------------------
+ if ($proxysettings{'UPSTREAM_PROXY'}) { &debuglog("Using upstream proxy $proxysettings{'UPSTREAM_PROXY'}"); }
-sub cache_access
-{
- my $updsource="UPDCACHE";
- my $updfile='';
- my $do_redirect=0;
-
- $_[0] =~ s@\%2f@/@ig;
- $updfile = substr($_[0],rindex($_[0],"/")+1);
+ $ENV{'http_proxy'} = $proxysettings{'UPSTREAM_PROXY'};
+ @http_header = `$wget $login --user-agent="$useragent" --spider -S $sourceurl 2>&1`;
+ $ENV{'http_proxy'} = '';
- if (!-e "$updcachedir/metadata/$updfile")
+ foreach (@http_header)
{
- open(FILE,">$updcachedir/metadata/$updfile");
- print FILE "$_[0]\n$_[3]\n$sfOutdated\n0\n";
- close(FILE);
+ chomp;
+ if (/^\s*Content-Length:\s/) { $remote_size = $_; $remote_size =~ s/[^0-9]//g; }
+ if (/^\s*Last-Modified:\s/) { $remote_mtime = $_; $remote_mtime =~ s/^\s*Last-Modified:\s//; $remote_mtime = HTTP::Date::str2time($remote_mtime) }
}
- if (-e "$updcachedir/$updfile")
+ if (
+ (-e "$updcachedir/$vendorid/$uuid/$updfile") &&
+ ($remote_size == (-s "$updcachedir/$vendorid/$uuid/$updfile")) &&
+ ($remote_mtime == &getmtime("$updcachedir/$vendorid/$uuid/$updfile"))
+ )
{
- open(FILE,">>$updcachedir/metadata/$updfile");
- print FILE time."\n";
- close(FILE);
- $do_redirect=1;
+ &debuglog("File exists in cache and is up to date");
+ &debuglog("Retrieving file from cache ($updsource)");
+ &setcachestatus("$updcachedir/$vendorid/$uuid/access.log",time);
+ system("$apphome/bin/setperms $vendorid/$uuid/access.log");
+ $cacheurl="http://$netsettings{'GREEN_ADDRESS'}:$http_port/updatecache/$vendorid/$uuid/$updfile";
}
else
{
+ if (-e "$updcachedir/$vendorid/$uuid/$updfile")
+ {
+ &debuglog("Local filesize: " . (-s "$updcachedir/$vendorid/$uuid/$updfile"));
+ &debuglog("Local timestamp: " . &getmtime("$updcachedir/$vendorid/$uuid/$updfile"));
+ } else { &debuglog("File not found in cache"); }
$updsource="DLSOURCE";
- if ((!$passive_mode) && (&diskusage($updcachedir) <= $maxusage) && (&getdownloadsize <= &diskfree($updcachedir)) && (!-e "$updcachedir/download/$updfile"))
+ &debuglog("Remote filesize: $remote_size");
+ &debuglog("Remote timestamp: $remote_mtime");
+ &debuglog("Free disk space: " . &diskfree($updcachedir));
+ &debuglog("Disk usage: " . &diskusage($updcachedir) . "% (max. $maxusage%)");
+ if (-e "$updcachedir/download/$vendorid/$updfile") { &debuglog("File download/$vendorid/$updfile exists"); }
+ &debuglog("Retrieving file from source ($updsource)");
+ if ((!$passive_mode) && (&diskusage($updcachedir) <= $maxusage) && ($remote_size <= &diskfree($updcachedir)) && (!-e "$updcachedir/download/$vendorid/$updfile"))
{
- system("$nice/var/ipfire/updatexlrator/bin/download $_[0] &");
+ &debuglog("Running command $nice$apphome/bin/download $vendorid $sourceurl $cfmirror &");
+ system("$nice$apphome/bin/download $vendorid $sourceurl $cfmirror &");
}
+ $cacheurl=$sourceurl;
}
- if ($logging) { &writelog($_[1],$_[2],$_[3],$updsource,$_[0]); }
+ &writelog($_[1],$_[2],$_[3],$updsource,$sourceurl);
- return $do_redirect;
+ return $cacheurl;
}
# -------------------------------------------------------------------
my %proxysettings=();
my %xlratorsettings=();
my $id=0;
+my @dfdata=();
+my $dfstr='';
+my @updatelist=();
+my @sources=();
+my $sourceurl='';
+my $vendorid='';
+my $uuid='';
+my $status=0;
my $updatefile='';
my $shortname='';
-my $vendor='';
my $time='';
my $filesize=0;
my $filedate='';
my $lastaccess='';
my $lastcheck='';
-
-my $repository = "/var/updatecache";
+my $cachedtraffic=0;
+my @requests=();
+my $data='';
+my $counts=0;
+my $numfiles=0;
+my $cachehits=0;
+my $efficiency='0.0';
+my @vendors=();
+my %vendorstats=();
+
+my $repository = "/var/updatecache/";
my $hintcolour = '#FFFFCC';
+my $colourgray = '#808080';
-my $sfNoSource='0';
+my $sfUnknown='0';
my $sfOk='1';
my $sfOutdated='2';
+my $sfNoSource='3';
my $not_accessed_last='';
$xlratorsettings{'ACTION'} = '';
$xlratorsettings{'ENABLE_LOG'} = 'off';
$xlratorsettings{'PASSIVE_MODE'} = 'off';
-$xlratorsettings{'MAX_DISK_USAGE'} = '95';
+$xlratorsettings{'MAX_DISK_USAGE'} = '75';
$xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} = 'off';
+$xlratorsettings{'MAX_DOWNLOAD_RATE'} = '';
$xlratorsettings{'ENABLE_AUTOCHECK'} = 'off';
$xlratorsettings{'FULL_AUTOSYNC'} = 'off';
$xlratorsettings{'NOT_ACCESSED_LAST'} = 'month1';
&Header::getcgihash(\%xlratorsettings);
+$xlratorsettings{'EXTENDED_GUI'} = '';
+
+if ($xlratorsettings{'ACTION'} eq "$Lang::tr{'updxlrtr statistics'} >>")
+{
+ $xlratorsettings{'EXTENDED_GUI'} = 'statistics';
+}
+
+if ($xlratorsettings{'ACTION'} eq "$Lang::tr{'updxlrtr maintenance'} >>")
+{
+ $xlratorsettings{'EXTENDED_GUI'} = 'maintenance';
+}
+
if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr purge'})
{
+ $xlratorsettings{'EXTENDED_GUI'} = 'maintenance';
+
if (($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on') || ($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') || ($xlratorsettings{'REMOVE_OUTDATED'} eq 'on'))
{
- @repositorylist = <$repository/*>;
- foreach (@repositorylist)
+ undef (@sources);
+ undef @repositoryfiles;
+ foreach (<$repository/*>)
+ {
+ if (-d $_)
+ {
+ unless (/^$repository\/download$/) { push(@sources,$_); }
+ }
+ }
+
+ foreach (@sources)
{
- if (!-d $_)
+ @updatelist=<$_/*>;
+ $vendorid = substr($_,rindex($_,"/")+1);
+ foreach(@updatelist)
{
- $updatefile = substr($_,rindex($_,"/")+1);
- if (-e "$repository/metadata/$updatefile")
+ $uuid = substr($_,rindex($_,"/")+1);
+ if (-e "$_/source.url")
{
- open (FILE,"$repository/metadata/$updatefile");
- @metadata = <FILE>;
+ open (FILE,"$_/source.url");
+ $sourceurl=<FILE>;
close FILE;
- chomp(@metadata);
-
- if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($metadata[2] == $sfNoSource))
- {
- unlink("$repository/$updatefile");
- unlink("$repository/metadata/$updatefile");
- }
- if (($xlratorsettings{'REMOVE_OUTDATED'} eq 'on') && ($metadata[2] == $sfOutdated))
- {
- unlink("$repository/$updatefile");
- unlink("$repository/metadata/$updatefile");
- }
- if ($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on')
- {
- if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'week') && ($metadata[-1] < (time - 604800)))
- {
- unlink("$repository/$updatefile");
- unlink("$repository/metadata/$updatefile");
- }
- if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($metadata[-1] < (time - 2505600)))
- {
- unlink("$repository/$updatefile");
- unlink("$repository/metadata/$updatefile");
- }
- if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month3') && ($metadata[-1] < (time - 7516800)))
- {
- unlink("$repository/$updatefile");
- unlink("$repository/metadata/$updatefile");
- }
- if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($metadata[-1] < (time - 15033600)))
- {
- unlink("$repository/$updatefile");
- unlink("$repository/metadata/$updatefile");
- }
- if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'year') && ($metadata[-1] < (time - 31536000)))
- {
- unlink("$repository/$updatefile");
- unlink("$repository/metadata/$updatefile");
- }
- }
+ chomp($sourceurl);
+ $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
+ $updatefile = "$vendorid/$uuid/$updatefile";
+ push(@repositoryfiles,$updatefile);
+ }
+ }
+ }
+
+ foreach (@repositoryfiles)
+ {
+ ($vendorid,$uuid,$updatefile) = split('/');
+
+ if (-e "$repository/$vendorid/$uuid/status")
+ {
+ open (FILE,"$repository/$vendorid/$uuid/status");
+ @metadata = <FILE>;
+ close FILE;
+ chomp(@metadata);
+ $status = $metadata[-1];
+ }
+
+ if (-e "$repository/$vendorid/$uuid/access.log")
+ {
+ open (FILE,"$repository/$vendorid/$uuid/access.log");
+ @metadata = <FILE>;
+ close FILE;
+ chomp(@metadata);
+ $lastaccess = $metadata[-1];
+ }
+
+ if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($status == $sfNoSource))
+ {
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ }
+ if (($xlratorsettings{'REMOVE_OUTDATED'} eq 'on') && ($status == $sfOutdated))
+ {
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ }
+ if ($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on')
+ {
+ if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'week') && ($lastaccess < (time - 604800)))
+ {
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ }
+ if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($lastaccess < (time - 2505600)))
+ {
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ }
+ if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month3') && ($lastaccess < (time - 7516800)))
+ {
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ }
+ if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($lastaccess < (time - 15033600)))
+ {
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ }
+ if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'year') && ($lastaccess < (time - 31536000)))
+ {
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
}
}
}
$errormessage = $Lang::tr{'updxlrtr invalid disk usage'};
goto ERROR;
}
+ if (($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') && ((!($xlratorsettings{'MAX_DOWNLOAD_RATE'} =~ /^\d+$/)) || ($xlratorsettings{'MAX_DOWNLOAD_RATE'} < 1)))
+ {
+ $errormessage = $Lang::tr{'updxlrtr invalid download rate'};
+ goto ERROR;
+ }
&savesettings;
}
$errormessage = $Lang::tr{'updxlrtr invalid disk usage'};
goto ERROR;
}
- if (!(-e "${General::swroot}/proxy/enable"))
+ if (($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') && ((!($xlratorsettings{'MAX_DOWNLOAD_RATE'} =~ /^\d+$/)) || ($xlratorsettings{'MAX_DOWNLOAD_RATE'} < 1)))
+ {
+ $errormessage = $Lang::tr{'updxlrtr invalid download rate'};
+ goto ERROR;
+ }
+ if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue")))
{
$errormessage = $Lang::tr{'updxlrtr web proxy service required'};
goto ERROR;
if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr remove file'})
{
+ $xlratorsettings{'EXTENDED_GUI'} = 'maintenance';
+
$updatefile = $xlratorsettings{'ID'};
- if (-e "$repository/$updatefile") { unlink("$repository/$updatefile"); }
- $updatefile =~ s/^download\///i;
- if (-e "$repository/metadata/$updatefile") { unlink("$repository/metadata/$updatefile"); }
-}
-ERROR:
+ if ($updatefile =~ /^download\//)
+ {
+ ($uuid,$vendorid,$updatefile) = split('/',$updatefile);
+ if (-e "$repository/download/$vendorid/$updatefile") { system("rm $repository/download/$vendorid/$updatefile"); }
+ } else {
+ ($vendorid,$uuid,$updatefile) = split('/',$updatefile);
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ }
+}
$not_accessed_last = $xlratorsettings{'NOT_ACCESSED_LAST'};
undef($xlratorsettings{'NOT_ACCESSED_LAST'});
if ($xlratorsettings{'NOT_ACCESSED_LAST'} eq '') { $xlratorsettings{'NOT_ACCESSED_LAST'} = $not_accessed_last; } ;
+ERROR:
$checked{'ENABLE_LOG'}{'off'} = '';
$checked{'ENABLE_LOG'}{'on'} = '';
<tr>
<td class='base' width='25%'>$Lang::tr{'updxlrtr enable log'}:</td>
<td class='base' width='20%'><input type='checkbox' name='ENABLE_LOG' $checked{'ENABLE_LOG'}{'on'} /></td>
+ <td class='base' width='25%'></td>
+ <td class='base' width='30%'></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'updxlrtr passive mode'}:</td>
<td class='base'>$Lang::tr{'updxlrtr max disk usage'}:</td>
<td class='base'><input type='text' name='MAX_DISK_USAGE' value='$xlratorsettings{'MAX_DISK_USAGE'}' size='1' /> %</td>
</tr>
+</table>
+<hr size='1'>
+<table width='100%'>
<tr>
- <td class='base'>$Lang::tr{'updxlrtr low download priority'}:</td>
- <td class='base'><input type='checkbox' name='LOW_DOWNLOAD_PRIORITY' $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} /></td>
- <td> </td>
- <td> </td>
+ <td colspan='4'><b>$Lang::tr{'updxlrtr performance options'}</b></td>
+</tr>
+<tr>
+ <td class='base' width='25%'>$Lang::tr{'updxlrtr low download priority'}:</td>
+ <td class='base' width='20%'><input type='checkbox' name='LOW_DOWNLOAD_PRIORITY' $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} /></td>
+ <td class='base' width='25%'>$Lang::tr{'updxlrtr max download rate'}: <img src='/blob.gif' alt='*' </td>
+ <td class='base' width='30%'><input type='text' name='MAX_DOWNLOAD_RATE' value='$xlratorsettings{'MAX_DOWNLOAD_RATE'}' size='5' /></td>
</tr>
</table>
<hr size='1'>
<hr size='1'>
<table width='100%'>
<tr>
- <td colspan='6'><b>$Lang::tr{'updxlrtr maintenance'}</b></td>
-</tr>
-<tr>
- <td class='base' colspan='3'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr purge'}' /> $Lang::tr{'updxlrtr all files'}</td>
- <td class='base' width='25%'><input type='checkbox' name='REMOVE_OBSOLETE' $checked{'REMOVE_OBSOLETE'}{'on'} /> $Lang::tr{'updxlrtr not accessed'}</td>
- <td class='base' colspan='3'><select name='NOT_ACCESSED_LAST'>
- <option value='week' $selected{'NOT_ACCESSED_LAST'}{'week'}>$Lang::tr{'updxlrtr week'}</option>
- <option value='month1' $selected{'NOT_ACCESSED_LAST'}{'month1'}>$Lang::tr{'updxlrtr month'}</option>
- <option value='month3' $selected{'NOT_ACCESSED_LAST'}{'month3'}>$Lang::tr{'updxlrtr 3 months'}</option>
- <option value='month6' $selected{'NOT_ACCESSED_LAST'}{'month6'}>$Lang::tr{'updxlrtr 6 months'}</option>
- <option value='year' $selected{'NOT_ACCESSED_LAST'}{'year'}>$Lang::tr{'updxlrtr year'}</option>
- </select>
- </td>
+ <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
+ <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr save and restart'}' /></td>
+ <td> </td>
+END
+;
+
+print" <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr statistics'}";
+if ($xlratorsettings{'EXTENDED_GUI'} eq 'statistics') { print " <<' "; } else { print " >>' "; }
+print "/></td>\n";
+
+print" <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr maintenance'}";
+if ($xlratorsettings{'EXTENDED_GUI'} eq 'maintenance') { print " <<' "; } else { print " >>' "; }
+print "/></td>\n";
+
+print <<END
</tr>
+</table>
+END
+;
+
+&Header::closebox();
+
+print "</form>\n";
+
+# =====================================================================================
+# CACHE STATISTICS
+# =====================================================================================
+
+if ($xlratorsettings{'EXTENDED_GUI'} eq 'statistics')
+{
+
+# ----------------------------------------------------
+# Get statistics
+# ----------------------------------------------------
+
+@sources=();
+foreach (<$repository/*>)
+{
+ if (-d $_)
+ {
+ unless ((/^$repository\/download$/) || (/^$repository\/lost\+found$/)) { push(@sources,$_); }
+ }
+}
+
+@vendors=();
+foreach (@sources)
+{
+ $vendorid=substr($_,rindex($_,'/')+1,length($_));
+ push(@vendors,$vendorid);
+ @updatelist=<$_/*>;
+ foreach $data (@updatelist)
+ {
+ if (-e "$data/source.url")
+ {
+ open (FILE,"$data/source.url");
+ $sourceurl=<FILE>;
+ close FILE;
+ chomp($sourceurl);
+ $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
+ #
+ # Total file size
+ #
+ $filesize += (-s "$data/$updatefile");
+ #
+ # File size for this source
+ #
+ $vendorstats{$vendorid."_filesize"} += (-s "$data/$updatefile");
+ #
+ # Number of requests from cache for this source
+ #
+ open (FILE,"$data/access.log");
+ @requests=<FILE>;
+ close FILE;
+ chomp(@requests);
+ $counts = @requests;
+ $counts--;
+ $vendorstats{$vendorid."_requests"} += $counts;
+ $cachehits += $counts;
+ #
+ # Total number of files in cache
+ #
+ $numfiles++;
+ #
+ # Number of files for this source
+ #
+ $vendorstats{$vendorid."_files"}++;
+ #
+ # Count cache status occurences
+ #
+ open (FILE,"$data/status");
+ $_=<FILE>;
+ close FILE;
+ chomp;
+ $vendorstats{$vendorid."_".$_}++;
+ #
+ # Calculate cached traffic for this source
+ #
+ $vendorstats{$vendorid."_cachehits"} += $counts * (-s "$data/$updatefile");
+ #
+ # Calculate total cached traffic
+ #
+ $cachedtraffic += $counts * (-s "$data/$updatefile");
+
+ }
+ }
+}
+
+if ($numfiles) { $efficiency = sprintf("%.1f", $cachehits / $numfiles); }
+
+1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
+1 while $cachedtraffic =~ s/^(-?\d+)(\d{3})/$1.$2/;
+
+# ----------------------------------------------------
+# Show statistics
+# ----------------------------------------------------
+
+&Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr cache statistics'}");
+
+unless ($numfiles) { print "<i>$Lang::tr{'updxlrtr empty repository'}</i>\n<hr size='1'>\n"; }
+
+print <<END
+<table>
+<tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td></tr>
+</table>
+<table cellpadding='3'>
<tr>
+<td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
+<td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
+<td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
+<td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
+<td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
</tr>
+END
+;
+
+open(DF,"/bin/df -h $repository|");
+@dfdata = <DF>;
+close DF;
+shift(@dfdata);
+chomp(@dfdata);
+$dfstr = join(' ',@dfdata);
+my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
+
+print <<END
<tr>
- <td class='base' width='25%'><input type='checkbox' name='REMOVE_NOSOURCE' $checked{'REMOVE_NOSOURCE'}{'on'} /> $Lang::tr{'updxlrtr marked as'}</td>
- <td class='base' width='3%'><img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
- <td class='base' width='17%'>[<i>$Lang::tr{'updxlrtr condition nosource'}</i>]</td>
- <td class='base' width='25%'><input type='checkbox' name='REMOVE_OUTDATED' $checked{'REMOVE_OUTDATED'}{'on'} /> $Lang::tr{'updxlrtr marked as'}</td>
- <td class='base' width='3%'><img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
- <td class='base' width='27%'>[<i>$Lang::tr{'updxlrtr condition outdated'}</i>]</td>
+<td>[$repository]</td>
+<td align='right'>$size</td>
+<td align='right'>$used</td>
+<td align='right'>$free</td>
+<td>
+END
+;
+&percentbar($percent);
+print <<END
+</td>
+<td align='right'>$percent</td>
</tr>
</table>
+END
+;
+
+if ($numfiles)
+{
+ print <<END
<hr size='1'>
<table width='100%'>
<tr>
- <td> </td>
- <td align='center' width='45%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
- <td align='center' width='45%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr save and restart'}' /></td>
- <td> </td>
+ <td colspan='5'><b>$Lang::tr{'updxlrtr summary'}</b></td>
+</tr>
+<tr>
+ <td class='base' width='25%'>$Lang::tr{'updxlrtr total files'}:</td>
+ <td class='base' width='20%'><font color='$colourgray'>$numfiles</font></td>
+ <td class='base' width='25%'>$Lang::tr{'updxlrtr total cache size'}:</td>
+ <td class='base' width='15%' align='right'><font color='$colourgray'>$filesize</font></td>
+ <td class='base'></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'updxlrtr efficiency index'}:</td>
+ <td class='base'><font color='$colourgray'>$efficiency</font></td>
+ <td class='base'>$Lang::tr{'updxlrtr total data from cache'}:</td>
+ <td class='base' align='right'><font color='$colourgray'>$cachedtraffic</font></td>
+ <td class='base'></td>
</tr>
</table>
-<table width='100%'>
+<hr size='1'>
+<table>
<tr>
- <td align='right'>
-
- </td>
+ <td colspan='17'><b>$Lang::tr{'updxlrtr statistics by source'}</b></td>
+</tr>
+<tr>
+ <td class='base' colspan='2'><i>$Lang::tr{'updxlrtr source'}</i></td>
+ <td class='base' width='7%'> </td>
+ <td class='base' align='right'><i>$Lang::tr{'updxlrtr files'}</i></td>
+ <td class='base' width='7%'> </td>
+ <td class='base' align='right'><nobr><i>$Lang::tr{'updxlrtr cache size'}</i></nobr></td>
+ <td class='base' width='7%'> </td>
+ <td class='base' align='right'><nobr><i>$Lang::tr{'updxlrtr data from cache'}</i></nobr></td>
+ <td class='base' width='15%'> </td>
+ <td class='base'><img src="/images/updbooster/updxl-led-green.gif" /></td>
+ <td class='base' width='15%'> </td>
+ <td class='base'><img src="/images/updbooster/updxl-led-yellow.gif" /></td>
+ <td class='base' width='15%'> </td>
+ <td class='base'><img src="/images/updbooster/updxl-led-red.gif" /></td>
+ <td class='base' width='15%'> </td>
+ <td class='base'><img src="/images/updbooster/updxl-led-gray.gif" /></td>
+ <td class='base' width='90%'> </td>
</tr>
+END
+;
+
+$id = 0;
+
+foreach (@vendors)
+{
+ $vendorid = $_;
+
+ unless ($vendorstats{$vendorid . "_files"}) { next; }
+
+ $id++;
+ if ($id % 2) {
+ print "<tr bgcolor=''$color{'color20'}'>\n"; }
+ else {
+ print "<tr bgcolor=''$color{'color22'}'>\n"; }
+
+ print "<td class='base' align='center'><nobr> ";
+
+ if ($vendorid =~ /^Adobe$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe'}' /> </nobr></td>\n";
+ print "<td class='base'> Adobe </td>\n";
+ } elsif ($vendorid =~ /^Microsoft$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft'}' /> </nobr></td>\n";
+ print "<td class='base'> Microsoft </td>\n";
+ } elsif ($vendorid =~ /^Symantec$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec'}' /> </nobr></td>\n";
+ print "<td class='base'> Symantec </td>\n";
+ } elsif ($vendorid =~ /^Linux$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-linux.gif' alt='Linux'}' /> </nobr></td>\n";
+ print "<td class='base'> Linux </td>\n";
+ } elsif ($vendorid =~ /^TrendMicro$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro'}' /> </nobr></td>\n";
+ print "<td class='base'> Trend Micro </td>\n";
+ } elsif ($vendorid =~ /^Apple$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-apple.gif' alt='Apple'}' /> </nobr></td>\n";
+ print "<td class='base'> Apple </td>\n";
+ } elsif ($vendorid =~ /^Avast$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-avast.gif' alt='Avast'}' /> </nobr></td>\n";
+ print "<td class='base'> Avast </td>\n";
+ } elsif ($vendorid =~ /^Avira$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-avira.gif' alt='Avira' /> </td>\n";
+ print "<td class='base'> Avira </td>\n";
+ } elsif ($vendorid =~ /^AVG$/i)
+ {
+ print "<img src='/images/updbooster/updxl-src-avg.gif' alt='AVG' /> </td>\n";
+ print "<td class='base'> AVG </td>\n";
+ } elsif ($vendorid =~ /^Ipfire$/i)
+ {
+ print "<img src='/images/IPFire.png' width='18' height='18' alt='IPFire' /> </td>\n";
+ print "<td class='base'> IPFiew </td>\n";
+ } else
+ {
+ if (-e "/srv/web/ipfire/html/images/updbooster/updxl-src-" . $vendorid . ".gif")
+ {
+ print "<img src='/images/updbooster/updxl-src-" . $vendorid . ".gif' alt='" . ucfirst $vendorid . "' /> </nobr></td>\n";
+ } else {
+ print "<img src='/images/updbooster/updxl-src-unknown.gif' alt='" . ucfirst $vendorid . "' /> </nobr></td>\n";
+ }
+ print "<td class='base'> " . ucfirst $vendorid . " </td>\n";
+ }
+
+ print "<td class='base' colspan=2 align='right'>";
+ printf "%5d", $vendorstats{$vendorid."_files"};
+ print " </td>\n";
+
+ unless ($vendorstats{$vendorid."_filesize"}) { $vendorstats{$vendorid."_filesize"} = '0'; }
+ 1 while $vendorstats{$vendorid."_filesize"} =~ s/^(-?\d+)(\d{3})/$1.$2/;
+ print "<td class='base' colspan=2 align='right'>";
+ printf "%15s", $vendorstats{$vendorid."_filesize"};
+ print " </td>\n";
+
+ unless ($vendorstats{$vendorid."_cachehits"}) { $vendorstats{$vendorid."_cachehits"} = '0'; }
+ 1 while $vendorstats{$vendorid."_cachehits"} =~ s/^(-?\d+)(\d{3})/$1.$2/;
+ print "<td class='base' colspan=2 align='right'>";
+ printf "%15s", $vendorstats{$vendorid."_cachehits"};
+ print " </td>\n";
+
+ print "<td class='base' colspan=2 align='right'>";
+ printf "%5d", $vendorstats{$vendorid."_1"};
+ print " </td>\n";
+
+ print "<td class='base' colspan=2 align='right'>";
+ printf "%5d", $vendorstats{$vendorid."_3"};
+ print " </td>\n";
+
+ print "<td class='base' colspan=2 align='right'>";
+ printf "%5d", $vendorstats{$vendorid."_2"};
+ print " </td>\n";
+
+ print "<td class='base' colspan=2 align='right'>";
+ printf "%5d", $vendorstats{$vendorid."_0"};
+ print " </td>\n";
+
+ print "<td class='base'> </td>\n";
+ print "</tr>\n";
+}
+
+print "</table>\n";
+
+print <<END
+<br>
+<table>
+ <tr>
+ <td class='boldbase'> <b>$Lang::tr{'legend'}:</b></td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /></td>
+ <td class='base'>$Lang::tr{'updxlrtr condition ok'}</td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
+ <td class='base'>$Lang::tr{'updxlrtr condition nosource'}</td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
+ <td class='base'>$Lang::tr{'updxlrtr condition outdated'}</td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition unknown'}' /></td>
+ <td class='base'>$Lang::tr{'updxlrtr condition unknown'}</td>
+ <td class='base'> </td>
+ </tr>
</table>
END
;
+}
+
&Header::closebox();
-print "</form>\n";
+}
+
+# =====================================================================================
+# CACHE MAINTENANCE
+# =====================================================================================
+
+if ($xlratorsettings{'EXTENDED_GUI'} eq 'maintenance')
+{
+
# ----------------------------------------------------
# File list dialog
# ----------------------------------------------------
-&Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr current files'}:");
+&Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr cache maintenance'}");
-@repositorylist = <$repository/download/*>;
+@sources= <$repository/download/*>;
undef @repositoryfiles;
-foreach (@repositorylist)
+foreach (@sources)
{
- if (!-d)
+ if (-d)
{
- $updatefile = substr($_,rindex($_,"/")+1);
- $updatefile = "download/$updatefile";
- push(@repositoryfiles,$updatefile);
+ @updatelist = <$_/*>;
+ $vendorid = substr($_,rindex($_,"/")+1);
+ foreach(@updatelist)
+ {
+ $updatefile = substr($_,rindex($_,"/")+1);
+ $updatefile .= ":download/$vendorid/$updatefile";
+ $updatefile = " ".$updatefile;
+ push(@repositoryfiles,$updatefile);
+ }
}
}
-@repositorylist = <$repository/*>;
+undef (@sources);
+foreach (<$repository/*>)
+{
+ if (-d $_)
+{
+ unless (/^$repository\/download$/) { push(@sources,$_); }
+ }
+}
-foreach (@repositorylist)
+foreach (@sources)
{
- if (!-d) { push(@repositoryfiles,substr($_,rindex($_,"/")+1)); }
+ @updatelist=<$_/*>;
+ $vendorid = substr($_,rindex($_,"/")+1);
+ foreach(@updatelist)
+ {
+ $uuid = substr($_,rindex($_,"/")+1);
+ if (-e "$_/source.url")
+ {
+ open (FILE,"$_/source.url");
+ $sourceurl=<FILE>;
+ close FILE;
+ chomp($sourceurl);
+ $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
+ $_ = $updatefile; tr/[A-Z]/[a-z]/;
+ $updatefile = "$_:$vendorid/$uuid/$updatefile";
+ push(@repositoryfiles,$updatefile);
+ }
+ }
}
+@repositoryfiles = sort(@repositoryfiles);
+
+unless (@repositoryfiles) { print "<i>$Lang::tr{'updxlrtr empty repository'}</i>\n<hr size='1'>\n"; }
+
+print <<END
+<table>
+<tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td></tr>
+</table>
+<table cellpadding='3'>
+<tr>
+<td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
+<td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
+<td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
+<td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
+<td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
+</tr>
+END
+;
+
+open(DF,"/bin/df -h $repository|");
+@dfdata = <DF>;
+close DF;
+shift(@dfdata);
+chomp(@dfdata);
+$dfstr = join(' ',@dfdata);
+my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
+
+print <<END
+<tr>
+<td>[$repository]</td>
+<td align='right'>$size</td>
+<td align='right'>$used</td>
+<td align='right'>$free</td>
+<td>
+END
+;
+&percentbar($percent);
+print <<END
+</td>
+<td align='right'>$percent</td>
+</tr>
+</table>
+END
+;
+
if (@repositoryfiles)
{
print <<END
+<hr size='1'>
+<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
+<table width='100%'>
+<tr>
+ <td class='base' colspan='3'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr purge'}' /> $Lang::tr{'updxlrtr all files'}</td>
+ <td class='base' width='25%'><input type='checkbox' name='REMOVE_OBSOLETE' $checked{'REMOVE_OBSOLETE'}{'on'} /> $Lang::tr{'updxlrtr not accessed'}</td>
+ <td class='base' colspan='3'><select name='NOT_ACCESSED_LAST'>
+ <option value='week' $selected{'NOT_ACCESSED_LAST'}{'week'}>$Lang::tr{'updxlrtr week'}</option>
+ <option value='month1' $selected{'NOT_ACCESSED_LAST'}{'month1'}>$Lang::tr{'updxlrtr month'}</option>
+ <option value='month3' $selected{'NOT_ACCESSED_LAST'}{'month3'}>$Lang::tr{'updxlrtr 3 months'}</option>
+ <option value='month6' $selected{'NOT_ACCESSED_LAST'}{'month6'}>$Lang::tr{'updxlrtr 6 months'}</option>
+ <option value='year' $selected{'NOT_ACCESSED_LAST'}{'year'}>$Lang::tr{'updxlrtr year'}</option>
+ </select>
+ </td>
+</tr>
+<tr>
+</tr>
+<tr>
+ <td class='base' width='25%'><input type='checkbox' name='REMOVE_NOSOURCE' $checked{'REMOVE_NOSOURCE'}{'on'} /> $Lang::tr{'updxlrtr marked as'}</td>
+ <td class='base' width='3%'><img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
+ <td class='base' width='17%'>[<i>$Lang::tr{'updxlrtr condition nosource'}</i>]</td>
+ <td class='base' width='25%'><input type='checkbox' name='REMOVE_OUTDATED' $checked{'REMOVE_OUTDATED'}{'on'} /> $Lang::tr{'updxlrtr marked as'}</td>
+ <td class='base' width='3%'><img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
+ <td class='base' width='27%'>[<i>$Lang::tr{'updxlrtr condition outdated'}</i>]</td>
+</tr>
+</table>
+</form>
+<hr size='1'>
+<table>
+<tr><td class='boldbase'><b>$Lang::tr{'updxlrtr current files'}</b></td></tr>
+</table>
<table width='100%'>
<colgroup span='2' width='2%'></colgroup>
<colgroup span='1' width='0*'></colgroup>
<td class='base' align='center'><b>$Lang::tr{'updxlrtr filesize'}</b></td>
<td class='base' align='center'><b>$Lang::tr{'date'}</b></td>
<td class='base' align='center'><img src='/images/reload.gif' alt='$Lang::tr{'updxlrtr last access'}' /></td>
- <td class='base' align='center'><img src='/images/floppy.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
+ <td class='base' align='center'><img src='/images/updbooster/updxl-globe.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
<td class='base' align='center'> </td>
</tr>
END
$id = 0;
foreach $updatefile (@repositoryfiles)
{
+ $updatefile =~ s/.*://;
+
$id++;
if ($id % 2) {
- print "<tr bgcolor='$color{'color20'}'>\n"; }
+ print "<tr bgcolor='$Header::table1colour'>\n"; }
else {
- print "<tr bgcolor='$color{'color22'}'>\n"; }
+ print "<tr bgcolor='$Header::table2colour'>\n"; }
$filesize = (-s "$repository/$updatefile");
1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
$lastaccess = "n/a";
$lastcheck = "n/a";
- undef @metadata;
- $shortname = $updatefile;
- $shortname =~ s/^download\///i;
+ $status = $sfUnknown;
- if (-e "$repository/metadata/$shortname")
+ unless ($updatefile =~ /^download\//)
{
- open (FILE,"$repository/metadata/$shortname");
- @metadata = <FILE>;
- close(FILE);
- chomp @metadata;
-
- ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
- $DAYdt = sprintf ("%.02d",$DAYdt);
- $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
- $YEARdt = sprintf ("%.04d",$YEARdt+1900);
- if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastaccess = $YEARdt."-".$MONTHdt."-".$DAYdt; }
-
- ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[3]);
- $DAYdt = sprintf ("%.02d",$DAYdt);
- $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
- $YEARdt = sprintf ("%.04d",$YEARdt+1900);
- if (($metadata[3] =~ /^\d+/) && ($metadata[3] >= 1)) { $lastcheck = $YEARdt."-".$MONTHdt."-".$DAYdt; }
+ ($vendorid,$uuid,$shortname) = split('/',$updatefile);
+
+ if (-e "$repository/$vendorid/$uuid/access.log")
+ {
+ open (FILE,"$repository/$vendorid/$uuid/access.log");
+ @metadata = <FILE>;
+ close(FILE);
+ chomp @metadata;
+
+ ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
+ $DAYdt = sprintf ("%.02d",$DAYdt);
+ $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
+ $YEARdt = sprintf ("%.04d",$YEARdt+1900);
+ if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastaccess = $YEARdt."-".$MONTHdt."-".$DAYdt; }
+ }
+ if (-e "$repository/$vendorid/$uuid/checkup.log")
+ {
+ open (FILE,"$repository/$vendorid/$uuid/checkup.log");
+ @metadata = <FILE>;
+ close(FILE);
+ chomp @metadata;
+
+ ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
+ $DAYdt = sprintf ("%.02d",$DAYdt);
+ $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
+ $YEARdt = sprintf ("%.04d",$YEARdt+1900);
+ if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastcheck = $YEARdt."-".$MONTHdt."-".$DAYdt; }
+ }
+ if (-e "$repository/$vendorid/$uuid/status")
+ {
+ open (FILE,"$repository/$vendorid/$uuid/status");
+ @metadata = <FILE>;
+ close(FILE);
+ chomp @metadata;
+ $status = $metadata[-1];
+ }
+ } else {
+ ($uuid,$vendorid,$shortname) = split('/',$updatefile);
+ $status = $sfOutdated;
}
-
+
print "\t\t<td align='center' nowrap='nowrap'> ";
- if ($metadata[2] eq $sfNoSource)
+ if ($status == $sfUnknown)
{
- print "<img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /> </td>\n";
+ print "<img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition unknown'}' /> </td>\n";
}
- if ($metadata[2] eq $sfOk)
+ if ($status == $sfOk)
{
- print "<img src='/images/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /> </td>\n";
+ print "<img src='/images/updbooster/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /> </td>\n";
}
- if (($metadata[2] eq $sfOutdated) && (!($updatefile =~ /^download\//i)))
+ if ($status == $sfNoSource)
{
- print "<img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /> </td>\n";
+ print "<img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /> </td>\n";
}
- if (($metadata[2] eq $sfOutdated) && ($updatefile =~ /^download\//i))
+ if (($status == $sfOutdated) && (!($updatefile =~ /^download\//i)))
{
- print "<img src='/images/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /> </td>\n";
+ print "<img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /> </td>\n";
}
- if ($metadata[2] eq '')
+ if (($status == $sfOutdated) && ($updatefile =~ /^download\//i))
{
- print "<img src='/images/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /> </td>\n";
+ print "<img src='/images/updbooster/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /> </td>\n";
}
print "\t\t<td align='center' nowrap='nowrap'> ";
- if ($metadata[1] eq 'Adobe')
+ if ($vendorid =~ /^Adobe$/i)
{
- print "<img src='/images/updxl-src-adobe.gif' alt='Adobe' /> </td>\n";
- } elsif ($metadata[1] eq 'Microsoft')
+ print "<img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe'}' /> </td>\n";
+ } elsif ($vendorid =~ /^Microsoft$/i)
{
- print "<img src='/images/updxl-src-windows.gif' alt='Microsoft' /> </td>\n";
- } elsif ($metadata[1] eq 'Symantec')
+ print "<img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft'}' /> </td>\n";
+ } elsif ($vendorid =~ /^Symantec$/i)
{
- print "<img src='/images/updxl-src-symantec.gif' alt='Symantec' /> </td>\n";
- } elsif ($metadata[1] eq 'Avira')
+ print "<img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec'}' /> </td>\n";
+ } elsif ($vendorid =~ /^Linux$/i)
{
- print "<img src='/images/updxl-src-avira.gif' alt='Avira' /> </td>\n";
- } elsif ($metadata[1] eq 'AVG')
+ print "<img src='/images/updbooster/updxl-src-linux.gif' alt='Linux'}' /> </td>\n";
+ } elsif ($vendorid =~ /^TrendMicro$/i)
{
- print "<img src='/images/updxl-src-avg.gif' alt='AVG' /> </td>\n";
- } elsif ($metadata[1] eq 'Avast')
+ print "<img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro'}' /> </td>\n";
+ } elsif ($vendorid =~ /^Apple$/i)
{
- print "<img src='/images/updxl-src-avast.gif' alt='Avast' /> </td>\n";
- } elsif ($metadata[1] eq 'IPFire')
+ print "<img src='/images/updbooster/updxl-src-apple.gif' alt='Apple'}' /> </td>\n";
+ } elsif ($vendorid =~ /^Avast$/i)
{
- print "<img src='/images/IPFire.png' width='18' height='18' alt='IPFire' /> </td>\n";
- } elsif ($metadata[1] eq 'Apple')
+ print "<img src='/images/updbooster/updxl-src-avast.gif' alt='Avast'}' /> </td>\n";
+ } elsif ($vendorid =~ /^Avira$/i)
{
- print "<img src='/images/updxl-src-apple.gif' alt='Apple' /> </td>\n";
- } elsif ($metadata[1] eq 'Kaspersky')
+ print "<img src='/images/updbooster/updxl-src-avira.gif' alt='Avira' /> </td>\n";
+ } elsif ($vendorid =~ /^AVG$/i)
{
- print "<img src='/images/updxl-src-kaspersky.gif' alt='Kaspersky' /> </td>\n";
- } elsif ($metadata[1] eq 'Linux')
+ print "<img src='/images/updbooster/updxl-src-avg.gif' alt='AVG' /> </td>\n";
+ } elsif ($vendorid =~ /^Ipfire$/i)
{
- print "<img src='/images/tux.png' alt='Linux' /> </td>\n";
- } else
+ print "<img src='/images/IPFire.png' width='18' height='18' alt='IPFire' /> </td>\n";
+ }
+ else
{
- print "<img src='/images/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr unknown'}' /> </td>\n";
+ if (-e "/srv/web/ipfire/html/images/updbooster/updxl-src-" . $vendorid . ".gif")
+ {
+ print "<img src='/images/updbooster/updxl-src-" . $vendorid . ".gif' alt='" . ucfirst $vendorid . "' /> </td>\n";
+ } else {
+ print "<img src='/images/updbooster/updxl-src-unknown.gif' alt='" . ucfirst $vendorid . "' /> </td>\n";
+ }
}
- $shortname = $updatefile;
+ $shortname = substr($updatefile,rindex($updatefile,"/")+1);
$shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/\1_*\2/i;
- $shortname =~ s/^download\///i;
print <<END
- <td class='base' align='left' title='$updatefile'>$shortname</td>
+ <td class='base' align='left' title='cache:/$updatefile'><a href="/updatecache/$updatefile">$shortname</a></td>
<td class='base' align='right' nowrap='nowrap'> $filesize </td>
<td class='base' align='center' nowrap='nowrap'> $filedate </td>
<td class='base' align='center' nowrap='nowrap'> $lastaccess </td>
<td><img src='/images/reload.gif' alt='$Lang::tr{'updxlrtr last access'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr last access'}</td>
<td class='base'> </td>
- <td><img src='/images/floppy.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
+ <td><img src='/images/updbooster/updxl-globe.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr last checkup'}</td>
<td class='base'> </td>
<td><img src='/images/delete.gif' alt='$Lang::tr{'updxlrtr remove file'}' /></td>
<td class='base'> </td>
</tr>
<tr>
- <td colspan='13'></td>
+ <td colspan='13'><br></td>
</tr>
<tr>
<td class='base'> $Lang::tr{'status'}:</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /></td>
+ <td align='center'><img src='/images/updbooster/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr condition ok'}</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
+ <td align='center'><img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr condition nosource'}</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
+ <td align='center'><img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr condition outdated'}</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /></td>
+ <td align='center'> </td>
+ <td class='base'> </td>
+ </tr>
+ <tr>
+ <td class='base'> </td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr condition download'}</td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition unknown'}' /></td>
+ <td class='base'>$Lang::tr{'updxlrtr condition unknown'}</td>
+ <td class='base'> </td>
+ <td align='center'> </td>
+ <td class='base'> </td>
+ <td class='base'> </td>
+ <td align='center'> </td>
+ <td class='base'> </td>
</tr>
<tr>
- <td colspan='13'></td>
+ <td colspan='13'> <br></td>
</tr>
<tr>
<td class='base'> $Lang::tr{'updxlrtr source'}:</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-adobe.gif' alt='Adobe' /></td>
+ <td align='center'><img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe' /></td>
<td class='base'>Adobe</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-windows.gif' alt='Microsoft' /></td>
- <td class='base'>Microsoft</td>
+ <td align='center'><img src='/images/updbooster/updxl-src-apple.gif' alt='Apple' /></td>
+ <td class='base'>Apple</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-symantec.gif' alt='Symantec' /></td>
- <td class='base'>Symantec</td>
+ <td align='center'><img src='/images/updbooster/updxl-src-avast.gif' alt='Avast' /></td>
+ <td class='base'>Avast</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-avira.gif' alt='Avira' /></td>
- <td class='base'>Avira</td>
+ <td align='center'><img src='/images/updbooster/updxl-src-linux.gif' alt='Linux' /></td>
+ <td class='base'>Linux</td>
+ </tr>
+ <tr>
+ <td colspan='13'></td>
+ </tr>
+ <tr>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-avg.gif' alt='AVG' /></td>
- <td class='base'>AVG</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-apple.gif' alt='Apple' /></td>
- <td class='base'>Apple</td>
+ <td align='center'><img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft' /></td>
+ <td class='base'>Microsoft</td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec' /></td>
+ <td class='base'>Symantec</td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro' /></td>
+ <td class='base'>Trend Micro</td>
<td class='base'> </td>
- </tr>
- <tr>
- <td class='base' colspan='2'> </td>
<td align='center'><img src='/images/IPFire.png' width='18' height='18' alt='IPFire' /></td>
<td class='base'>IPFire</td>
+ </tr>
+ <tr>
<td class='base'> </td>
- <td align='center'><img src='/images/tux.png' alt='Linux' /></td>
- <td class='base'>Linux</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-avast.gif' alt='Avast' /></td>
- <td class='base'>Avast</td>
+ <td align='center'><img src='/images/updbooster/updxl-src-avira.gif' alt='Avira' /></td>
+ <td class='base'>Avira</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-kaspersky.gif' alt='Kaspersky' /></td>
- <td class='base'>Kaspersky</td>
+ <td align='center'><img src='/images/updbooster/updxl-src-avg.gif' alt='AVG' /></td>
+ <td class='base'>AVG</td>
+ <td class='base'> </td>
+ <td align='center'><img src='/images/updbooster/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr other'}' /></td>
+ <td class='base'>$Lang::tr{'updxlrtr other'}</td>
<td class='base'> </td>
- <td align='center'><img src='/images/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr unknown'}' /></td>
- <td class='base'>$Lang::tr{'updxlrtr unknown'}</td>
+ <td align='center'></td>
<td class='base'> </td>
</tr>
</table>
END
;
-} else {
- print "<i>$Lang::tr{'updxlrtr empty repository'}</i>\n";
}
-print <<END
-<hr>
-
-<table>
-<tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}:</b></td></tr>
-</table>
+&Header::closebox();
-<table cellpadding='3'>
-END
-;
-open(DF,"/bin/df -h $repository|");
-while(<DF>)
-{
- if ($_ =~ m/^Filesystem/ )
- {
- print <<END
-<tr>
-<td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
-<td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
-</tr>
-END
-;
- }
- else
- {
- my ($device,$size,$used,$free,$percent,$mount) = split;
- print <<END
-<tr>
-<td>[$repository]</td>
-<td align='right'>$size</td>
-<td align='right'>$used</td>
-<td align='right'>$free</td>
-<td>
-END
-;
- &percentbar($percent);
- print <<END
-</td>
-<td align='right'>$percent</td>
-</tr>
-END
-;
- }
}
-close DF;
-print "</table>\n";
-&Header::closebox();
+# =====================================================================================
+
+# ----------------------------------------------------
&Header::closebigbox();
delete($xlratorsettings{'REMOVE_NOSOURCE'});
delete($xlratorsettings{'REMOVE_OUTDATED'});
+ delete($xlratorsettings{'EXTENDED_GUI'});
+
&General::writehash("${General::swroot}/updatexlrator/settings", \%xlratorsettings);
}