summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStew Benedict <stewb@mandriva.org>2004-02-10 00:09:49 +0000
committerStew Benedict <stewb@mandriva.org>2004-02-10 00:09:49 +0000
commit63c47ccccde0395b8df118ac93b65ccb258ecea0 (patch)
tree9e745e8f9f5cda4fc813484454e231a0dc98c349
parent544c56fbc59b4cd7d3a24179c24a3ed9a944227d (diff)
downloaddrakx-63c47ccccde0395b8df118ac93b65ccb258ecea0.tar
drakx-63c47ccccde0395b8df118ac93b65ccb258ecea0.tar.gz
drakx-63c47ccccde0395b8df118ac93b65ccb258ecea0.tar.bz2
drakx-63c47ccccde0395b8df118ac93b65ccb258ecea0.tar.xz
drakx-63c47ccccde0395b8df118ac93b65ccb258ecea0.zip
Fix failure to disable user cron job. Code reduction.
-rwxr-xr-xperl-install/standalone/drakbackup53
1 files changed, 18 insertions, 35 deletions
diff --git a/perl-install/standalone/drakbackup b/perl-install/standalone/drakbackup
index ca29cc8d9..bd150e95b 100755
--- a/perl-install/standalone/drakbackup
+++ b/perl-install/standalone/drakbackup
@@ -595,55 +595,38 @@ sub read_cron_files() {
}
sub save_cron_files() {
- my $entry_changed = 0;
my $tmpcron = "$ENV{HOME}/tmp/crontab.tmp";
if ($nonroot_user && $when_space ne "custom" && $when_space ne '' && $backup_daemon) {
show_warning("w", N("Interval cron not available as non-root"));
$backup_daemon = 0;
return 1;
- }
- my @cron_file = ("#!/bin/sh\n", "export USER=root\n", "/usr/sbin/drakbackup --daemon > /dev/null 2>&1\n");
-
- if ($backup_daemon) {
- if ($when_space ne "custom") {
- output_p("/etc/cron.$when_space/drakbackup", @cron_file);
- system("chmod +x /etc/cron.$when_space/drakbackup");
} else {
- my $newdetail = join(" ", $time_string, $exec_string, "\n");
- system("crontab -l | tail +4 > $tmpcron");
- my @cronlines = cat_($tmpcron);
- my $index = 0;
- foreach (@cronlines) {
- if (/$exec_string/) {
- $cronlines[$index] = $newdetail;
- $entry_changed = 1;
- }
- $index++;
- }
- push(@cronlines, $newdetail) if $entry_changed == 0;
- output($tmpcron, @cronlines);
- system("crontab $tmpcron");
- unlink($tmpcron);
- }
- } elsif (!$nonroot_user) {
foreach (qw(hourly daily weekly monthly)) {
-f "/etc/cron.$_/drakbackup" and rm_rf("/etc/cron.$_/drakbackup");
}
+ }
+ my @cron_file = ("#!/bin/sh\n", "export USER=root\n", "/usr/sbin/drakbackup --daemon > /dev/null 2>&1\n");
+
+ if ($when_space ne "custom" && $when_space ne '' && $backup_daemon) {
+ output_p("/etc/cron.$when_space/drakbackup", @cron_file);
+ system("chmod +x /etc/cron.$when_space/drakbackup");
+ }
+ if ($when_space eq "custom" || !$backup_daemon) {
+ my $newdetail = join(" ", $time_string, $exec_string, "\n") if $backup_daemon;
system("crontab -l | tail +4 > $tmpcron");
my @cronlines = cat_($tmpcron);
- if (any { /$exec_string/ } @cronlines) {
- my $index = 0;
- foreach (@cronlines) {
- if (/$exec_string/) {
- splice(@cronlines, $index, 1);
- }
- $index++;
+ my $index = 0;
+ foreach (@cronlines) {
+ if (/$exec_string/) {
+ splice(@cronlines, $index, 1);
}
- output($tmpcron, @cronlines);
- system("crontab $tmpcron");
- unlink($tmpcron);
+ $index++
}
+ push(@cronlines, $newdetail) if $backup_daemon;
+ output($tmpcron, @cronlines);
+ system("crontab $tmpcron");
+ unlink($tmpcron);
}
}