closes #3183
[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 # All users group
12 prefix=`arv --format=uuid user current | cut -d- -f1`
13 read -rd $'\000' newgroup <<EOF; arv group create --group "$newgroup"
14 {
15  "uuid":"$prefix-j7d0g-fffffffffffffff",
16  "name":"All users"
17 }
18 EOF
19
20 # Arvados repository object
21 all_users_group_uuid="$prefix-j7d0g-fffffffffffffff"
22 repo_uuid=`arv --format=uuid repository create --repository '{"name":"arvados","fetch_url":"git@api:arvados.git","push_url":"git@api:arvados.git"}'`
23 echo "Arvados repository uuid is $repo_uuid"
24
25 read -rd $'\000' newlink <<EOF; arv link create --link "$newlink"
26 {
27  "tail_uuid":"$all_users_group_uuid",
28  "head_uuid":"$repo_uuid",
29  "link_class":"permission",
30  "name":"can_read"
31 }
32 EOF
33
34 # Make sure the necessary keep_service objects exist
35 arv keep_service list > /tmp/keep_service.list
36
37 grep -q keep_server_0 /tmp/keep_service.list
38 if [[ "$?" != "0" ]]; then
39   arv keep_service create --keep-service "$(cat /root/keep_server_0.json)"
40 fi
41
42 grep -q keep_server_1 /tmp/keep_service.list
43 if [[ "$?" != "0" ]]; then
44   arv keep_service create --keep-service "$(cat /root/keep_server_1.json)"
45 fi
46
47 # User repository object
48 user_uuid=`arv --format=uuid user current`
49 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"}'`
50 echo "User repository uuid is $repo_uuid"
51
52 read -rd $'\000' newlink <<EOF; arv link create --link "$newlink"
53 {
54  "tail_uuid":"$user_uuid",
55  "head_uuid":"$repo_uuid",
56  "link_class":"permission",
57  "name":"can_write"
58 }
59 EOF
60
61 # Shell machine object
62 arv virtual_machine create --virtual-machine '{"hostname":"shell"}'