summaryrefslogtreecommitdiffstats
path: root/draksnapshot-config
diff options
context:
space:
mode:
authortv <tv@99302b65-d5f7-0310-b3dd-f8cd6f4e3d94>2008-09-26 15:16:29 +0000
committertv <tv@99302b65-d5f7-0310-b3dd-f8cd6f4e3d94>2008-09-26 15:16:29 +0000
commit72d295a29deb7c5d95a70d2853748af05a36e743 (patch)
treeb66ca9de8276af29eba273ac904db7ef030b6d65 /draksnapshot-config
parent9a15705aa295cbaeaf07cf092b2ad7bb43af2a37 (diff)
downloaddraksnapshot-72d295a29deb7c5d95a70d2853748af05a36e743.tar
draksnapshot-72d295a29deb7c5d95a70d2853748af05a36e743.tar.gz
draksnapshot-72d295a29deb7c5d95a70d2853748af05a36e743.tar.bz2
draksnapshot-72d295a29deb7c5d95a70d2853748af05a36e743.tar.xz
draksnapshot-72d295a29deb7c5d95a70d2853748af05a36e743.zip
generate anacron friendly cron files (#43297)
git-svn-id: http://svn.mandriva.com/svn/soft/draksnapshot/trunk@246741 99302b65-d5f7-0310-b3dd-f8cd6f4e3d94
Diffstat (limited to 'draksnapshot-config')
-rwxr-xr-xdraksnapshot-config45
1 files changed, 18 insertions, 27 deletions
diff --git a/draksnapshot-config b/draksnapshot-config
index 3eaf7d8..5b93fc3 100755
--- a/draksnapshot-config
+++ b/draksnapshot-config
@@ -301,35 +301,26 @@ sub save_keyword {
sub generate_cron_entry() {
- my %minutes = (
- 'hourly' => 0,
- 'daily' => 50,
- 'weekly' => 40,
- 'monthly' => 30,
- );
+ # handle upgrading from old scheme to new scheme:
+ unlink("$::prefix/etc/cron.d/rsnapshot");
- my $cron_file = "$::prefix/etc/cron.d/rsnapshot";
+ my $cron_file = "$::prefix/etc/cron.\%s/rsnapshot";
- output_with_perm($cron_file, 0644,
- qq(# WARNING: This file is autogenerated from /etc/rsnapshot.conf.
+ my @current_conf = cat_($config_file);
+
+ foreach my $type (qw(hourly daily weekly monthly)) {
+ my $current_setting = grep { /^interval\s$type/ } @current_conf;
+ if (my ($interval) = $current_setting = ~ /^interval\s*$type\s*(\S*)/) {
+ my $file = sprintf($cron_file, $type);
+ output_with_perm($file, 0755,
+ qq(# WARNING: This file is autogenerated from /etc/rsnapshot.conf.
# WARNING: Please alter /etc/rsnapshot.conf instead of $cron_file
+# Then rerun draksnapshot-config
#
-# $cron_file: crontab fragment for rsnapshot
-
-),
- (map {
- if (my ($type, $interval) = /^interval\s*(\S*)\s*(\S*)/) {
- # crontab: minute hour day_month month day_of_week user command
- join("\t",
- $minutes{$type},
- ($type eq 'hourly' ? "*/" . 24/$interval : 4),
- ($type eq 'monthly' ? 1 : '*'),
- '*' ,
- ($type eq 'weekly' ? 6 : '*'),
- 'root',
- "/usr/bin/rsnapshot $type"
- ), "\n";
- }
- } grep { /^interval\s/ } cat_($config_file)),
- );
+# $file: crontab fragment for rsnapshot
+
+/usr/bin/rsnapshot $type
+));
+ }
+ }
}