Imported Upstream version 3.3.1
[debian/amanda] / server-src / amcleanup.pl
index eb1730fc5540ea042d0e6dc5615c97584815fe18..915e72fe2a552cd398fc6b8e60b6198072cfcb47 100644 (file)
@@ -28,13 +28,15 @@ use Amanda::Paths;
 use Amanda::Constants;
 use Amanda::Process;
 use Amanda::Logfile;
-
+use Amanda::Holding;
+use Amanda::Debug qw( debug );
 my $kill_enable=0;
 my $process_alive=0;
 my $verbose=0;
+my $clean_holding=0;
 
 sub usage() {
-    print "Usage: amcleanup [-k] [-v] [-p] conf\n";
+    print "Usage: amcleanup [-k] [-v] [-p] [-r] conf\n";
     exit 1;
 }
 
@@ -42,11 +44,14 @@ Amanda::Util::setup_application("amcleanup", "server", $CONTEXT_CMDLINE);
 
 my $config_overrides = new_config_overrides($#ARGV+1);
 
+debug("Arguments: " . join(' ', @ARGV));
 Getopt::Long::Configure(qw(bundling));
 GetOptions(
+    'version' => \&Amanda::Util::version_opt,
     'k' => \$kill_enable,
     'p' => \$process_alive,
     'v' => \$verbose,
+    'r' => \$clean_holding,
     'help|usage' => \&usage,
     'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); },
 ) or usage();
@@ -73,7 +78,7 @@ my $logdir=config_dir_relative(getconf($CNF_LOGDIR));
 my $logfile = "$logdir/log";
 my $amreport="$sbindir/amreport";
 my $amtrmidx="$amlibexecdir/amtrmidx";
-my $amcleanupdisk="$amlibexecdir/amcleanupdisk";
+my $amcleanupdisk="$sbindir/amcleanupdisk";
 
 if ( ! -e "$CONFIG_DIR/$config_name" ) {
     die "Configuration directory '$CONFIG_DIR/$config_name' doesn't exist\n";
@@ -195,10 +200,11 @@ foreach my $pname ("amdump", "amflush") {
     }
 }
 
-if ($verbose) {
-    system $amcleanupdisk, "-v", $config_name;
-} else {
-    system $amcleanupdisk, $config_name;
-}
+my @amcleanupdisk;
+push @amcleanupdisk, $amcleanupdisk;
+push @amcleanupdisk, "-v" if $verbose;
+push @amcleanupdisk, "-r" if $clean_holding;
+push @amcleanupdisk, $config_name;
+system @amcleanupdisk;
 
 Amanda::Util::finish_application();