forked from EMBL-EBI-TSI/ansible-playbook-gridftp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_endpoints.sh
executable file
·46 lines (37 loc) · 1.14 KB
/
test_endpoints.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# This script will transfer a file between endpoints in both directions
# Author: Luis Gracia <luis.gracia@ebi.ac.uk>
# List the enpoints, one per line, ie. my.gridftp.server/my/path
# Usage: test_endpoints.sh server/path ...
declare -a endpoints=$*
if [ ${#endpoints[@]} -lt 1 ]; then
echo "No endpoints defined"
exit 1
fi
timestamp=$(date +'%Y%m%d%H%M%S')
file=test_gridftp_endpoints.txt
# Find max server string size
declare -i MAXSIZE=0
for endpoint in ${endpoints[@]}; do
server=${endpoint/\/*}
size=${#server}
[ $size -gt $MAXSIZE ] && MAXSIZE=$size
done
# Print header
printf "%${MAXSIZE}s"
for endpoint in ${endpoints[@]}; do
printf " %${MAXSIZE}s" ${endpoint/\/*}
done
echo
# Print results
for endpoint1 in ${endpoints[@]}; do
printf "%${MAXSIZE}s" ${endpoint1/\/*}
echo $timestamp ${endpoint1/\/*} > $file
globus-url-copy -q $file gsiftp://$endpoint2/ 2>test_transfer.stderr
for endpoint2 in ${endpoints[@]}; do
globus-url-copy -q gsiftp://$endpoint1/$file gsiftp://$endpoint2/ 2>test_transfer.stderr
[ $? -gt 0 ] && status="no" || status="yes"
printf " %${MAXSIZE}s" $status
done
echo
done