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