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
=== modified file 'config.yaml'
--- config.yaml 2013-02-01 22:47:17 +0000
+++ config.yaml 2014-05-09 15:56:56 +0000
@@ -1,17 +1,17 @@
1options:1options:
2 admin_password:2 admin_password:
3 type: string3 type: string
4 description: Sets the admin password4 description: Sets the admin password. MANDATORY.
55
6 host:6 host:
7 type: string7 type: string
8 description: The FQDN for your GitLab unit8 description: The FQDN for your GitLab unit. MANDATORY.
9 default: localhost9 default: localhost
1010
11 email_from:11 email_from:
12 type: string12 type: string
13 description: Email address used in the from field in mails send by GitLab13 description: Email address used in the from field in mails send by GitLab
14 default: gitlab@localhost14 default: git@localhost
1515
16 support_email:16 support_email:
17 type: string17 type: string
1818
=== modified file 'hooks/db-relation-broken'
--- hooks/db-relation-broken 2013-02-01 22:47:17 +0000
+++ hooks/db-relation-broken 2014-05-09 15:56:56 +0000
@@ -1,2 +1,2 @@
1#!/bin/bash1#!/bin/bash
2sudo -u gitlab -H rm -f ~gitlab/gitlab/config/database.yml2sudo -u gitlab -H rm -f ~git/gitlab/config/database.yml
33
=== modified file 'hooks/db-relation-changed'
--- hooks/db-relation-changed 2013-02-01 22:47:17 +0000
+++ hooks/db-relation-changed 2014-05-09 15:56:56 +0000
@@ -13,9 +13,9 @@
13source inc/common13source inc/common
1414
15# If there is a config file already, Joomla is already installed & config'ed15# If there is a config file already, Joomla is already installed & config'ed
16if [ -f ~gitlab/gitlab/config/database.yml ]; then16if [ -f ~git/gitlab/config/database.yml ]; then
17 juju-log "Database relation is already setup. Nothing to be done"17 juju-log "Database relation is already setup. Nothing to be done"
18 # TODO: Update the config file with new DB values even 18 # TODO: Update the config file with new DB values even
19 exit 019 exit 0
20fi20fi
2121
@@ -28,14 +28,14 @@
28# Admin password from config.yaml28# Admin password from config.yaml
29admin_password=`config-get admin_password`29admin_password=`config-get admin_password`
3030
31# Secret key 31# Secret key
32secret_key=`pwgen 32 1`32secret_key=`pwgen 32 1`
3333
34# Sanity checks34# Sanity checks
35## If there is no database name defined, die35## If there is no database name defined, die
36if [ -z "$database" ] ; then36if [ -z "$database" ] ; then
37 juju-log "Not a valid database"37 juju-log "Not a valid database"
38 exit 138 exit 0
39fi39fi
4040
41## If the user has given no password to the admin user exit with an error41## If the user has given no password to the admin user exit with an error
@@ -48,43 +48,49 @@
48function configure_mysql_database() {48function configure_mysql_database() {
49 # Generates the proper database config49 # Generates the proper database config
50 juju-log Configuring MySQL GitLab database50 juju-log Configuring MySQL GitLab database
51 cd ~gitlab/gitlab51 cd ~git/gitlab
52 sudo -u gitlab -H sh -c "sed -e 's/^ database: gitlabhq_production/ database: $database/g' < config/database.yml.mysql > config/database.yml"52 sudo -u git -H sh -c "sed -e 's/^ database: gitlabhq_production/ database: $database/g' < config/database.yml.mysql > config/database.yml"
53 sudo -u gitlab -H sh -c "sed -i -e 's/^ username: root/ username: $user/g' config/database.yml"53 sudo -u git -H sh -c "sed -i -e 's/^ username: git/ username: $user/g' config/database.yml"
54 sudo -u gitlab -H sh -c "sed -i -e 's/^ password: \"secure password\"/ password: \"$password\"/g' config/database.yml"54 sudo -u git -H sh -c "sed -i -e 's/^ password: \"secure password\"/ password: \"$password\"/g' config/database.yml"
55 sudo -u gitlab -H sh -c "sed -i -e 's/^ # host: localhost/ host: $host/g' config/database.yml"55 sudo -u git -H sh -c "sed -i -e 's/^ # host: localhost/ host: $host/g' config/database.yml"
56 cd -56 cd -
57}57}
5858
59function install_mysql_gems() {59function install_mysql_gems() {
60 cd ~gitlab/gitlab60 cd ~git/gitlab
6161
62 # TODO: this gem install is probably better off in the install hook62 # TODO: this gem install is probably better off in the install hook
63 sudo gem install charlock_holmes --version '0.6.9'63 sudo gem install charlock_holmes --version '0.6.9'
6464
65 # For MySQL (note, the option says "without")65 # For MySQL (note, the option says "without")
66 sudo -u gitlab -H bundle install --deployment --without development test postgres66 sudo -u git -H bundle install --deployment --without development test postgres
67 cd -67 cd -
68}68}
6969
70function init_database() {70function init_database() {
71 cd ~gitlab/gitlab71 cd ~git/gitlab
72 juju-log "Seting up GitLab and initializing database"72 juju-log "Seting up GitLab and initializing database"
73 sudo -u gitlab -H sh -c "yes yes | bundle exec rake gitlab:setup RAILS_ENV=production"73 sudo -u git -H sh -c "yes yes | bundle exec rake gitlab:setup RAILS_ENV=production"
74 cd -74 cd -
75}75}
7676
77function precompile() {77function precompile() {
78 # TODO: maybe this can be done during install, but I am not sure if it needs the db connection to78 # TODO: maybe this can be done during install, but I am not sure if it needs the db connection to
79 # be established already.79 # be established already.
80 cd ~gitlab/gitlab80 cd ~git/gitlab
81 juju-log "Precompiling GitLab. This may take a while (15 minutes on ec2 t1.micro)..."81 juju-log "Precompiling GitLab. This may take a while (15 minutes on ec2 t1.micro)..."
82 juju-log "Please, be patient"82 juju-log "Please, be patient"
83 sudo -u gitlab -H bundle exec rake assets:precompile RAILS_ENV=production83 sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
84 juju-log "Precompile finished. Thanks for your patience"84 juju-log "Precompile finished. Thanks for your patience"
85 cd -85 cd -
86}86}
8787
88function install_git_shell() {
89 cd ~git/gitlab-shell/
90 sudo -u git -H cp config.yml.example config.yml
91 sudo -u git -H ./bin/install
92}
93
88function set_admin_password() {94function set_admin_password() {
89 encrypted_password=`ruby -e 'require "bcrypt"; puts BCrypt::Password.create(ARGV[0], :cost => 10)' $admin_password`95 encrypted_password=`ruby -e 'require "bcrypt"; puts BCrypt::Password.create(ARGV[0], :cost => 10)' $admin_password`
90 # TODO: allow for email to be config'ed too96 # TODO: allow for email to be config'ed too
@@ -99,9 +105,13 @@
99init_database105init_database
100set_admin_password106set_admin_password
101precompile107precompile
108install_git_shell
102109
103juju-log "Opening port 80"110juju-log "Opening port 80"
104open-port 80/tcp111open-port 80/tcp
105112
106juju-log "Starting Nginx and GitLab"113juju-log "Starting GitLab"
107hooks/start114sudo service gitlab start
115juju-log "Starting nginx"
116sudo service nginx start
117
108118
=== modified file 'hooks/install'
--- hooks/install 2013-02-01 22:47:17 +0000
+++ hooks/install 2014-05-09 15:56:56 +0000
@@ -58,13 +58,9 @@
58 git58 git
5959
60 # This user is for gitlab, a web gui for managing your git repositories60 # This user is for gitlab, a web gui for managing your git repositories
61 sudo adduser --disabled-login --gecos 'GitLab' gitlab
6261
63 # Add it to the git group
64 sudo usermod -a -G git gitlab
65
66 # Generate the SSH key62 # Generate the SSH key
67 sudo -u gitlab -H ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa63 sudo -u git -H ssh-keygen -q -N '' -t rsa -f /home/git/.ssh/id_rsa
68}64}
6965
70function install_gitolite() {66function install_gitolite() {
@@ -79,8 +75,8 @@
79 sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'75 sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'
8076
81 # Copy the gitlab user's (public) SSH key ...77 # Copy the gitlab user's (public) SSH key ...
82 sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub78 sudo cp /home/git/.ssh/id_rsa.pub /home/git/gitlab.pub
83 sudo chmod 0444 /home/git/gitlab.pub 79 sudo chmod 0444 /home/git/gitlab.pub
8480
85 # ... and use it as the admin key for the Gitolite setup81 # ... and use it as the admin key for the Gitolite setup
86 sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"82 sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
@@ -88,19 +84,19 @@
88 # Make sure the Gitolite config dir is owned by git84 # Make sure the Gitolite config dir is owned by git
89 sudo chmod 750 /home/git/.gitolite/85 sudo chmod 750 /home/git/.gitolite/
90 sudo chown -R git:git /home/git/.gitolite/86 sudo chown -R git:git /home/git/.gitolite/
91 87
92 # Make sure the repositories dir is owned by git and it stays that way88 # Make sure the repositories dir is owned by git and it stays that way
93 sudo chmod -R ug+rwXs,o-rwx /home/git/repositories/89 sudo chmod -R ug+rwXs,o-rwx /home/git/repositories/
94 sudo chown -R git:git /home/git/repositories/90 sudo chown -R git:git /home/git/repositories/
9591
96 # Adds localhost ssh key to gitlab's known_hosts92 # Adds localhost ssh key to gitlab's known_hosts
97 sudo -u gitlab -H sh -c 'ssh-keyscan -H localhost >> ~/.ssh/known_hosts'93 sudo -u git -H sh -c 'ssh-keyscan -H localhost >> ~/.ssh/known_hosts'
98}94}
9995
100function test_gitolite() {96function test_gitolite() {
101 # Clone the admin repo so SSH adds localhost to known_hosts ...97 # Clone the admin repo so SSH adds localhost to known_hosts ...
102 # ... and to be sure your users have access to Gitolite98 # ... and to be sure your users have access to Gitolite
103 sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin99 sudo -u git -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
104100
105 # If it succeeded without errors you can remove the cloned repo101 # If it succeeded without errors you can remove the cloned repo
106 sudo rm -rf /tmp/gitolite-admin102 sudo rm -rf /tmp/gitolite-admin
@@ -108,20 +104,21 @@
108104
109function install_gitlab() {105function install_gitlab() {
110 # We'll install GitLab into home directory of the user "gitlab"106 # We'll install GitLab into home directory of the user "gitlab"
111 cd /home/gitlab107 cd /home/git
112108
113 # Clone GitLab repository109 # Clone GitLab repository
114 sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab110 sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
111 sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.9.3
115112
116 # Go to gitlab dir 113 # Go to gitlab dir
117 cd /home/gitlab/gitlab114 cd /home/git/gitlab
118115
119 # Checkout to stable release116 # Checkout to stable release
120 sudo -u gitlab -H git checkout 4-1-stable117 sudo -u git -H git checkout 6-8-stable
121}118}
122119
123function configure_gitlab() {120function configure_gitlab() {
124 cd /home/gitlab/gitlab121 cd /home/git/gitlab
125122
126 # Copy the example GitLab config123 # Copy the example GitLab config
127 #sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml124 #sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml
@@ -130,45 +127,45 @@
130 # charm config127 # charm config
131 host=`config-get host`128 host=`config-get host`
132 # TODO: add default values129 # TODO: add default values
133 sudo -u gitlab -H sh -c "sed -e 's/^ host: localhost/ host: $host/g' < config/gitlab.yml.example > config/gitlab.yml"130 sudo -u git -H sh -c "sed -e 's/^ host: localhost/ host: $host/g' < config/gitlab.yml.example > config/gitlab.yml"
134131
135 # TODO: update other config items in gitlab.yml132 # TODO: update other config items in gitlab.yml
136 # sed -itmp133 # sed -itmp
137134
138 # Make sure GitLab can write to the log/ and tmp/ directories135 # Make sure GitLab can write to the log/ and tmp/ directories
139 sudo chown -R gitlab log/136 sudo chown -R git log/
140 sudo chown -R gitlab tmp/137 sudo chown -R git tmp/
141 sudo chmod -R u+rwX log/138 sudo chmod -R u+rwX log/
142 sudo chmod -R u+rwX tmp/139 sudo chmod -R u+rwX tmp/
143140
144 # Make directory for satellites141 # Make directory for satellites
145 sudo -u gitlab -H mkdir /home/gitlab/gitlab-satellites142 sudo -u git -H mkdir /home/git/gitlab-satellites
146 143
147 # Copy the example Unicorn config144 # Copy the example Unicorn config
148 sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb145 sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
149}146}
150147
151function configure_git {148function configure_git {
152 sudo -u gitlab -H git config --global user.name "GitLab"149 sudo -u git -H git config --global user.name "GitLab"
153 # TODO: get from charm config.yaml150 # TODO: get from charm config.yaml
154 sudo -u gitlab -H git config --global user.email "gitlab@localhost"151 sudo -u git -H git config --global user.email "gitlab@localhost"
155}152}
156153
157function setup_gitlab_hooks() {154function setup_gitlab_hooks() {
158 cd ~gitlab/gitlab155 cd ~git/gitlab
159 sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive156 sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
160 sudo chown git:git /home/git/.gitolite/hooks/common/post-receive157 sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
161 cd -158 cd -
162}159}
163160
164function init_script() {161function init_script() {
165 sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/4-1-stable/init.d/gitlab162 sudo curl --output /etc/init.d/gitlab https://raw.githubusercontent.com/gitlabhq/gitlabhq/fefa10c3c208cb0cce6e25e498221d1d97d26238/lib/support/init.d/gitlab
166 sudo chmod +x /etc/init.d/gitlab163 sudo chmod +x /etc/init.d/gitlab
167 sudo update-rc.d gitlab defaults 21164 sudo update-rc.d gitlab defaults 21
168}165}
169166
170function config_nginx() {167function config_nginx() {
171 sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/4-1-stable/nginx/gitlab168 sudo curl --output /etc/nginx/sites-available/gitlab https://raw.githubusercontent.com/gitlabhq/gitlabhq/fefa10c3c208cb0cce6e25e498221d1d97d26238/lib/support/nginx/gitlab
172 sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab169 sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
173 # TODO: allow for config of hostname170 # TODO: allow for config of hostname
174 sed -i -e 's/YOUR_SERVER_IP/0.0.0.0/g' /etc/nginx/sites-available/gitlab171 sed -i -e 's/YOUR_SERVER_IP/0.0.0.0/g' /etc/nginx/sites-available/gitlab
@@ -182,6 +179,6 @@
182install_gitlab179install_gitlab
183configure_gitlab180configure_gitlab
184configure_git181configure_git
185setup_gitlab_hooks182#setup_gitlab_hooks
186init_script183init_script
187config_nginx184config_nginx
188185
=== modified file 'hooks/start'
--- hooks/start 2013-02-01 22:47:17 +0000
+++ hooks/start 2014-05-09 15:56:56 +0000
@@ -1,6 +1,6 @@
1#!/bin/bash1#!/bin/bash
2# Avoid starting a unconfigured instance that has no database2# Avoid starting a unconfigured instance that has no database
3if [ -f ~gitlab/gitlab/config/database.yml ]; then3if [ -f ~git/gitlab/config/database.yml ]; then
4 juju-log "Starting GitLab"4 juju-log "Starting GitLab"
5 sudo service gitlab start5 sudo service gitlab start
6 juju-log "Starting nginx"6 juju-log "Starting nginx"

Subscribers

People subscribed via source and target branches

to all changes: