Subversion Repositories sysadmin_scripts

Rev

Rev 30 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

%config = (
   # location where directories are put by end users   
   'local root dir' => '/home/dallas_active_projects/ready_to_archive',
   # location where directories are moved when job is completed
   'local trash dir' => '/home/archiveDirectories/Trash',
   # location where directories are moved while being transferred
   'local staging area' => '/home/archiveDirectories/Staging',

   # target server name/ip. Must be accessible via ssh with no password
   'target server' => 'davinci',
   # location on target server where directories are placed while copying
   'target staging area' => '/home/samba/archives/ready_to_archive',
   # location on target server where directories are finally put
   'target final directory' => '/home/samba/archives/MC',

   # suffix of md5 of directories
   'md5 suffix' => 'md5sum',
   # suffix of filename to create showing actions
   'log suffix' => 'log',
   # suffix of error log
   'error suffix' => 'err',
   # how long a directory must be undisturbed before it is ready to work on
   'quiesent seconds' => 60*5, # five minutes
   # how long to leave stuff in the trash directory. 0 indicates never do it.
   'trash cleanup' => 86400*7, # 7 days
   # anoymous subroutine to do any final processing on remote machine
   'final procedure' =>
      sub {
         my ( $remoteServer, $remoteStaging, $remoteTarget, $directory ) = @_;
         my $target = substr( $directory, 0, 2 );
         $target = "$remoteTarget/MC_Patient_20$target/";
         my ($message, $error ) = &runRemoteCommand( $remoteServer, "[ ! -d $target ] && mkdir -p $target" );
         if ( $error == 0 ) {
            my $command = "mv '$remoteStaging/$directory' '$target'";
            $command = "ssh $remoteServer " . '"' . $command . '"';
            my $message = qx/$command/;
            &logit( $directory, $error == 0 ? $config{ 'log suffix' } : $config{ 'error suffix' }, $message );
         } else {
            &logit( $directory, $config{ 'error suffix' }, $message );
         }
      } # anonymous sub
);