forked from moserp/gitorious-ubuntu-sprinkle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gitorious.rb
261 lines (227 loc) · 6.69 KB
/
gitorious.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
require 'packages/ubuntu'
policy :gitorious, :roles => :server do
requires :sprinkle_dependencies
requires :ubuntu_gitorious_dependencies
requires :gitorious
requires :gitorious_symlink
requires :config
requires :initscripts
requires :git_user
requires :git_directories
requires :start_daemons
requires :apache_config
requires :logrotate
end
package :initscripts do
requires :gitdaemon_initd
requires :stomp_initd
requires :gitpoller_initd
end
package :config do
requires :database_config
requires :gitorious_config
requires :stomp_config
end
package :rdiscount do
gem :rdiscount do
http_proxy 'http://proxy.intra.bt.com:8080'
end
version '1.3.1.1'
verify { has_gem 'rdiscount', '1.3.1.1' }
end
package :stomp do
gem :stomp do
http_proxy 'http://proxy.intra.bt.com:8080'
end
version '1.1'
verify { has_gem 'stomp', '1.1' }
end
package :gitorious_dependencies do
gems = [:chronic, :daemons, :hoe, :echoe, :'ruby-yadis', :'ruby-openid',
:'mime-types', :'diff-lcs', :json, :'ruby-hmac', :stompserver, :mysql]
gems.each do |gem_name|
puts "installing #{gem_name}"
gem gem_name do
http_proxy 'http://proxy.intra.bt.com:8080'
end
end
requires :rdiscount
requires :stomp
verify do
gems.each do |gem|
has_gem gem
end
end
end
package :rack do
gem :rack do
http_proxy 'http://proxy.intra.bt.com:8080'
end
version '1.0.1'
verify { has_gem 'rack', '1.0.1' }
end
package :gitorious do
requires :rack
requires :gitorious_dependencies
gem 'mysql' do
http_proxy 'http://proxy.intra.bt.com:8080'
pre :install, 'bash -c "export http_proxy=http://proxy.intra.bt.com:8080 && wget http://gitorious.org/gitorious/mainline/archive-tarball/master -O /tmp/gitorious.tar.gz"'
pre :install, 'tar xfz /tmp/gitorious.tar.gz -C /var/www'
pre :install, 'mv /var/www/gitorious-mainline /var/www/gitorious'
# this next line should work, but http git clone is flakey on gitorious, so using the above tar file instead
#pre :install, 'export http_proxy=http://proxy.intra.bt.com:8080 && git clone http://git.gitorious.org/gitorious/mainline.git /var/www/gitorious'
end
verify do
has_directory '/var/www/gitorious'
end
end
package :gitorious_symlink do
noop do
post :install, 'ln -s /var/www/gitorious/script/gitorious /usr/bin'
end
verify {has_symlink '/usr/bin/gitorious','/var/www/gitorious/script/gitorious'}
end
package :stomp_initd do
transfer 'init.d/stomp', 'stomp' do
post :install, 'mv stomp /etc/init.d/stomp'
end
verify do
has_file '/etc/init.d/stomp'
end
end
package :gitpoller_initd do
transfer 'init.d/git-poller', 'git-poller' do
post :install, 'mv git-poller /etc/init.d/git-poller'
end
verify do
has_file '/etc/init.d/git-poller'
end
end
package :gitdaemon_initd do
transfer 'init.d/git-daemon', 'git-daemon' do
post :install, 'mv git-daemon /etc/init.d/git-daemon'
end
verify do
has_file '/etc/init.d/git-daemon'
end
end
package :gitorious_database do
noop do
post :install, 'su - git -c "rake db:create db:migrate RAILS_ENV=production"'
end
end
package :start_stomp do
noop do
post :install, 'chown root:root /etc/init.d/stomp'
post :install, 'chmod 755 /etc/init.d/stomp'
post :install, 'update-rc.d stomp defaults'
post :install, '/etc/init.d/stomp start'
end
verify {has_process 'stompserver'}
end
package :start_git_poller do
noop do
post :install, 'chown root:root /etc/init.d/git-poller'
post :install, 'chmod 755 /etc/init.d/git-poller'
post :install, 'update-rc.d git-poller defaults'
post :install, '/etc/init.d/git-poller start'
end
verify {has_file '~git/tmp/pids/poller0.pid'}
end
package :start_git_daemon do
noop do
post :intsall, 'chown root:root /etc/init.d/git-daemon'
post :install, 'update-rc.d git-daemon defaults'
post :install, '/etc/init.d/git-daemon start'
end
verify {has_file '~git/log/git-daemon.pid'}
end
package :start_daemons do
requires :stomp_initd
requires :gitpoller_initd
requires :gitdaemon_initd
requires :gitorious_database
requires :start_stomp
requires :start_git_poller
requires :start_git_daemon
end
package :database_config do
requires :git_user
transfer 'config/database.yml', '/tmp/database.yml' do
post :install, 'mv /tmp/database.yml ~git/config/database.yml'
#post :install, 'chown git:git ~git/config/database.yml'
end
verify {has_file '~git/config/database.yml'}
end
package :gitorious_config do
requires :git_user
transfer 'config/gitorious.yml', '/tmp/gitorious.yml' do
post :install, 'mv /tmp/gitorious.yml ~git/config/gitorious.yml'
#post :install, 'chown git:git ~git/config/gitorious.yml'
end
verify {has_file '~git/config/gitorious.yml'}
end
package :stomp_config do
noop do
post :install, 'cp ~git/config/broker.yml.example ~git/config/broker.yml'
end
verify {has_file '~git/config/broker.yml'}
end
package :git_user do
noop do
post :install, 'adduser --system --home /var/www/gitorious/ --no-create-home --group --shell /bin/bash git'
post :install, 'chown -R git:git /var/www/gitorious'
end
verify {file_contains '/etc/passwd', 'git'}
end
package :git_directories do
noop do
post :install, "su git -c 'mkdir ~git/.ssh'"
post :install, "su git -c 'touch ~git/.ssh/authorized_keys'"
post :install, "chmod 700 ~git/.ssh"
post :install, "chmod 600 ~git/.ssh/authorized_keys"
post :install, "su git -c 'mkdir ~git/tmp/pids'"
post :install, "su git -c 'mkdir ~git/repositories'"
post :install, "su git -c 'mkdir ~git/tarballs'"
end
verify do
has_file '~git/.ssh/authorized_keys'
has_directory '~git/tmp/pids'
has_directory '~git/repositories'
has_directory '~git/tarballs'
end
end
# TODO
# logrotate
package :sprinkle_dependencies do
apt 'wget'
end
package :apache_config do
transfer 'apache-config/gitorious', '/tmp/gitorious' do
post :install, 'mv /tmp/gitorious /etc/apache2/sites-available/gitorious'
end
noop do
post :install, 'ln -s /etc/apache2/sites-available/gitorious /etc/apache2/sites-enabled/002-gitorious'
post :install, 'rm /etc/apache2/sites-enabled/000-default'
post :install, 'apachectl restart'
end
verify {has_file '/etc/apache2/sites-enabled/002-gitorious'}
end
package :logrotate do
noop do
post :install, 'cp /var/www/gitorious//doc/templates/ubuntu/gitorious-logrotate /etc/logrotate.d/gitorious'
end
verify {has_file '/etc/logrotate.d/gitorious'}
end
deployment do
# mechanism for deployment
delivery :capistrano do
recipes 'deploy'
end
# source based package installer defaults
source do
prefix '/usr/local'
archives '/usr/local/sources'
builds '/usr/local/build'
end
end