minor backward compat breakage in specifying owner/desc,
[gitolite.git] / t / mirror-test-setup.sh
blob23f382d5334104527849271a3bfe95c9b968b042
1 #!/bin/bash
3 set -e
4 hosts="frodo sam gollum"
5 mainhost=frodo
7 # setup software
8 bd=`gitolite query-rc -n GL_BINDIR`
9 rm -rf /tmp/g3/src
10 cp -a $bd /tmp/g3/src
11 chmod -R go+rX /tmp/g3
13 # setup symlinks in frodo, sam, and gollum's accounts
14 for h in $hosts
16 sudo -u $h -i bash -c "rm -rf *.pub bin .ssh projects.list repositories .gitolite .gitolite.rc"
17 done
19 [ "$1" = "clear" ] && exit
21 cd /tmp/g3
22 [ -d keys ] || {
23 mkdir keys
24 cd keys
25 for h in $hosts
27 ssh-keygen -N '' -q -f server-$h -C $h
28 chmod go+r /tmp/g3/keys/server-$h
29 done
30 cp $bd/../t/mirror-test-ssh-config ssh-config
33 for h in $hosts
35 sudo -u $h -i bash -c "mkdir -p bin; ln -sf /tmp/g3/src/gitolite bin; mkdir -p .ssh; chmod 0700 .ssh"
37 sudo -u $h -i cp /tmp/g3/keys/ssh-config .ssh/config
38 sudo -u $h -i cp /tmp/g3/keys/server-$h .ssh/id_rsa
39 sudo -u $h -i cp /tmp/g3/keys/server-$h.pub .ssh/id_rsa.pub
40 sudo -u $h -i chmod go-rwx .ssh/id_rsa .ssh/config
42 done
44 # add all pubkeys to all servers
45 for h in $hosts
47 sudo -u $h -i gitolite setup -a admin
48 for j in $hosts
50 sudo -u $h -i gitolite setup -pk /tmp/g3/keys/server-$j.pub
51 echo sudo _u $j _i ssh $h@localhost info
52 sudo -u $j -i ssh -o StrictHostKeyChecking=no $h@localhost info
53 done
54 echo ----
55 done
57 # now copy our admin key to the main host
58 cd;cd .ssh
59 cp admin id_rsa; cp admin.pub id_rsa.pub
60 cp admin.pub /tmp/g3/keys; chmod go+r /tmp/g3/keys/admin.pub
61 sudo -u $mainhost -i gitolite setup -pk /tmp/g3/keys/admin.pub
62 ssh $mainhost@localhost info
64 lines="
65 repo gitolite-admin
66 option mirror.master = frodo
67 option mirror.slaves-1 = sam gollum
68 option mirror.redirectOK = sam
70 repo r1
71 RW+ = u1
72 RW = u2
73 R = u3
74 option mirror.master = sam
75 option mirror.slaves-1 = frodo
77 repo r2
78 RW+ = u2
79 RW = u3
80 R = u4
81 option mirror.master = sam
82 option mirror.slaves-1 = frodo gollum
83 option mirror.redirectOK = all
85 include \"%HOSTNAME.conf\"
88 lines2="
89 repo l-%HOSTNAME
90 RW = u1
93 # for each server, set the HOSTNAME to the rc, add the mirror options to the
94 # conf file, and compile
95 for h in $hosts
97 cat $bd/../t/mirror-test-rc | perl -pe "s/%HOSTNAME/$h/" > /tmp/g3/temp
98 sudo -u $h -i cp /tmp/g3/temp .gitolite.rc
99 echo "$lines" | sudo -u $h -i sh -c 'cat >> .gitolite/conf/gitolite.conf'
100 echo "$lines2" | sudo -u $h -i sh -c "cat >> .gitolite/conf/$h.conf"
101 sudo -u $h -i gitolite setup
102 done
104 # goes on frodo
105 lines="
106 # local to frodo but sam thinks frodo is a slave
107 repo lfrodo
108 RW = u1
110 # both think they're master
111 repo mboth
112 RW = u1
113 option mirror.master = frodo
114 option mirror.slaves = sam
116 # frodo thinks someone else is the master but sam thinks he is
117 repo mnotsam
118 RW = u1
119 option mirror.master = merry
120 option mirror.slaves = frodo
122 # local to frodo but sam thinks frodo is a master and redirect is OK
123 repo lfrodo2
124 RW = u1
126 # non-native to frodo but sam thinks frodo is master
127 repo nnfrodo
128 RW = u1
129 option mirror.master = gollum
130 option mirror.slaves = frodo
131 option mirror.redirectOK = all
133 # sam is not a valid slave to send stuff to frodo
134 repo nvsfrodo
135 RW = u1
136 option mirror.master = frodo
137 option mirror.slaves = gollum
138 option mirror.redirectOK = all
141 echo "$lines" | sudo -u frodo -i sh -c "cat >> .gitolite/conf/frodo.conf"
143 # goes on sam
144 lines="
145 # local to frodo but sam thinks frodo is a slave
146 repo lfrodo
147 RW = u1
148 option mirror.master = sam
149 option mirror.slaves = frodo
151 # both think they're master
152 repo mboth
153 RW = u1
154 option mirror.master = sam
155 option mirror.slaves = frodo
157 # frodo thinks someone else is the master but sam thinks he is
158 repo mnotsam
159 RW = u1
160 option mirror.master = sam
161 option mirror.slaves = frodo
163 # local to frodo but sam thinks frodo is a master and redirect is OK
164 repo lfrodo2
165 RW = u1
166 option mirror.master = frodo
167 option mirror.slaves = sam
168 option mirror.redirectOK = all
170 # non-native to frodo but sam thinks frodo is master
171 repo nnfrodo
172 RW = u1
173 option mirror.master = frodo
174 option mirror.slaves = sam
175 option mirror.redirectOK = all
177 # sam is not a valid slave to send stuff to frodo
178 repo nvsfrodo
179 RW = u1
180 option mirror.master = frodo
181 option mirror.slaves = sam
182 option mirror.redirectOK = all
185 echo "$lines" | sudo -u sam -i sh -c "cat >> .gitolite/conf/sam.conf"
187 for h in $hosts
189 sudo -u $h -i gitolite setup
190 done
192 # that ends the setup phase
193 echo ======================================================================