Merge branch '9820-cwl-poll-jobs' closes #9820
[arvados.git] / docker / api / setup-gitolite.sh.in
1 #!/bin/bash
2
3 ssh-keygen -q -N '' -t rsa -f /root/.ssh/id_rsa
4
5 useradd git
6 mkdir /home/git
7
8 # Set up gitolite repository
9 cp ~root/.ssh/id_rsa.pub ~git/root-authorized_keys.pub
10 chown git:git /home/git -R
11 su - git -c "mkdir -p ~/bin"
12
13 su - git -c "git clone git://github.com/sitaramc/gitolite"
14 su - git -c "gitolite/install -ln ~/bin"
15 su - git -c "PATH=/home/git/bin:$PATH gitolite setup -pk ~git/root-authorized_keys.pub"
16 install -o git -g git -m 600 /usr/local/arvados/config/.gitolite.rc /home/git/
17
18 # And make sure that the existing repos are equally readable, or the API server commit model will freak out...
19 chmod 755 /home/git/repositories
20 chmod +rx /home/git/repositories/*git -R
21
22 # Now set up the gitolite repo(s) we use
23 mkdir -p /usr/local/arvados/gitolite-tmp/
24 # Make ssh store the host key
25 ssh -o "StrictHostKeyChecking no" git@api.@@ARVADOS_DOMAIN@@ info
26 # Now check out the tree
27 git clone git@api.@@ARVADOS_DOMAIN@@:gitolite-admin.git /usr/local/arvados/gitolite-tmp/gitolite-admin/
28 cd /usr/local/arvados/gitolite-tmp/gitolite-admin
29 mkdir keydir/arvados
30 mkdir conf/admin
31 mkdir conf/auto
32 echo "
33
34 @arvados_git_user = arvados_git_user
35
36 repo @all
37      RW+                 = @arvados_git_user
38
39 " > conf/admin/arvados.conf
40 echo '
41 include "auto/*.conf"
42 include "admin/*.conf"
43 ' >> conf/gitolite.conf
44
45 #su - git -c "ssh-keygen -t rsa"
46 cp /root/.ssh/id_rsa.pub keydir/arvados/arvados_git_user.pub
47 # Replace the 'root' key with the user key, just in case
48 cp /root/.ssh/authorized_keys keydir/root-authorized_keys.pub
49 # But also make sure we have the root key installed so it can access all keys
50 git add keydir/root-authorized_keys.pub
51 git add keydir/arvados/arvados_git_user.pub
52 git add conf/admin/arvados.conf
53 git add keydir/arvados/
54 git add conf/gitolite.conf
55 git commit -a -m 'git server setup'
56 git push
57
58 # Prepopulate the arvados.git repo with our source. Silly, but until we can check out from remote trees,
59 # we need this to make the tutorials work.
60 su - git -c "git clone --bare git://github.com/curoverse/arvados.git /home/git/repositories/arvados.git"
61
62 echo "ARVADOS_API_HOST_INSECURE=yes" > /etc/cron.d/gitolite-update
63 echo "*/2 * * * * root /bin/bash -c 'source /etc/profile.d/rvm.sh && /usr/src/arvados/services/api/script/arvados-git-sync.rb production'" >> /etc/cron.d/gitolite-update
64
65 # Create/update the repos now
66 . /etc/profile.d/rvm.sh
67 export ARVADOS_API_HOST=api
68 export ARVADOS_API_HOST_INSECURE=yes
69 export ARVADOS_API_TOKEN=@@API_SUPERUSER_SECRET@@
70 /usr/local/arvados/update-gitolite.rb production
71
72 echo "PATH=/usr/bin:/bin:/sbin" > /etc/cron.d/arvados-repo-update
73 echo "*/5 * * * * git cd ~git/repositories/arvados.git; git fetch https://github.com/curoverse/arvados.git master:master" >> /etc/cron.d/arvados-repo-update