X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=grid%2Fcommon.sh;h=62205e72135b0eb9105d7d03fcb2d12521dc91d0;hb=fae205f8ac8ecaa3272d59d7e3d2995a37ded542;hp=c466050077c53d5b93f20bc216fdbd292d367084;hpb=1f5bb620cbb7768762c16914775fa7412b431c5b;p=clitk.git diff --git a/grid/common.sh b/grid/common.sh index c466050..62205e7 100644 --- a/grid/common.sh +++ b/grid/common.sh @@ -27,16 +27,35 @@ test "${answer}" == "n" && return 1 check_user "${prompt}" } +# checks if the lfn file exists function file_exists { lfnfile="${1:?"provide lfn to file"}" lfc-ls ${lfnfile} 2>&1 > /dev/null } +# upload file to grid storage element +# source can be a relative or an absolute path to the source file +# dest must be the lfn to the target **file** (not the directory) +# if dest already exists, it prompts the user for overwritting +function upload_file { +sourcefile=${1:?"provide source file"} +destlfn=${2:?"provide destination file lfn"} +sourcefile="$(readlink -f "${sourcefile}")" # convert to absolute path +test -f "${sourcefile}" || error "can't find ${sourcefile}" +echo "uploading ${sourcefile} to ${destlfn}" +if file_exists "${destlfn}"; then + check_user "${destlfn} already exists. overwrite it?" || return 2 + lcg-del -a "lfn:${destlfn}" || error "lcg-del error" +fi +echo "lets roll" +lcg-cr -v -d ccsrm02.in2p3.fr -l "lfn:${destlfn}" "file:${sourcefile}" || error "lcg-cr error" +} + # common path used lfnbase="/grid/biomed/creatis/fgate/" -lfnrelease="${lfnbase}releases/" -lfnworkflow="${lfnbase}" +lfnrelease="/grid/biomed/creatis/vip/data/groups/GateLab/releases/" +lfnworkflow="${lfnbase}workflow/" lfngasw="${lfnbase}gasw/" lfnscript="${lfnbase}bin/"