Merge lp:~patrick-hetu/charms/precise/gitlab/6-8-stable into lp:charms/gitlab

Proposed by Patrick Hetu
Status: Work in progress
Proposed branch: lp:~patrick-hetu/charms/precise/gitlab/6-8-stable
Merge into: lp:charms/gitlab
Diff against target: 300 lines (+57/-50)
5 files modified
config.yaml (+3/-3)
hooks/db-relation-broken (+1/-1)
hooks/db-relation-changed (+27/-17)
hooks/install (+25/-28)
hooks/start (+1/-1)
To merge this branch: bzr merge lp:~patrick-hetu/charms/precise/gitlab/6-8-stable
Reviewer Review Type Date Requested Status
Benjamin Saller (community) Needs Fixing
Review via email: mp+219012@code.launchpad.net

Description of the change

Update the charm to install version 6-8-stable.

To post a comment you must log in.
Revision history for this message
Benjamin Saller (bcsaller) wrote :

Thank you so much for the submission! I am going to put this MP to "Needs Fixing"

Once the problem has been addressed, click on the “Request another review” link on this merge proposal. That way it will be added to the review queue properly.

If you have any questions/comments/concerns about the review contact us in #juju on irc.freenode.net or email the mailing list <email address hidden>

The notes below are pretty minor. I'm also not sure what nesscited the change from gitlab to git everywhere, but implementor's choice :)

review: Needs Fixing
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

Hey, there's a new review system we're moving this to Work in progress, when ready for another review please move to "Needs review". If you wish to abandon this please move to Rejected.

Thanks!

Unmerged revisions

8. By Patrick Hetu

