2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
9 . /usr/local/lib/arvbox/common.sh
11 mkdir -p /var/lib/arvados/git
13 export ARVADOS_API_HOST=$localip:${services[api]}
14 export ARVADOS_API_HOST_INSECURE=1
15 export ARVADOS_API_TOKEN=$(cat /var/lib/arvados/superuser_token)
20 export HOME=/var/lib/arvados/git
24 mkdir -p ~arvbox/.ssh ~git/.ssh
25 chmod 0700 ~arvbox/.ssh ~git/.ssh
27 if ! test -s ~arvbox/.ssh/id_rsa ; then
28 ssh-keygen -t rsa -P '' -f .ssh/id_rsa
29 cp ~arvbox/.ssh/id_rsa ~arvbox/.ssh/id_rsa.pub ~git/.ssh
32 if test -s ~arvbox/.ssh/known_hosts ; then
33 ssh-keygen -f ".ssh/known_hosts" -R localhost
36 if ! test -f /var/lib/arvados/gitolite-setup ; then
39 # Do a no-op login to populate known_hosts
40 # with the hostkey, so it won't try to ask
42 cp .ssh/id_rsa.pub .ssh/authorized_keys
43 ssh -o stricthostkeychecking=no git@localhost true
44 rm .ssh/authorized_keys
46 cp /usr/local/lib/arvbox/gitolite.rc .gitolite.rc
48 gitolite setup -pk .ssh/id_rsa.pub
50 if ! test -d gitolite-admin ; then
51 git clone git@localhost:gitolite-admin
55 git config user.email arvados
56 git config user.name arvados
57 git config push.default simple
60 touch /var/lib/arvados/gitolite-setup
62 # Do a no-op login to populate known_hosts
63 # with the hostkey, so it won't try to ask
64 # about it later. Don't run anything,
65 # get the default gitolite behavior.
66 ssh -o stricthostkeychecking=no git@localhost
69 prefix=$(arv --format=uuid user current | cut -d- -f1)
71 if ! test -s /var/lib/arvados/arvados-git-uuid ; then
72 repo_uuid=$(arv --format=uuid repository create --repository "{\"owner_uuid\":\"$prefix-tpzed-000000000000000\", \"name\":\"arvados\"}")
73 echo $repo_uuid > /var/lib/arvados/arvados-git-uuid
76 repo_uuid=$(cat /var/lib/arvados/arvados-git-uuid)
78 if ! test -s /var/lib/arvados/arvados-git-link-uuid ; then
79 all_users_group_uuid="$prefix-j7d0g-fffffffffffffff"
82 read -rd $'\000' newlink <<EOF
84 "tail_uuid":"$all_users_group_uuid",
85 "head_uuid":"$repo_uuid",
86 "link_class":"permission",
91 link_uuid=$(arv --format=uuid link create --link "$newlink")
92 echo $link_uuid > /var/lib/arvados/arvados-git-link-uuid
95 if ! test -d /var/lib/arvados/git/repositories/$repo_uuid.git ; then
96 git clone --bare /usr/src/arvados /var/lib/arvados/git/repositories/$repo_uuid.git
98 git --git-dir=/var/lib/arvados/git/repositories/$repo_uuid.git fetch -f /usr/src/arvados master:master
101 cd /usr/src/arvados/services/api
102 export RAILS_ENV=development
104 git_user_key=$(cat ~git/.ssh/id_rsa.pub)
106 cat > config/arvados-clients.yml <<EOF
108 gitolite_url: /var/lib/arvados/git/repositories/gitolite-admin.git
109 gitolite_tmp: /var/lib/arvados/git
110 arvados_api_host: $localip:${services[api]}
111 arvados_api_token: "$ARVADOS_API_TOKEN"
112 arvados_api_host_insecure: true
113 gitolite_arvados_git_user_key: "$git_user_key"
117 bundle exec script/arvados-git-sync.rb development