X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famrmtape.pl;fp=server-src%2Famrmtape.pl;h=2f9ec576cfab3517e7632407439a3138fab86ca0;hb=691567b16c13087b31ee4c2b6d038e57872fae82;hp=f7d37081a4c60ade7f8adc7651a4d0534d86f09c;hpb=cc7d7b45afc706099acf7ff2490ec5667d370651;p=debian%2Famanda diff --git a/server-src/amrmtape.pl b/server-src/amrmtape.pl index f7d3708..2f9ec57 100644 --- a/server-src/amrmtape.pl +++ b/server-src/amrmtape.pl @@ -2,9 +2,10 @@ # # Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -47,26 +48,6 @@ my $changer_name; my $keep_label; my $verbose = 1; my $help; -my $logdir; -my $log_file; -my $log_created = 0; - -sub die_handler { - if ($log_created == 1) { - unlink $log_file; - $log_created = 0; - } -} -$SIG{__DIE__} = \&die_handler; - -sub int_handler { - if ($log_created == 1) { - unlink $log_file; - $log_created = 0; - } - die "Interrupted\n"; -} -$SIG{INT} = \&int_handler; sub usage() { print <= $CFGERR_WARNINGS) { } Amanda::Util::finish_setup($RUNNING_AS_DUMPUSER); -$logdir = config_dir_relative(getconf($CNF_LOGDIR)); -$log_file = "$logdir/log"; - -if ($erase) { - # Check for log file existance - if (-e $log_file) { - `amcleanup -p $config_name`; - } - - if (-e $log_file) { - local *LOG; - open(LOG, $log_file); - my $info_line = ; - close LOG; - $info_line =~ /^INFO (.*) .* pid .*$/; - my $process_name = $1; - print "$process_name is running, or you must run amcleanup\n"; - exit 1; - } -} # amadmin may later try to load this and will die if it has errors # load it now to catch the problem sooner (before we might erase data) @@ -208,11 +169,12 @@ my $scrub_db = sub { $tapelist->write(); } - my $tmp_curinfo_file = "$AMANDA_TMPDIR/curinfo-amrmtape-" . time(); + my $tmp_curinfo_file = "$AMANDA_TMPDIR/curinfo-amrmtape-" . time() . "-" . $$; unless (open(AMADMIN, "$amadmin $config_name export |")) { die "Failed to execute $amadmin: $! $?"; } - open(CURINFO, ">$tmp_curinfo_file"); + open(CURINFO, ">$tmp_curinfo_file") or + die "Failed to open $tmp_curinfo_file for writing: $! $?"; sub info_line($) { print CURINFO "$_[0]"; @@ -294,11 +256,6 @@ my $scrub_db = sub { my $erase_volume = make_cb('erase_volume' => sub { if ($erase) { - $log_created = 1; - local *LOG; - open(LOG, ">$log_file"); - print LOG "INFO amrmtape amrmtape pid $$\n"; - close LOG; my $chg = Amanda::Changer->new($changer_name, tapelist => $tapelist); $chg->load( 'label' => $label, @@ -349,9 +306,4 @@ my $erase_volume = make_cb('erase_volume' => sub { $erase_volume->(); Amanda::MainLoop::run(); -if ($log_created == 1) { - unlink $log_file; - $log_created = 0; -} - Amanda::Util::finish_application();