blob: 0879a8b722fd9a770bdf93aeb46e552c0d70cd18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package ftp;
use Net::FTP;
use install_any;
use log;
# non-rentrant!!
1;
sub new {
my %options = (Passive => 1);
$options{Firewall} = $ENV{PROXY} if $ENV{PROXY};
$options{Port} = $ENV{PROXYPORT} if $ENV{PROXYPORT};
my @l;
unless ($ENV{HOST}) {
# must be in kickstart, using URLPREFIX to find out information
($ENV{LOGIN}, $ENV{PASSWORD}, $ENV{HOST}, $ENV{PREFIX}) = @l =
$ENV{URLPREFIX} =~ m|
://
(?: ([^:]*) # login
(?: :([^@]*))? # password
@)?
([^/]*) # host
/?(.*) # prefix
|x;
}
unless ($ENV{LOGIN}) {
$ENV{LOGIN} = 'anonymous';
$ENV{PASSWORD} = 'mdkinst@test';
}
my $host = $ENV{HOST};
if ($host !~ /^[.\d]+$/) {
$host = join ".", unpack "C4", (gethostbyname $host)[4];
}
my $ftp = Net::FTP->new($host, %options) or die;
$ftp->login($ENV{LOGIN}, $ENV{PASSWORD}) or die;
$ftp->binary;
$ftp;
}
my $retr;
sub getFile($) {
$ftp ||= new();
$retr->close if $retr;
$retr = $ftp->retr($ENV{PREFIX} . "/" . install_any::relGetFile($_[0]));
}
|