If a Sync-job crash it should stop trying to sync until somebody checked it.
moving the cron EVN to the code is necessary to prevent at updating that the file will be over written.
rename delete_corn to delete_configs
the function also deletes the config entry
Signed-off-by: Wolfgang Link <w.link@proxmox.com>
rm -rf debian
mkdir debian
install -d debian/var/lib/pve-zsync
rm -rf debian
mkdir debian
install -d debian/var/lib/pve-zsync
- install -d debian/etc/cron.d/
- echo "SHELL=/bin/sh" >> debian/etc/cron.d/pve-zsync
- echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> debian/etc/cron.d/pve-zsync
make DESTDIR=${CURDIR}/debian install
install -d -m 0755 debian/DEBIAN
sed -e s/@@VERSION@@/${VERSION}/ -e s/@@PKGRELEASE@@/${PKGREL}/ -e s/@@ARCH@@/${ARCH}/ <control.in >debian/DEBIAN/control
make DESTDIR=${CURDIR}/debian install
install -d -m 0755 debian/DEBIAN
sed -e s/@@VERSION@@/${VERSION}/ -e s/@@PKGRELEASE@@/${PKGREL}/ -e s/@@ARCH@@/${ARCH}/ <control.in >debian/DEBIAN/control
my $source = parse_target($param->{source});
my $source = parse_target($param->{source});
- my $delete_cron = sub {
+ my $delete_configs = sub {
my ($path, $name, $cfg) = @_;
die "Source does not exist!\n" unless $cfg->{$path} ;
die "Sync Name does not exist!\n" unless $cfg->{$path}->{$name};
my ($path, $name, $cfg) = @_;
die "Source does not exist!\n" unless $cfg->{$path} ;
die "Sync Name does not exist!\n" unless $cfg->{$path}->{$name};
- my $source .= $cfg->{$path}->{$name}->{source_ip} ? "$cfg->{$path}->{$name}->{source_ip}:" : '';
+ my $source = $cfg->{$path}->{$name}->{source_ip} ? "$cfg->{$path}->{$name}->{source_ip}:" : '';
- $source .= $cfg->{$path}->{$name}->{source_pool};
+ $source .= $cfg->{$path}->{$name}->{source_pool} if $cfg->{$path}->{$name}->{source_pool};
$source .= $cfg->{$path}->{$name}->{source_path} ? $cfg->{$path}->{$name}->{source_path} :'';
my $dest = $cfg->{$path}->{$name}->{dest_ip} ? $cfg->{$path}->{$name}->{dest_ip} :"";
$source .= $cfg->{$path}->{$name}->{source_path} ? $cfg->{$path}->{$name}->{source_path} :'';
my $dest = $cfg->{$path}->{$name}->{dest_ip} ? $cfg->{$path}->{$name}->{dest_ip} :"";
- $dest .= $cfg->{$path}->{$name}->{dest_pool};
+ $dest .= $cfg->{$path}->{$name}->{dest_pool} if $cfg->{$path}->{$name}->{dest_pool};
$dest .= $cfg->{$path}->{$name}->{dest_path} ? $cfg->{$path}->{$name}->{dest_path} :'';
delete $cfg->{$path}->{$name};
$dest .= $cfg->{$path}->{$name}->{dest_path} ? $cfg->{$path}->{$name}->{dest_path} :'';
delete $cfg->{$path}->{$name};
if ($source->{vmid}) {
my $path = $source->{vmid};
if ($source->{vmid}) {
my $path = $source->{vmid};
- &$delete_cron($path, $name, $cfg)
+ &$delete_configs($path, $name, $cfg)
} else {
my $path = $source->{pool};
$path .= $source->{path} if $source->{path};
} else {
my $path = $source->{pool};
$path .= $source->{path} if $source->{path};
- &$delete_cron($path, $name, $cfg);
+ &$delete_configs($path, $name, $cfg);
$conf_name = $source->{vmid} if $source->{vmid};
$cfg->{$conf_name}->{$name}->{status} = "error";
write_to_config($cfg);
$conf_name = $source->{vmid} if $source->{vmid};
$cfg->{$conf_name}->{$name}->{status} = "error";
write_to_config($cfg);
+ my $source_target = $source->{ip} ? $source->{ip}.":" : '';
+ $source_target .= $source->{vmid} ? $source->{vmid} : $source->{abs_path};
+ cron_del($source_target, $dest->{abs_path}, $name);
sub cron_add {
my ($vm) = @_;
sub cron_add {
my ($vm) = @_;
+ my $text ="";
+
+ unless(-e $CRONJOBS){
+ $text .= 'SHELL=/bin/sh'."\n";
+ $text .= 'PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'."\n ";
+ }
+
open(my $fh, '>>', "$CRONJOBS")
or die "Could not open file: $!\n";
foreach my $name (keys%{$vm}){
open(my $fh, '>>', "$CRONJOBS")
or die "Could not open file: $!\n";
foreach my $name (keys%{$vm}){
- my $text = "*/$vm->{$name}->{interval} * * * * root ";
+ $text .= "*/$vm->{$name}->{interval} * * * * root ";
$text .= "$PATH$PROGNAME sync";
$text .= " -source ";
if ($vm->{$name}->{vmid}) {
$text .= "$PATH$PROGNAME sync";
$text .= " -source ";
if ($vm->{$name}->{vmid}) {