diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2003-12-16 14:24:29 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2003-12-16 14:24:29 +0000 |
commit | 25e5e6983e3e18b7b469ccbe09179992c056f85a (patch) | |
tree | 18abbdb0097693898d66686c5037be963a0eaed4 /perl-install/standalone | |
parent | 8ffd39fcffe3826482e1af17c2cb31f2aa58d7c4 (diff) | |
download | drakx-backup-do-not-use-25e5e6983e3e18b7b469ccbe09179992c056f85a.tar drakx-backup-do-not-use-25e5e6983e3e18b7b469ccbe09179992c056f85a.tar.gz drakx-backup-do-not-use-25e5e6983e3e18b7b469ccbe09179992c056f85a.tar.bz2 drakx-backup-do-not-use-25e5e6983e3e18b7b469ccbe09179992c056f85a.tar.xz drakx-backup-do-not-use-25e5e6983e3e18b7b469ccbe09179992c056f85a.zip |
reuse new wizard framework
Diffstat (limited to 'perl-install/standalone')
-rwxr-xr-x | perl-install/standalone/logdrake | 123 |
1 files changed, 63 insertions, 60 deletions
diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake index 874605ac2..41766d3cb 100755 --- a/perl-install/standalone/logdrake +++ b/perl-install/standalone/logdrake @@ -370,34 +370,11 @@ sub log_output { #------------------------------------------------------------- sub alert_config() { - - $::isWizard = 1; my $conffile = "/etc/sysconfig/mail_alert"; - $::Wizard_pix_up = "wiz_logdrake.png"; # FIXME - $::Wizard_title = N("Mail alert"); my %options = getVarsFromSh($conffile); $options{LOAD} ||= 3; $options{MAIL} ||= "root"; - my $cron = q(#!/usr/bin/perl -# generated by logdrake -use MDK::Common; -my $r; -my %options = getVarsFromSh("/etc/sysconfig/mail_alert"); -); - - my $initdir = "/etc/init.d"; - - begin: - $::Wizard_finished = 0; - $::Wizard_no_previous = 1; - $in->ask_okcancel(N("Mail alert configuration"), - N("Welcome to the mail configuration utility.\n\nHere, you'll be able to set up the alert system.\n"), - 1) or quit(); - - step_service: - undef $::Wizard_no_previous; - undef $::Wizard_finished; my $service = { httpd => N("Apache World Wide Web Server"), bind => N("Domain Name Resolver"), @@ -408,54 +385,82 @@ my %options = getVarsFromSh("/etc/sysconfig/mail_alert"); webmin => N("Webmin Service"), xinetd => N("Xinetd Service") }; - my @installed_d = grep { -e "$initdir/$_" } sort keys %$service; + my @installed_d = grep { -e "/etc/init.d/$_" } sort keys %$service; my %services_to_check = map { $_ => 1 } split(':', $options{SERVICES}); - $in->ask_from(N("service setting"), - N("You will receive an alert if one of the selected services is no longer running"), - [ map { { label => $_, val => \$services_to_check{$_}, type => "bool", text => $service->{$_} } } @installed_d - ]) or goto begin; + + use wizards; + my $w = wizards->new; + my $wiz = { + defaultimage => "wiz_logdrake.png", + name => N("Mail alert"), + pages => { + welcome => { + name => N("Mail alert configuration") . "\n\n" . + N("Welcome to the mail configuration utility.\n\nHere, you'll be able to set up the alert system.\n"), + no_back => 1, + next => 'services' + }, + services => { + name => N("Services settings") . "\n\n" . + N("You will receive an alert if one of the selected services is no longer running"), + data => [ map { { label => $_, val => \$services_to_check{$_}, + type => "bool", text => $service->{$_} } } @installed_d ], + next => "load", + }, + load => { + #PO- Here "load" is a noun; that is load refers to the system/CPU) load + name => N("Load setting") . "\n\n" . + N("You will receive an alert if the load is higher than this value"), + data => [ { label => N("_: load here is a noun, the load of the system\nLoad"), + val => \$options{LOAD}, type => 'range', min => 1, max => 50 } ], + next => "email", + }, + email => { + name => N("Alert configuration") . "\n\n" . + N("Please enter your email address below "), + data => [ + { label => "Email", val => \$options{MAIL}, + }, + ], + complete => sub { + if ($options{MAIL} !~ /[\w.-]*\@[\w.-]/) { + err_dialog(N("Wrong email"), N("\"%s\" is not a valid email!", $options{MAIL})); + return 1; + } + }, + next => "end", + }, + end => { + name => N("Congratulations") . "\n\n" . N("The wizard successfully configured the mail alert."), + end => 1, + no_back => 1, + next => 0 + }, + }, + }; + $w->process($wiz, $in); + + $options{SERVICES} = join ':', grep { $services_to_check{$_} } sort keys %services_to_check; use Data::Dumper; - $cron .= q(#- check services + output_with_perm "/etc/cron.hourly/logdrake_service", 0755, q(#!/usr/bin/perl +# generated by logdrake +use MDK::Common; +my $r; +my %options = getVarsFromSh("/etc/sysconfig/mail_alert"); + +#- check services my ) . Data::Dumper->Dump([ $service ], [qw(*services)]) . q( foreach (split(':', $options{SERVICES})) { next unless $services{$_}; $r .= "Service $_ ($services{$_} is not running)\\n" unless -e "/var/lock/subsys/$_"; } -); - $options{SERVICES} = join ':', grep { $services_to_check{$_} } sort keys %services_to_check; - - step_load: - undef $::Wizard_finished; -#PO- Here "load" is a noun; that is load refers to the system/CPU) load - $in->ask_from(N("Load setting"), - N("You will receive an alert if the load is higher than this value"), - [ - - { label => N("_: load here is a noun, the load of the system\nLoad"), val => \$options{LOAD}, type => 'range', min => 1, max => 50 }, - ]) or goto step_service; - $cron .= q( #- load my ($load) = split ' ', first(cat_("/proc/loadavg")); $r .= "Load is huge: $load\n" if $load > $options{LOAD}; -); - - step_output: -# $::Wizard_no_previous = 1; - $::Wizard_finished = 1; - $in->ask_from(N("alert configuration"), - N("Please enter your email address below "), - [ - { label => "" }, - { label => "Email", val => \$options{MAIL} }, - ]) or goto step_load; - if ($options{MAIL} !~ /[\w.-]*\@[\w.-]/) { - err_dialog(N("Wrong email"), N("\"%s\" is not a valid email!")); - goto step_output; - } - $cron .= q(#- report it +#- report it if ($r) { my $F; open $F, '|/usr/sbin/sendmail -oi -t'; @@ -468,10 +473,8 @@ To: $options{MAIL} } # EOF); - output_with_perm "/etc/cron.hourly/logdrake_service", 0755, $cron; setVarsInSh($conffile, \%options); - undef $::isWizard; if (defined $::WizardWindow) { $::WizardWindow->destroy; undef $::WizardWindow; |