8d8d2d5e39774c1838e3f6c3be23cff466721f4e
[arvados.git] / tools / copy-tutorial / copy-tutorial.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 set -e -o pipefail
7
8 if test -z "$1"  ; then
9   echo "$0: Copies Arvados tutorial resources from public data cluster (jutro)"
10   echo "Usage: copy-tutorial.sh <dest>"
11   echo "<dest> is 5-character cluster id of the destination"
12   exit
13 fi
14
15 src=jutro
16 dest=$1
17
18 if ! test -f $HOME/.config/arvados/${dest}.conf ; then
19     echo "Please create $HOME/.config/arvados/${dest}.conf with the following contents:"
20     echo "ARVADOS_API_HOST=<${dest} host>"
21     echo "ARVADOS_API_TOKEN=<${dest} token>"
22     exit 1
23 fi
24
25 if ! test -f $HOME/.config/arvados/jutro.conf ; then
26     # Set it up with the anonymous user token.
27     echo "ARVADOS_API_HOST=jutro.arvadosapi.com" > $HOME/.config/arvados/jutro.conf
28     echo "ARVADOS_API_TOKEN=v2/jutro-gj3su-e2o9x84aeg7q005/22idg1m3zna4qe4id3n0b9aw86t72jdw8qu1zj45aboh1mm4ej" >> $HOME/.config/arvados/jutro.conf
29     exit 1
30 fi
31
32 for a in $(cat $HOME/.config/arvados/${dest}.conf) ; do export $a ; done
33
34 echo
35 echo "Copying bwa mem example from public data cluster (jutro) to $dest"
36 echo
37
38 set -x
39
40 project_uuid=$(arv --format=uuid group list --filters '[["name", "=", "User guide resources"]]')
41 if test -z "$project_uuid" ; then
42     project_uuid=$(arv --format=uuid group create --group '{"name":"User guide resources", "group_class": "project"}')
43     arv link create --link '{"link_class": "permission", "name": "can_read", "tail_uuid": "'$dest'-j7d0g-anonymouspublic", "head_uuid": "'$project_uuid'"}'
44 fi
45
46 if ! arv-keepdocker | grep "arvados/jobs *latest" ; then
47     arv-copy --src jutro --dst $dest --project-uuid=$project_uuid jutro-4zz18-sxmit0qs6i9n2s4
48 fi
49
50 # Bwa-mem workflow
51 arv-copy --src jutro --dst $dest --project-uuid=$project_uuid f141fc27e7cfa7f7b6d208df5e0ee01b+59
52 arv-copy --src jutro --dst $dest --project-uuid=$project_uuid jutro-7fd4e-mkmmq53m1ze6apx
53
54 set +x
55
56 echo
57 echo "Finished, data copied to \"User guide resources\" at $project_uuid"
58 echo