]> Creatis software - clitk.git/blob - grid/common.sh
44ad69381ed09e212c99c1cb9001c2fb09ac7bb3
[clitk.git] / grid / common.sh
1
2 set -u
3
4 # print error message and exit immediately
5 programname="$(basename ${0})"
6 function error {
7 echo "${programname} **ERROR** $1"
8 exit 1
9 }
10
11 # ensure a valid proxy is present for at least one hour
12 # if no proxy is found, try to create a new one
13 # return 0 if a valid proxy is found or created
14 # else return voms-proxy-init error code
15 function ensure_proxy {
16 voms-proxy-info --exists -valid 1:0 > /dev/null && return 0 
17 voms-proxy-init --voms biomed -valid 24:00 || exit 1
18 }
19
20 # print prompt to ensure that the user want to continue further
21 # the user has to answer with 'y' to continue
22 function check_user {
23 prompt="${1:-is that correct?}"
24 read -p "${prompt} [y/n] " answer
25 test "${answer}" == "y" && return 0
26 test "${answer}" == "n" && return 1
27 check_user "${prompt}"
28 }
29
30 # common path used
31 lfnbase="/grid/biomed/creatis/fgate/"
32 lfnrelease="${lfnbase}releases/"
33 lfnworkflow="${lfnbase}"
34 lfngasw="${lfnbase}gasw/"
35 lfnscript="${lfnbase}bin/"
36
37 # define the prefix for uploaded file
38 # default to local machine username
39 prefix="${USER:?"USER must be set"}_"