blob: 6c498f2afcb7899bd2e2a619c295111197219212 (
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
|
package ftp;
use Net::FTP;
use install_any;
use network;
use log;
# non-rentrant!!
my $retr;
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 $ftp = Net::FTP->new(network::resolv($ENV{HOST}), %options) or die '';
$ftp->login($ENV{LOGIN}, $ENV{PASSWORD}) or die '';
$ftp->binary;
$ftp;
}
sub getFile($) {
$ftp ||= new();
$retr->close if $retr;
$retr = $ftp->retr($ENV{PREFIX} . "/" . install_any::relGetFile($_[0]));
}
|