Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[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
17 # Make sure the repositories are created in such a way that they are readable
18 # by the api server
19 sed -i 's/0077/0022/g' /home/git/.gitolite.rc
20
21 # And make sure that the existing repos are equally readable, or the API server commit model will freak out...
22 chmod 755 /home/git/repositories
23 chmod +rx /home/git/repositories/*git -R
24
25 # Now set up the gitolite repo(s) we use
26 mkdir -p /usr/local/arvados/gitolite-tmp/
27 # Make ssh store the host key
28 ssh -o "StrictHostKeyChecking no" git@api info
29 # Now check out the tree
30 git clone git@api:gitolite-admin.git /usr/local/arvados/gitolite-tmp/gitolite-admin/
31 cd /usr/local/arvados/gitolite-tmp/gitolite-admin
32 mkdir keydir/arvados
33 mkdir conf/admin
34 mkdir conf/auto
35 echo "
36
37 @arvados_git_user = arvados_git_user
38
39 repo @all
40      RW+                 = @arvados_git_user
41
42 " > conf/admin/arvados.conf
43 echo '
44 include "auto/*.conf"
45 include "admin/*.conf"
46 ' >> conf/gitolite.conf
47
48 #su - git -c "ssh-keygen -t rsa"
49 cp /root/.ssh/id_rsa.pub keydir/arvados/arvados_git_user.pub
50 # Replace the 'root' key with the user key, just in case
51 cp /root/.ssh/authorized_keys keydir/root-authorized_keys.pub
52 # But also make sure we have the root key installed so it can access all keys
53 git add keydir/root-authorized_keys.pub
54 git add keydir/arvados/arvados_git_user.pub
55 git add conf/admin/arvados.conf
56 git add keydir/arvados/
57 git add conf/gitolite.conf
58 git commit -a -m 'git server setup'
59 git push
60
61 # Prepopulate the arvados.git repo with our source. Silly, but until we can check out from remote trees,
62 # we need this to make the tutorials work.
63 su - git -c "git clone --bare git://github.com/curoverse/arvados.git /home/git/repositories/arvados.git"
64
65 echo "ARVADOS_API_HOST_INSECURE=yes" > /etc/cron.d/gitolite-update
66 echo "*/2 * * * * root /bin/bash -c 'source /etc/profile.d/rvm.sh && /usr/local/arvados/update-gitolite.rb production'" >> /etc/cron.d/gitolite-update
67
68 # Create/update the repos now
69 . /etc/profile.d/rvm.sh
70 export ARVADOS_API_HOST=api
71 export ARVADOS_API_HOST_INSECURE=yes
72 export ARVADOS_API_TOKEN=@@API_SUPERUSER_SECRET@@
73 /usr/local/arvados/update-gitolite.rb production
74
75 echo "PATH=/usr/bin:/bin:/sbin" > /etc/cron.d/arvados-repo-update
76 echo "*/5 * * * * git cd ~git/repositories/arvados.git; git fetch https://github.com/curoverse/arvados.git master:master" >> /etc/cron.d/arvados-repo-update
77