update to the last version

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2013-02-01 22:47:17 +0000
3+++ config.yaml 2014-05-09 15:56:56 +0000
4@@ -1,17 +1,17 @@
5 options:
6 admin_password:
7 type: string
8- description: Sets the admin password
9+ description: Sets the admin password. MANDATORY.
10
11 host:
12 type: string
13- description: The FQDN for your GitLab unit
14+ description: The FQDN for your GitLab unit. MANDATORY.
15 default: localhost
16
17 email_from:
18 type: string
19 description: Email address used in the from field in mails send by GitLab
20- default: gitlab@localhost
21+ default: git@localhost
22
23 support_email:
24 type: string
25
26=== modified file 'hooks/db-relation-broken'
27--- hooks/db-relation-broken 2013-02-01 22:47:17 +0000
28+++ hooks/db-relation-broken 2014-05-09 15:56:56 +0000
29@@ -1,2 +1,2 @@
30 #!/bin/bash
31-sudo -u gitlab -H rm -f ~gitlab/gitlab/config/database.yml
32+sudo -u gitlab -H rm -f ~git/gitlab/config/database.yml
33
34=== modified file 'hooks/db-relation-changed'
35--- hooks/db-relation-changed 2013-02-01 22:47:17 +0000
36+++ hooks/db-relation-changed 2014-05-09 15:56:56 +0000
37@@ -13,9 +13,9 @@
38 source inc/common
39
40 # If there is a config file already, Joomla is already installed & config'ed
41-if [ -f ~gitlab/gitlab/config/database.yml ]; then
42+if [ -f ~git/gitlab/config/database.yml ]; then
43 juju-log "Database relation is already setup. Nothing to be done"
44- # TODO: Update the config file with new DB values even
45+ # TODO: Update the config file with new DB values even
46 exit 0
47 fi
48
49@@ -28,14 +28,14 @@
50 # Admin password from config.yaml
51 admin_password=`config-get admin_password`
52
53-# Secret key
54+# Secret key
55 secret_key=`pwgen 32 1`
56
57 # Sanity checks
58 ## If there is no database name defined, die
59 if [ -z "$database" ] ; then
60 juju-log "Not a valid database"
61- exit 1
62+ exit 0
63 fi
64
65 ## If the user has given no password to the admin user exit with an error
66@@ -48,43 +48,49 @@
67 function configure_mysql_database() {
68 # Generates the proper database config
69 juju-log Configuring MySQL GitLab database
70- cd ~gitlab/gitlab
71- sudo -u gitlab -H sh -c "sed -e 's/^ database: gitlabhq_production/ database: $database/g' < config/database.yml.mysql > config/database.yml"
72- sudo -u gitlab -H sh -c "sed -i -e 's/^ username: root/ username: $user/g' config/database.yml"
73- sudo -u gitlab -H sh -c "sed -i -e 's/^ password: \"secure password\"/ password: \"$password\"/g' config/database.yml"
74- sudo -u gitlab -H sh -c "sed -i -e 's/^ # host: localhost/ host: $host/g' config/database.yml"
75+ cd ~git/gitlab
76+ sudo -u git -H sh -c "sed -e 's/^ database: gitlabhq_production/ database: $database/g' < config/database.yml.mysql > config/database.yml"
77+ sudo -u git -H sh -c "sed -i -e 's/^ username: git/ username: $user/g' config/database.yml"
78+ sudo -u git -H sh -c "sed -i -e 's/^ password: \"secure password\"/ password: \"$password\"/g' config/database.yml"
79+ sudo -u git -H sh -c "sed -i -e 's/^ # host: localhost/ host: $host/g' config/database.yml"
80 cd -
81 }
82
83 function install_mysql_gems() {
84- cd ~gitlab/gitlab
85+ cd ~git/gitlab
86
87 # TODO: this gem install is probably better off in the install hook
88 sudo gem install charlock_holmes --version '0.6.9'
89
90 # For MySQL (note, the option says "without")
91- sudo -u gitlab -H bundle install --deployment --without development test postgres
92+ sudo -u git -H bundle install --deployment --without development test postgres
93 cd -
94 }
95
96 function init_database() {
97- cd ~gitlab/gitlab
98+ cd ~git/gitlab
99 juju-log "Seting up GitLab and initializing database"
100- sudo -u gitlab -H sh -c "yes yes | bundle exec rake gitlab:setup RAILS_ENV=production"
101+ sudo -u git -H sh -c "yes yes | bundle exec rake gitlab:setup RAILS_ENV=production"
102 cd -
103 }
104
105 function precompile() {
106 # TODO: maybe this can be done during install, but I am not sure if it needs the db connection to
107 # be established already.
108- cd ~gitlab/gitlab
109+ cd ~git/gitlab
110 juju-log "Precompiling GitLab. This may take a while (15 minutes on ec2 t1.micro)..."
111 juju-log "Please, be patient"
112- sudo -u gitlab -H bundle exec rake assets:precompile RAILS_ENV=production
113+ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
114 juju-log "Precompile finished. Thanks for your patience"
115 cd -
116 }
117
118+function install_git_shell() {
119+ cd ~git/gitlab-shell/
120+ sudo -u git -H cp config.yml.example config.yml
121+ sudo -u git -H ./bin/install
122+}
123+
124 function set_admin_password() {
125 encrypted_password=`ruby -e 'require "bcrypt"; puts BCrypt::Password.create(ARGV[0], :cost => 10)' $admin_password`
126 # TODO: allow for email to be config'ed too
127@@ -99,9 +105,13 @@
128 init_database
129 set_admin_password
130 precompile
131+install_git_shell
132
133 juju-log "Opening port 80"
134 open-port 80/tcp
135
136-juju-log "Starting Nginx and GitLab"
137-hooks/start
138+juju-log "Starting GitLab"
139+sudo service gitlab start
140+juju-log "Starting nginx"
141+sudo service nginx start
142+
143
144=== modified file 'hooks/install'
145--- hooks/install 2013-02-01 22:47:17 +0000
146+++ hooks/install 2014-05-09 15:56:56 +0000
147@@ -58,13 +58,9 @@
148 git
149
150 # This user is for gitlab, a web gui for managing your git repositories
151- sudo adduser --disabled-login --gecos 'GitLab' gitlab
152
153- # Add it to the git group
154- sudo usermod -a -G git gitlab
155-
156 # Generate the SSH key
157- sudo -u gitlab -H ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
158+ sudo -u git -H ssh-keygen -q -N '' -t rsa -f /home/git/.ssh/id_rsa
159 }
160
161 function install_gitolite() {
162@@ -79,8 +75,8 @@
163 sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'
164
165 # Copy the gitlab user's (public) SSH key ...
166- sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
167- sudo chmod 0444 /home/git/gitlab.pub
168+ sudo cp /home/git/.ssh/id_rsa.pub /home/git/gitlab.pub
169+ sudo chmod 0444 /home/git/gitlab.pub
170
171 # ... and use it as the admin key for the Gitolite setup
172 sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
173@@ -88,19 +84,19 @@
174 # Make sure the Gitolite config dir is owned by git
175 sudo chmod 750 /home/git/.gitolite/
176 sudo chown -R git:git /home/git/.gitolite/
177-
178+
179 # Make sure the repositories dir is owned by git and it stays that way
180 sudo chmod -R ug+rwXs,o-rwx /home/git/repositories/
181 sudo chown -R git:git /home/git/repositories/
182
183 # Adds localhost ssh key to gitlab's known_hosts
184- sudo -u gitlab -H sh -c 'ssh-keyscan -H localhost >> ~/.ssh/known_hosts'
185+ sudo -u git -H sh -c 'ssh-keyscan -H localhost >> ~/.ssh/known_hosts'
186 }
187
188 function test_gitolite() {
189 # Clone the admin repo so SSH adds localhost to known_hosts ...
190 # ... and to be sure your users have access to Gitolite
191- sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
192+ sudo -u git -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
193
194 # If it succeeded without errors you can remove the cloned repo
195 sudo rm -rf /tmp/gitolite-admin
196@@ -108,20 +104,21 @@
197
198 function install_gitlab() {
199 # We'll install GitLab into home directory of the user "gitlab"
200- cd /home/gitlab
201+ cd /home/git
202
203 # Clone GitLab repository
204- sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
205+ sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
206+ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.3
207
208- # Go to gitlab dir
209- cd /home/gitlab/gitlab
210+ # Go to gitlab dir
211+ cd /home/git/gitlab
212
213 # Checkout to stable release
214- sudo -u gitlab -H git checkout 4-1-stable
215+ sudo -u git -H git checkout 6-8-stable
216 }
217
218 function configure_gitlab() {
219- cd /home/gitlab/gitlab
220+ cd /home/git/gitlab
221
222 # Copy the example GitLab config
223 #sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml
224@@ -130,45 +127,45 @@
225 # charm config
226 host=`config-get host`
227 # TODO: add default values
228- sudo -u gitlab -H sh -c "sed -e 's/^ host: localhost/ host: $host/g' < config/gitlab.yml.example > config/gitlab.yml"
229+ sudo -u git -H sh -c "sed -e 's/^ host: localhost/ host: $host/g' < config/gitlab.yml.example > config/gitlab.yml"
230
231 # TODO: update other config items in gitlab.yml
232 # sed -itmp
233
234 # Make sure GitLab can write to the log/ and tmp/ directories
235- sudo chown -R gitlab log/
236- sudo chown -R gitlab tmp/
237+ sudo chown -R git log/
238+ sudo chown -R git tmp/
239 sudo chmod -R u+rwX log/
240 sudo chmod -R u+rwX tmp/
241
242 # Make directory for satellites
243- sudo -u gitlab -H mkdir /home/gitlab/gitlab-satellites
244-
245+ sudo -u git -H mkdir /home/git/gitlab-satellites
246+
247 # Copy the example Unicorn config
248- sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb
249+ sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
250 }
251
252 function configure_git {
253- sudo -u gitlab -H git config --global user.name "GitLab"
254+ sudo -u git -H git config --global user.name "GitLab"
255 # TODO: get from charm config.yaml
256- sudo -u gitlab -H git config --global user.email "gitlab@localhost"
257+ sudo -u git -H git config --global user.email "gitlab@localhost"
258 }
259
260 function setup_gitlab_hooks() {
261- cd ~gitlab/gitlab
262+ cd ~git/gitlab
263 sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
264 sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
265 cd -
266 }
267
268 function init_script() {
269- sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/4-1-stable/init.d/gitlab
270+ sudo curl --output /etc/init.d/gitlab https://raw.githubusercontent.com/gitlabhq/gitlabhq/fefa10c3c208cb0cce6e25e498221d1d97d26238/lib/support/init.d/gitlab
271 sudo chmod +x /etc/init.d/gitlab
272 sudo update-rc.d gitlab defaults 21
273 }
274
275 function config_nginx() {
276- sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/4-1-stable/nginx/gitlab
277+ sudo curl --output /etc/nginx/sites-available/gitlab https://raw.githubusercontent.com/gitlabhq/gitlabhq/fefa10c3c208cb0cce6e25e498221d1d97d26238/lib/support/nginx/gitlab
278 sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
279 # TODO: allow for config of hostname
280 sed -i -e 's/YOUR_SERVER_IP/0.0.0.0/g' /etc/nginx/sites-available/gitlab
281@@ -182,6 +179,6 @@
282 install_gitlab
283 configure_gitlab
284 configure_git
285-setup_gitlab_hooks
286+#setup_gitlab_hooks
287 init_script
288 config_nginx
289
290=== modified file 'hooks/start'
291--- hooks/start 2013-02-01 22:47:17 +0000
292+++ hooks/start 2014-05-09 15:56:56 +0000
293@@ -1,6 +1,6 @@
294 #!/bin/bash
295 # Avoid starting a unconfigured instance that has no database
296-if [ -f ~gitlab/gitlab/config/database.yml ]; then
297+if [ -f ~git/gitlab/config/database.yml ]; then
298 juju-log "Starting GitLab"
299 sudo service gitlab start
300 juju-log "Starting nginx"

Subscribers

People subscribed via source and target branches

to all changes: