--- foxridge-archiver/archiver.pl 2005/09/23 17:16:17 1.6 +++ foxridge-archiver/archiver.pl 2017/03/16 17:00:43 1.9 @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl -w +#!/usr/bin/perl -w use strict; @@ -16,7 +16,7 @@ $|=1; # # program version -my $version = "0.7.1 (ROC 23.9.2005)"; +my $version = "0.7.3 (ROC 10.9.2008)"; # short help my $help = "MPIWG archiver $version @@ -25,6 +25,7 @@ options: -debug show debugging info -premigrate don't delete archived files -force archive even if already archived + -replace rewrite index file "; # read command line parameters @@ -40,6 +41,9 @@ $debug = (exists $$args{'debug'}) ? $$ar # force archiving my $force_archive = (exists $$args{'force'}) ? $$args{'force'} : 0; +# rewrite index file +my $rewrite_index = (exists $$args{'replace'}) ? $$args{'replace'} : 0; + # rewrite XML file (necessary for archive date!) my $fix_xml = 1; my $xml_changed = 0; @@ -355,7 +359,7 @@ sub delete_all_files { logger('START', "archiver $version at $archdate"); # make shure the right user is running this program -my $user = getlogin; +my $user = getlogin || getpwuid($<); if (($user ne "archive")&&($user ne "root")) { logger("WARNING", "you ($user) should be archive or root user to run this program!"); } @@ -372,7 +376,11 @@ if (-f "$docdir/.archived") { } # use metacheck first -if (open CHECK, "$checkprog -add-files $docdir |") { +my $check_opts="-add-files"; +if ($rewrite_index) { + $check_opts = "-replace"; +} +if (open CHECK, "$checkprog $check_opts $docdir |") { my @errors; my $msg; while () {