Merge branch 'master' into 4926-browser-based-upload
[arvados.git] / docker / api / setup.sh.in
1 #!/bin/bash
2
3 set -x
4
5 . /etc/profile.d/rvm.sh
6
7 export ARVADOS_API_HOST=api
8 export ARVADOS_API_HOST_INSECURE=yes
9 export ARVADOS_API_TOKEN=@@API_SUPERUSER_SECRET@@
10
11 # Arvados repository object
12 all_users_group_uuid="$prefix-j7d0g-fffffffffffffff"
13 repo_uuid=`arv --format=uuid repository create --repository '{"name":"arvados","fetch_url":"git@api:arvados.git","push_url":"git@api:arvados.git"}'`
14 echo "Arvados repository uuid is $repo_uuid"
15
16 read -rd $'\000' newlink <<EOF; arv link create --link "$newlink"
17 {
18  "tail_uuid":"$all_users_group_uuid",
19  "head_uuid":"$repo_uuid",
20  "link_class":"permission",
21  "name":"can_read"
22 }
23 EOF
24
25 # Make sure the necessary keep_service objects exist
26 arv keep_service list > /tmp/keep_service.list
27
28 grep -q keep_server_0 /tmp/keep_service.list
29 if [[ "$?" != "0" ]]; then
30   arv keep_service create --keep-service "$(cat /root/keep_server_0.json)"
31 fi
32
33 grep -q keep_server_1 /tmp/keep_service.list
34 if [[ "$?" != "0" ]]; then
35   arv keep_service create --keep-service "$(cat /root/keep_server_1.json)"
36 fi
37
38 # User repository object
39 user_uuid=`arv --format=uuid user current`
40 repo_uuid=`arv --format=uuid repository create --repository '{"name":"@@ARVADOS_USER_NAME@@","fetch_url":"git@api:@@ARVADOS_USER_NAME@@.git","push_url":"git@api:@@ARVADOS_USER_NAME@@.git"}'`
41 echo "User repository uuid is $repo_uuid"
42
43 read -rd $'\000' newlink <<EOF; arv link create --link "$newlink"
44 {
45  "tail_uuid":"$user_uuid",
46  "head_uuid":"$repo_uuid",
47  "link_class":"permission",
48  "name":"can_write"
49 }
50 EOF
51
52 # Shell machine object
53 arv virtual_machine create --virtual-machine '{"hostname":"shell"}'