#!/bin/bash

# (c) Sean Parkin 2010/01/18
# This just creates a directory with all of the files from the X8 Proteum needed 
# to finish a refinement on a different computer, tarballs it and then starts up
# a secure copy job. Here is what it does:

# 1) Descend directory tree one level from /work, get the path to that directory, 
#    put that in string variable 'dir' then go back up to the /work directory.
# 2) Replace string variable 'dir' with the last 6 characters in 'dir'.
# 3) Make a new directory called 'dir', and copy necessary files into it.
# 4) Create a string variable 'tarball' from 'dir' + '.tar'
# 5) Create tarball (flag j tells it to use bzip2).
# 6) Secure copy tarball to some other computer.

cd ../
dir=`pwd`
cd work

dir=${dir:length-6}

mkdir $dir
cp *.abs $dir/.
cp *.hkl $dir/.
cp *.pcf $dir/.
cp *.prp $dir/.
cp *.res $dir/.
cp *_0m._ls $dir/.

tarball=$dir.tar.bz2

tar -cjf $tarball $dir

scp $tarball user@computer:/path/to/directory/.

