#!/usr/bin/perl
# weekly-xtcopy.pl
# this script is called by weekly-reports.pl
# it copies the ciao and earthscape extracts to a separate directory

while ($ARGV[0]) {
  if ($ARGV[0] eq '-k') {
    $opt_k=1;
    shift;
  } elsif ($ARGV[0] =~ /^\d\d\d\d\d\d\d\d$/) {
    $date=$ARGV[0];
    shift;
  } else {
    die "usage: weekly-xtcopy.pl YYYYMMDD [-k]

-k     keep existing scratch files, if any\n";
  }
}

$XTDIR='/www/data/httpd/log/xt';
$DLCIN='/www/data/httpd/log/xt/wwwc/sec/dlc';
$DLCOUT='/wwwc/data/dlc/log/scratch';
system("rm $DLCOUT/*") unless $opt_k;

for $proj ('ciao', 'earthscape') {
  # copy virtual host extract files to scratch area
  system("cp $XTDIR/$proj/httpd.access.$date.gz $DLCOUT/$proj.$date.gz");

  # copy wwwc extract files to scratch area
  system("cp $DLCIN/$proj/httpd.access.$date.gz $DLCOUT/${proj}S.$date.gz");
}
