diff options
author | Antoine Ginies <aginies@mandriva.com> | 2005-06-07 03:03:36 +0000 |
---|---|---|
committer | Antoine Ginies <aginies@mandriva.com> | 2005-06-07 03:03:36 +0000 |
commit | 74527ba08bc2e60d2c8e053547cff01b47c4d4bf (patch) | |
tree | 92e466565e5135875cef9f4da977a4b717622ff3 | |
parent | 41e41d55556734b96d32eace5001e69cf1fc94ab (diff) | |
download | drakwizard-74527ba08bc2e60d2c8e053547cff01b47c4d4bf.tar drakwizard-74527ba08bc2e60d2c8e053547cff01b47c4d4bf.tar.gz drakwizard-74527ba08bc2e60d2c8e053547cff01b47c4d4bf.tar.bz2 drakwizard-74527ba08bc2e60d2c8e053547cff01b47c4d4bf.tar.xz drakwizard-74527ba08bc2e60d2c8e053547cff01b47c4d4bf.zip |
add SErverName and port option
-rwxr-xr-x | ftp_wizard/Proftpd.pm | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/ftp_wizard/Proftpd.pm b/ftp_wizard/Proftpd.pm index f696a7de..d34ea43a 100755 --- a/ftp_wizard/Proftpd.pm +++ b/ftp_wizard/Proftpd.pm @@ -30,6 +30,11 @@ use MDK::Wizard::Wizcommon; my $wiz = MDK::Wizard::Wizcommon->new; +my $file = "/etc/proftpd.conf"; + +my ($servername) = cat_($file) =~ /ServerName\s+(\S*.*)/; +my ($ftp_port) = cat_($file) =~ /Port\s+(\d+)/; + my $o = { name => N("FTP wizard"), var => { @@ -42,6 +47,8 @@ my $o = { wiz_default_root => '', wiz_ftp_resume => '', wiz_ftp_fxp => '', + wiz_server_name => '', + wiz_port => '', }, needed_rpm => [ 'proftpd' ], defaultimage => "$ENV{__WIZ_HOME__}ftp_wizard/images/FTP.png" @@ -90,28 +97,42 @@ $o->{pages} = { next => 'options' }, options => { - name => N("FTP Proftpd server options") . "\n\n" . N("Permit root login: allow root to log on FTP server.") . "\n" . N("Admin email: email address of the FTP administrator.") . "\n" . N("Chroot home user: users will only see their home directory.") . "\n\n" . N("Allow FTP resume: allow resume upload or download on FTP server.") . "\n" . N("Allow FXP: allow file transfer via another FTP."), + name => N("FTP Proftpd server options, step 1") . "\n\n" . N("Permit root login: allow root to log on FTP server.") . "\n" . N("Admin email: email address of the FTP administrator."), pre => sub { $o->{var}{wiz_root_login} ||= 0; - $o->{var}{wiz_default_root} ||= 1; - $o->{var}{wiz_ftp_resume} ||= 1; - $o->{var}{wiz_ftp_fxp} ||= 0; + $o->{var}{wiz_server_name} = $servername; }, data => [ - { label => N("Admin email:"), val => \$o->{var}{wiz_server_admin} }, + { label => N('Server name:'), val => \$o->{var}{wiz_server_name} }, + { label => N("Admin email:"), val => \$o->{var}{wiz_server_admin}, help => 'admin@guibland.com' }, { label => N("Permit root login:"), type => 'bool', val => \$o->{var}{wiz_root_login} }, - { label => N("Chroot home user:"), type => 'bool', val => \$o->{var}{wiz_default_root} }, - { label => N("Allow FTP resume:"), type => 'bool', val => \$o->{var}{wiz_ftp_resume} }, - { label => N("Allow FXP:"), type => 'bool', val => \$o->{var}{wiz_ftp_fxp} }, ], complete => sub { if (!any { /bash/ } cat_("/etc/shells")) { $::in->ask_warn(N("Error"), N("I can't find bash in list of shells! It seems you have modified it by hand! Please correct.")); return 1; - } else { return 0 } + } + if (!$o->{var}{wiz_server_name}) { $::in->ask_warn(N("Error"), N("Need a server name")); return 1; } }, - next => 'summary', + next => 'options_step2', }, + options_step2 => { + name => N('FTP server options, step 2') . "\n\n" . N("Chroot home user: users will only see their home directory.") . "\n" . N("Allow FTP resume: allow resume upload or download on FTP server.") . "\n" . N("Allow FXP: allow file transfer via another FTP."), + pre => sub { + $o->{var}{wiz_default_root} ||= 1; + $o->{var}{wiz_ftp_resume} ||= 1; + $o->{var}{wiz_ftp_fxp} ||= 0; + $o->{var}{wiz_port} = $ftp_port; + }, + data => [ + { label => N('FTP Port:'), val => \$o->{var}{wiz_port}, help => 'Default port is 21 for an FTP server' }, + { label => N("Chroot home user:"), type => 'bool', val => \$o->{var}{wiz_default_root} }, + { label => N("Allow FTP resume:"), type => 'bool', val => \$o->{var}{wiz_ftp_resume} }, + { label => N("Allow FXP:"), type => 'bool', val => \$o->{var}{wiz_ftp_fxp} }, + ], + complete => sub { if ($o->{var}{wiz_port} !~ /^\d+$/) { $::in->ask_warn(N('Error'), N('FTP Port should be a number.')); return 1; } }, + next => 'summary', + }, warning_dhcp => { name => N("Warning.") . "\n\n" . N("You are in DHCP, server may not work with your configuration."), ignore => 1, @@ -123,7 +144,7 @@ $o->{pages} = { next => 'config' }, summary => { - name => N("Configuring the FTP server") . "\n\n" . N("The wizard collected the following parameters needed to configure your FTP server") . "\n\n" . N("To accept those values, and configure your server, click the next button or use the back button to correct them"), + name => N("Configuring the FTP server") . "\n\n" . N("The wizard collected the following parameters needed to configure your FTP server") . "\n" . N("To accept those values, and configure your server, click the next button or use the back button to correct them"), pre => sub { $o->{var}{internal} = $o->{var}{wiz_ftp_internal} ? N("enabled") : N("disabled"); $o->{var}{external} = $o->{var}{wiz_ftp_external} ? N("enabled") : N("disabled"); @@ -133,9 +154,9 @@ $o->{pages} = { $o->{var}{fxp} = $o->{var}{wiz_ftp_fxp} ? N("enabled") : N("disabled"); }, data => [ + { label => N('FTP Port:'), fixed_val => \$o->{var}{wiz_port} }, { label => N("Intranet FTP server:"), fixed_val => \$o->{var}{internal} }, { label => N("Internet FTP server:"), fixed_val => \$o->{var}{external} }, - { label => N("Admin email"), fixed_val => \$o->{var}{wiz_server_admin} }, { label => N("Permit root Login"), fixed_val => \$o->{var}{rootlogin} }, { label => N("Chroot Home user"), fixed_val => \$o->{var}{defaultroot} }, { label => N("Allow FTP resume"), fixed_val => \$o->{var}{ftpresume} }, @@ -172,7 +193,6 @@ sub true { } sub get_dir { - my $file = "/etc/proftpd.conf"; die "no FTP configuration file found! warning." if !-f $file; local *NEW; open(NEW, "< $file") or die "error while opening $file: $!"; @@ -212,7 +232,6 @@ sub print_anonymous { sub change_options { my ($var, $var_in_conf) = @_; - my $file = "/etc/proftpd.conf"; my $status; if ($var == 1) { $status = "on" } else { $status = "off" } if (any { /^$var_in_conf/ } cat_($file)) { @@ -224,7 +243,6 @@ sub change_options { sub add_options { my ($var, $value) = @_; - my $file = "/etc/proftpd.conf"; if (any { /^$var/ } cat_($file)) { substInFile { s/$var.*/$var $value/ } $file; } else { @@ -237,7 +255,6 @@ sub do_it { $::testing and return; my $wiz_ftp_internal = $o->{var}{wiz_ftp_external} ? 1 : true $o->{var}{wiz_ftp_internal}; my $wiz_ftp_external = true $o->{var}{wiz_ftp_external}; - my $file = "/etc/proftpd.conf"; die "no FTP configuration file found! warning." if !-f $file; MDK::Common::cp_af($file, $file . ".orig"); my $allow; @@ -287,6 +304,9 @@ sub do_it { change_options($o->{var}{wiz_ftp_resume}, "AllowStoreRestart"); change_options($o->{var}{wiz_ftp_resume}, "AllowRetrieveRestart"); + substInFile { s/^ServerName.*/ServerName $o->{var}{wiz_server_name}/ } $file; + substInFile { s/^Port.*/Port $o->{var}{wiz_port}/ } $file; + my $data; if ($o->{var}{wiz_default_root} == 1) { $data = "DefaultRoot ~"; |