#!/bin/bash -e

# Script to copy new processed and aligned from the build server to the this
# server (gbdb server) This polls to determine if an alignment has been done
# since the last time files were downloaded.  Remote file access is by rsync.

set -e  # errors terminate
trap "echo Error: $(hostname) copy failed >&2; exit 1" ERR
exec </dev/null

# initialize
gbRoot=/genbank
cd $gbRoot
. $gbRoot/lib/gbCommon.sh
databases=$(gbGetDatabases etc/hgwbeta.dbs etc/rr.dbs)

# local location of /gbdb
gbdb=/export2/gbdb

# location of the genbank root and files on the remote build server
gbBuildServer=hgwdev
rsyncPort="rsh"
gbBuildRoot=/hive/data/outside/genbank

# Checking for an existing lock file, Silently exits if lock file exists
# and is less than one day old,  error if older.
gbCheckLock $gbRoot/var/copy/run/copy.lock

gbCopyStep -rsyncPort=$rsyncPort -gbdb=$gbdb $gbBuildServer $gbBuildRoot $databases

# we don't put put a completed message, as gbCopyStep does the checking.
