mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-05-05 03:18:00 +02:00
Added changes to the first core update to avoid full root partitions git-svn-id: http://svn.ipfire.org/svn/ipfire/branches/2.1/trunk@1113 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
69 lines
1.7 KiB
Perl
69 lines
1.7 KiB
Perl
#!/usr/bin/perl
|
|
#
|
|
# This code is distributed under the terms of the GPL
|
|
#
|
|
# (c) 2006 marco.s
|
|
#
|
|
# $Id: download,v 1.0 2006/08/30 00:00:00 marco.s Exp $
|
|
#
|
|
|
|
use strict;
|
|
|
|
my $logfile="/var/log/updatexlrator/download.log";
|
|
my $debug = 1;
|
|
my $updcachedir="/var/updatecache";
|
|
my $updfile='';
|
|
my @metadata=();
|
|
|
|
my $sfOk="1";
|
|
|
|
my $dsturl=@ARGV[0]; if ($dsturl eq '') { exit; }
|
|
|
|
$dsturl =~ s@\%2f@/@ig;
|
|
$updfile = substr($dsturl,rindex($dsturl,"/")+1);
|
|
|
|
# ---------------------------------------------------------------
|
|
# Retrieve file
|
|
# ---------------------------------------------------------------
|
|
|
|
if ($debug)
|
|
{
|
|
&writelog("Retrieving file for local cache: $updfile");
|
|
`/usr/bin/wget -nc -nd -nv -P $updcachedir/download $dsturl >>$logfile 2>&1`;
|
|
} else
|
|
{
|
|
`/usr/bin/wget -nc -nd -nv -P $updcachedir/download $dsturl 2>&1`;
|
|
}
|
|
|
|
if ($debug) { &writelog("Moving file into the cache directory -> \"$updcachedir/$updfile\""); }
|
|
system("mv $updcachedir/download/$updfile $updcachedir");
|
|
|
|
# ---------------------------------------------------------------
|
|
# Write metadata
|
|
# ---------------------------------------------------------------
|
|
|
|
if ($debug) { &writelog("Writing metadata \"$updcachedir/metadata/$updfile\""); }
|
|
|
|
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);
|
|
|
|
# ===============================================================
|
|
|
|
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;
|
|
}
|
|
|
|
# ===============================================================
|