]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - config/updxlrator/download
Am Pakfire weitergearbeitet.
[people/teissler/ipfire-2.x.git] / config / updxlrator / download
CommitLineData
46c01c09
MT
1#!/usr/bin/perl
2#
3# This code is distributed under the terms of the GPL
4#
5# (c) 2006 marco.s
6#
7# $Id: download,v 1.0 2006/08/30 00:00:00 marco.s Exp $
8#
9
10use strict;
11
46c01c09 12my $logfile="/var/log/updatexlrator/download.log";
5b2a12ff 13my $debug = 0;
46c01c09
MT
14my $updcachedir="/srv/web/ipfire/html/updatecache";
15my $updfile='';
16my @metadata=();
17
18my $sfOk="1";
19
20my $dsturl=@ARGV[0]; if ($dsturl eq '') { exit; }
21
22$dsturl =~ s@\%2f@/@ig;
23$updfile = substr($dsturl,rindex($dsturl,"/")+1);
24
25# ---------------------------------------------------------------
26# Retrieve file
27# ---------------------------------------------------------------
28
29if ($debug)
30{
31 &writelog("Retrieving file for local cache: $updfile");
5b2a12ff 32 `/usr/bin/wget -nc -nd -nv -P $updcachedir/download $dsturl >>$logfile 2>&1`;
46c01c09
MT
33} else
34{
5b2a12ff 35 `/usr/bin/wget -nc -nd -nv -P $updcachedir/download $dsturl 2>&1`;
46c01c09
MT
36}
37
38if ($debug) { &writelog("Moving file into the cache directory -> \"$updcachedir/$updfile\""); }
39system("mv $updcachedir/download/$updfile $updcachedir");
40
41# ---------------------------------------------------------------
42# Write metadata
43# ---------------------------------------------------------------
44
45if ($debug) { &writelog("Writing metadata \"$updcachedir/metadata/$updfile\""); }
46
47open(FILE,"$updcachedir/metadata/$updfile");
48@metadata = <FILE>;
49close(FILE);
50chomp @metadata;
51$metadata[2]="$sfOk";
52$metadata[3]=time;
53open(FILE,">$updcachedir/metadata/$updfile");
54foreach (@metadata) { print FILE "$_\n"; }
55print FILE time."\n";
56close(FILE);
57
58# ===============================================================
59
60sub writelog
61{
62 open (LOGFILE,">>$logfile");
63 my @now = localtime(time);
64 printf LOGFILE "%02d:%02d:%02d %s\n",$now[2],$now[1],$now[0],$_[0];
65 close LOGFILE;
66}
67
68# ===============================================================