summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-02-24 12:03:26 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-02-24 12:03:26 +0000
commiteff330a22608c144895b467666ce9dc2a1fbb8a0 (patch)
tree3399140dadf868dc489305cfd030a6d542a3c82e /perl-install
parent3b50dc3878f716e3a8620ed8dc4beaef00758d8f (diff)
downloaddrakx-eff330a22608c144895b467666ce9dc2a1fbb8a0.tar
drakx-eff330a22608c144895b467666ce9dc2a1fbb8a0.tar.gz
drakx-eff330a22608c144895b467666ce9dc2a1fbb8a0.tar.bz2
drakx-eff330a22608c144895b467666ce9dc2a1fbb8a0.tar.xz
drakx-eff330a22608c144895b467666ce9dc2a1fbb8a0.zip
fix mail alert generation
- do not crash without any message in strict mode (wizcancel die miscatched) - make the generated script be 'use strict' and perl_checker compliant
Diffstat (limited to 'perl-install')
-rwxr-xr-xperl-install/standalone/logdrake39
1 files changed, 19 insertions, 20 deletions
diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake
index 36f2ebf51..5d5b9e73e 100755
--- a/perl-install/standalone/logdrake
+++ b/perl-install/standalone/logdrake
@@ -189,13 +189,16 @@ gtkadd($my_win->{window},
)) : (1, create_scrolled_window($log_text)),
if_(!$::isExplain, 0, gtkadd(gtkset_border_width(gtkset_layout(Gtk2::HButtonBox->new, 'end'), 5),
if_(!$::isFile, gtksignal_connect(new Gtk2::Button(N("Mail alert")),
- clicked => sub { eval { alert_config() };
- if ($@ =~ /wizcancel/) {
- $::Wizard_no_previous = 1;
- $::Wizard_no_cancel = 1;
- $::WizardWindow->destroy if defined $::WizardWindow;
- undef $::WizardWindow;
- } })),
+ clicked => sub {
+ eval { alert_config() };
+ if ($@ =~ /wizcancel/) {
+ $::Wizard_no_previous = 1;
+ $::Wizard_no_cancel = 1;
+ $::WizardWindow->destroy if defined $::WizardWindow;
+ undef $::WizardWindow;
+ }
+
+ })),
gtksignal_connect(new Gtk2::Button(N("Save")), clicked => \&save),
gtksignal_connect(new Gtk2::Button($::isEmbedded ? N("Cancel") : N("Quit")), clicked => \&quit)
)
@@ -378,7 +381,7 @@ sub alert_config {
my $cron = q(#!/usr/bin/perl
# generated by logdrake
use MDK::Common;
-my $r = "*** ". chomp_(`date`) . " ***\n";
+my $r = "*** " . chomp_(`date`) . " ***\n";
);
@@ -411,17 +414,16 @@ my $initdir = "/etc/init.d";
foreach my $serv (keys %$service) {
-e "$initdir/$serv" && push @installed_d, $serv;
}
-
+ my %services_to_check;
$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 => \${ $_ }, type => "bool", text => $service->{$_} } } @installed_d
+ [ map { { label => $_, val => \$services_to_check{$_}, type => "bool", text => $service->{$_} } } @installed_d
]) or goto begin;
$cron .= "#- check services\n";
- my $r;
- foreach (@installed_d) {
- $r .= "Service $_ ($service->{$_} is not running\n" unless -e "/var/lock/subsys/$_";
-# $cron .= "$r" if ${ $_ }; # take a look at this, don't know what is done here
+ foreach (keys %services_to_check) {
+ next unless $services_to_check{$_};
+ $cron .= "\$r .= \"Service $_ ($service->{$_} is not running)\\n\" unless -e \"/var/lock/subsys/$_\";\n";
}
step_load:
@@ -451,14 +453,11 @@ EOF
$cron .= q(#- report it
-$email = ) . "'$email';\n\n";
+my $email = ) . "'$email';\n\n";
- $cron .= q(
-local *F;
+ $cron .= q(local *F;
open F, '|/usr/sbin/sendmail -oi -t';
-
-print F
-q(Subject: logdrake Mail Alert
+print F q(Subject: logdrake Mail Alert
From: root@localhost
To: ), "$email\n";
print F $r;