summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2001-06-12 22:35:40 +0000
committerdamien <damien@mandriva.com>2001-06-12 22:35:40 +0000
commit9d98348b82e5c1416a63caa74a9f0593e4798be3 (patch)
treee4d4c7483762bea88ad756e81efb3e770036b6c3 /perl-install
parent7faa440498da266d8d17f07855fef9d585aa1b1a (diff)
downloaddrakx-9d98348b82e5c1416a63caa74a9f0593e4798be3.tar
drakx-9d98348b82e5c1416a63caa74a9f0593e4798be3.tar.gz
drakx-9d98348b82e5c1416a63caa74a9f0593e4798be3.tar.bz2
drakx-9d98348b82e5c1416a63caa74a9f0593e4798be3.tar.xz
drakx-9d98348b82e5c1416a63caa74a9f0593e4798be3.zip
perlized
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/proxy.pm132
1 files changed, 63 insertions, 69 deletions
diff --git a/perl-install/proxy.pm b/perl-install/proxy.pm
index 5f4252ae7..163d67f26 100644
--- a/perl-install/proxy.pm
+++ b/perl-install/proxy.pm
@@ -7,100 +7,94 @@ use common qw(:common :system :file);
use log;
use c;
-my $config_file = "/usr/lib/wgetrc";
sub main {
my ($prefix, $in, $install) = @_;
my $proxy_cfg = {};
+ my $config_file; = "$prefix/usr/lib/wgetrc";
# grab current config
- open F, $config_file;
- while (<F>)
- {
- if (/http_proxy = (http:.*):(.*)/)
- {
- $proxy_cfg->{http_url} = $1;
- $proxy_cfg->{http_port} = $2;
- }
- if (/ftp_proxy = (ftp:.*):(.*)/)
- {
- $proxy_cfg->{ftp_url} = $1;
- $proxy_cfg->{ftp_port} = $2;
- }
- /http_user = (.*)/ and $proxy_cfg->{login} = $1;
- /http_passwd = (.*)/ and $proxy_cfg->{passwd} = $1;
- /http_passwd = (.*)/ and $proxy_cfg->{passwd2} = $1;
+ foreach (cat_($config_file)) {
+ ($proxy_cfg->{http_url}, $proxy_cfg->{http_port}) = /http_proxy = (http:.*):(.*)/;
+ ($proxy_cfg->{ftp_url}, $proxy_cfg->{ftp_port}) = /ftp_proxy = (ftp:.*):(.*)/;
+ ($proxy_cfg->{login}) = /http_user = (.*)/;
+ ($proxy_cfg->{passwd}) = /http_passwd = (.*)/;
+ ($proxy_cfg->{passwd2}) = /http_passwd = (.*)/;
}
begin:
$::isWizard = 1;
$::Wizard_no_previous = 1;
$in->ask_okcancel(_("Proxy configuration"),
_("Welcome to the proxy configuration utility.\n\nHere, you'll be able to set up your http and ftp proxies\nwith or without login and password\n"
- ), 1) or quit_global($in, 0);
-
-
+ ), 1);
+
# http proxy
- step_http_proxy:
+ step_http_proxy:
undef $::Wizard_no_previous;
$in->ask_from_entries_refH(_("Proxy configuration"),
_("Please fill in the http proxy informations"),
- [
- { label => _("URL"), val => \$proxy_cfg->{http_url} },
- { label => _("port"), val => \$proxy_cfg->{http_port} }
- ]
- ) or goto begin;
- if ($proxy_cfg->{http_url} && $proxy_cfg->{http_url} !~ /^http:/)
- {
- $in->ask_warn('', _("Url should begin with 'http:'"));
- goto step_http_proxy;
- }
- if ($proxy_cfg->{http_port} && $proxy_cfg->{http_port} !~ /^\d+$/)
- {
- $in->ask_warn('', _("The port part should be numeric"));
- goto step_http_proxy;
- }
+ [ { label => _("URL"), val => \$proxy_cfg->{http_url} },
+ { label => _("port"), val => \$proxy_cfg->{http_port} }
+ ],
+ complete => sub {
+ if($proxy_cfg->{http_url} && $proxy_cfg->{http_url} !~ /^http:/) {
+ $in->ask_warn('', _("Url should begin with 'http:'"));
+ return (1,0);
+ }
+ if ($proxy_cfg->{http_port} && $proxy_cfg->{http_port} !~ /^\d+$/) {
+ $in->ask_warn('', _("The port part should be numeric"));
+ return (1,1);
+ }
+ 0;
+ }
+ ) or goto begin;
+
# ftp proxy
step_ftp_proxy:
$in->ask_from_entries_refH(_("Proxy configuration"),
_("Please fill in the ftp proxy informations"),
- [
- { label => _("URL"), val => \$proxy_cfg->{ftp_url} },
- { label => _("port"), val => \$proxy_cfg->{ftp_port} }
- ]
- ) or goto step_http_proxy;
- if ($proxy_cfg->{ftp_url} && $proxy_cfg->{ftp_url} !~ /^ftp:/)
- {
- $in->ask_warn('', _("Url should begin with 'ftp:'"));
- goto step_ftp_proxy;
- }
- if ($proxy_cfg->{ftp_port} && $proxy_cfg->{ftp_port} !~ /^\d+$/)
- {
- $in->ask_warn('', _("The port part should be numeric"));
- goto step_ftp_proxy;
- }
+ [ { label => _("URL"), val => \$proxy_cfg->{ftp_url} },
+ { label => _("port"), val => \$proxy_cfg->{ftp_port} }
+ ],
+ complete => sub {
+ if ($proxy_cfg->{ftp_url} && $proxy_cfg->{ftp_url} !~ /^ftp:/) {
+ $in->ask_warn('', _("Url should begin with 'ftp:'"));
+ return (1,0);
+ }
+ if ($proxy_cfg->{ftp_port} && $proxy_cfg->{ftp_port} !~ /^\d+$/) {
+ $in->ask_warn('', _("The port part should be numeric"));
+ return (1,1);
+ }
+ 0;
+ }
+ ) or goto step_http_proxy;
+
# proxy login/passwd
step_login:
$in->ask_from_entries_refH(_("Proxy configuration"),
_("Please enter proxy login and password, if any.\nLeave it blank if you don't want login/passwd"),
- [
- { label => _("login"), val => \$proxy_cfg->{login} },
- { label => _("password"), val => \$proxy_cfg->{passwd}, hidden => 1 },
- { label => _("re-type password"), val => \$proxy_cfg->{passwd2}, hidden => 1 }
- ]
- ) or goto step_ftp_proxy;
- if ($proxy_cfg->{passwd} ne $proxy_cfg->{passwd2})
- {
- $in->ask_warn('', _("The passwords don't match. Try again!"));
- goto step_login;
- }
+ [ { label => _("login"), val => \$proxy_cfg->{login} },
+ { label => _("password"), val => \$proxy_cfg->{passwd}, hidden => 1 },
+ { label => _("re-type password"), val => \$proxy_cfg->{passwd2}, hidden => 1 }
+ ],
+ complete => sub {
+ if ($proxy_cfg->{passwd} ne $proxy_cfg->{passwd2}) {
+ $in->ask_warn('', _("The passwords don't match. Try again!"));
+ return(1,1);
+ }
+ 0;
+ }
+ ) or goto step_ftp_proxy;
# save config
- substInFile { s/^http_proxy.*\n//; $_ .= "http_proxy = $proxy_cfg->{http_url}:$proxy_cfg->{http_port}\n" if eof } $config_file;
- substInFile { s/^ftp_proxy.*\n//; $_ .= "ftp_proxy = $proxy_cfg->{ftp_url}:$proxy_cfg->{ftp_port}\n" if eof } $config_file;
- if ($proxy_cfg->{login})
- {
- substInFile { s/^http_user.*\n//; $_ .= "http_user = $proxy_cfg->{login}\n" if eof } $config_file;
- substInFile { s/^http_passwd.*\n//; $_ .= "http_passwd = $proxy_cfg->{passwd}\n" if eof } $config_file;
- }
+ substInFile {
+ s/^(http|ftp)_proxy.*\n//;
+ eof and $_ .= "http_proxy = $proxy_cfg->{http_url}:$proxy_cfg->{http_port}
+ftp_proxy = $proxy_cfg->{ftp_url}:$proxy_cfg->{ftp_port}\n";
+ } $config_file;
+ $proxy_cfg->{login} and substInFile {
+ s/^http_(user|passwd).*\n//;
+ eof and $_ .= "http_user = $proxy_cfg->{login}
+http_passwd = $proxy_cfg->{passwd}\n" } $config_file;
log::l("[drakproxy] Installation complete, exiting\n");
}