From a1098db4c5991b2e6c2c0f2c4fed6b6f96d1ff6c Mon Sep 17 00:00:00 2001
From: thomasmaurel <maurel@ebi.ac.uk>
Date: Thu, 8 Dec 2016 13:41:48 +0000
Subject: [PATCH] Updated script to work on both the EBI and Sanger MySQL
 servers

---
 misc-scripts/CopyDBoverServer.pl | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/misc-scripts/CopyDBoverServer.pl b/misc-scripts/CopyDBoverServer.pl
index eaa7c9e37a..60324fcdad 100755
--- a/misc-scripts/CopyDBoverServer.pl
+++ b/misc-scripts/CopyDBoverServer.pl
@@ -294,8 +294,8 @@ if ( defined($opt_skip_tables) ) {
   %skip_tables = map( { $_ => 1 } split( /,/, $opt_skip_tables ) );
 }
 
-if ( scalar( getpwuid($<) ) ne 'mysqlens' ) {
-  warn("You are not running this script as the 'mysqlens' user.\n");
+if ( scalar( getpwuid($<) ) ne 'ensmysql' and scalar( getpwuid($<) ) ne 'mysqlens' ) {
+  warn("You are not running this script as the 'ensmysql' user at the EBI or as the 'mysqlens' at Sanger.\n");
 }
 
 if (!defined($opt_user))
@@ -321,7 +321,11 @@ foreach my $key (@executables) {
   my $output = `which $key`;
   my $rc     = $? >> 8;
   
-  if($rc != 0) {
+  if ( !$opt_check && $key eq 'myisamchk' ) {
+      print( "Can not find 'myisamchk' " .
+      "but --nocheck was specified so skipping\n" ),;
+  }
+  elsif($rc != 0) {
     chomp $output;
     die(
       sprintf(
@@ -330,12 +334,6 @@ foreach my $key (@executables) {
       $key, $key
       ) );
   }
-  else {
-    if ( !$opt_check && $key eq 'myisamchk' ) {
-      print( "Can not find 'myisamchk' " .
-      "but --nocheck was specified so skipping\n" ),;
-    }
-  } 
 } ## end foreach my $key ( @executables...)
 
 my $run_hostaddr = hostname_to_ip(hostname());
@@ -603,7 +601,12 @@ foreach my $spec (@todo) {
   my $tmp_dir;
   if ( defined($opt_tmpdir) ) { $tmp_dir = $opt_tmpdir }
   else {
-    $tmp_dir = canonpath( catdir( $target_dir, updir(), 'tmp' ) );
+    if ((scalar( getpwuid($<) ) eq 'mysqlens')) {
+      $tmp_dir = canonpath( catdir( $target_dir, updir(), 'tmp' ));
+    }
+    elsif ((scalar( getpwuid($<) ) eq 'ensmysql')){
+       $tmp_dir = canonpath( catdir( $target_dir, updir(), 'temp' ));
+    }
   }
 
   printf( "SOURCE 'datadir' = '%s'\n", $source_dir );
-- 
GitLab