X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_archiveHost;h=ed481a785a6256a28e52e3a26fe354a0ca512678;hp=4bad6c68d9a932bbdb2eaf20cbcaf7578853a5d4;hb=17dcbbebb871212f90b81bb97f8d1feb528bdc43;hpb=2a48c566d7648f26c5a81f24de23be5e0edb05b2;ds=sidebyside diff --git a/bin/BackupPC_archiveHost b/bin/BackupPC_archiveHost index 4bad6c6..ed481a7 100755 --- a/bin/BackupPC_archiveHost +++ b/bin/BackupPC_archiveHost @@ -88,6 +88,22 @@ my $mesg = "Writing tar archive for host $host, backup #$bkupNum"; # $share = $bpc->shellEscape($share); $host = $bpc->shellEscape($host); + +# +# We prefer to use /bin/csh because the exit status of a pipeline +# is non-zero if any command is non zero. In contrast, /bin/sh +# and /bin/bash use the convention that the exit status is just +# the exit status of the last command of the pipeline. +# +my @shell; +if ( -x "/bin/csh" ) { + @shell = ("/bin/csh", "-cf"); +} elsif ( -x "/bin/sh" ) { + @shell = ("/bin/sh", "-c"); +} else { + print("Error: Can't find executable /bin/csh or /bin/sh\n"); + exit(1); +} my $cmd = "$tarCreate -t -h $host -n $bkupNum -s $share . "; $cmd .= "| $compPath " if ( $compPath ne "cat" && $compPath ne "" ); if ( -b $outLoc || -c $outLoc || -f $outLoc ) { @@ -115,9 +131,9 @@ print("$mesg\n"); # # Run the command # -my $ret = system($cmd); +my $ret = system(@shell, $cmd); if ( $ret ) { - print("Executing: $cmd\n"); + print("Executing: @shell -cf $cmd\n"); print("Error: $tarCreate, compress or split failed\n"); exit(1); } @@ -129,7 +145,7 @@ if ( $ret ) { if ( -d $outLoc && -x $parPath ) { if ( $parfile != 0 ) { print("Running $parPath to create parity files\n"); - my $parCmd = "$parPath c -r$parfile $outLoc/$host.$bkupNum.tar$fileExt.par2 $outLoc/$host.$bkupNum.tar$fileExt.*"; + my $parCmd = "$parPath c -r$parfile $outLoc/$host.$bkupNum.tar$fileExt.par2 $outLoc/$host.$bkupNum.tar$fileExt*"; $ret = system($parCmd); if ( $ret ) { print("Executing: $parCmd\n");