#!/bin/sh

#check input
if [ $# -eq 0 ] || [ $# -eq 1 ] 
then 
	echo "Usage:$0 <vm_name>.pvm <rsync_link>"
	exit 1
fi

echo Processing file ${1}

#archive the VM
archiveOk=`tar -cjf vm.tbz2 ${1}`

echo "bzip2 returned ${archiveOk}".

#getting md5 sum
md5 vm.tbz2 > vm.md5

echo "uploading MD5 sum and vm.tbz2 to "$2
rsync vm.md5 ${2}
rsync vm.tbz2 ${2}
echo "Uploading complete."

