Commit 0f502fa6b6ce209eaea043e4dd4a57dee11ddce3

Authored by Sytse Sijbrandij
2 parents da68aeb3 a2f049cf

Merge branch 'specify_url' into 'master'

Specify Url
@@ -8,7 +8,7 @@ GitLab! @@ -8,7 +8,7 @@ GitLab!
8 After the steps below your GitLab instance should reachable over HTTP, 8 After the steps below your GitLab instance should reachable over HTTP,
9 and have an admin user with username `root` and password `5iveL!fe`. 9 and have an admin user with username `root` and password `5iveL!fe`.
10 10
11 -### Ubuntu 11 +### Ubuntu 12.04
12 12
13 ``` 13 ```
14 sudo apt-get install openssh-server 14 sudo apt-get install openssh-server
@@ -30,28 +30,59 @@ sudo lokkit -s http -s ssh @@ -30,28 +30,59 @@ sudo lokkit -s http -s ssh
30 30
31 ## How to manage an Omnibus-installed GitLab 31 ## How to manage an Omnibus-installed GitLab
32 32
33 -### Administrative commands 33 +### Start/stop GitLab
34 34
35 -You can make configuration changes by editing `/etc/gitlab/gitlab.rb` and  
36 -`/etc/gitlab/gitlab-secrets.json`, followed by running 35 +You can start, stop or restart GitLab and all of its components with the
  36 +following commands.
37 37
  38 +```shell
  39 +# Start all GitLab components
  40 +sudo gitlab-ctl start
  41 +
  42 +# Stop all GitLab components
  43 +sudo gitlab-ctl stop
  44 +
  45 +# Restart all GitLab components
  46 +sudo gitlab-ctl restart
38 ``` 47 ```
39 -sudo gitlab-ctl reconfigure 48 +
  49 +It is also possible to start, stop or restart individual components.
  50 +
  51 +```shell
  52 +sudo gitlab-ctl restart unicorn
  53 +```
  54 +
  55 +### Creating the gitlab.rb configuration file
  56 +
  57 +```shell
  58 +sudo mkdir -p /etc/gitlab
  59 +sudo touch /etc/gitlab/gitlab.rb
  60 +sudo chmod 600 /etc/gitlab/gitlab.rb
40 ``` 61 ```
41 62
42 -To start/stop a component of GitLab run e.g.  
43 -`sudo gitlab-ctl stop sidekiq`. To permanently disable e.g. Sidekiq, add  
44 -`sidekiq['enable'] = false` to `/etc/gitlab/gitlab.rb`, and run  
45 -`sudo gitlab-ctl reconfigure` for the change to take effect. 63 +### Configuring the external URL for GitLab
46 64
47 -To invoke a GitLab rake task, use `gitlab-rake`. For example: 65 +In order for GitLab to display correct repository clone links to your users
  66 +it needs to know the URL under which it is reached by your users, e.g.
  67 +`http://gitlab.example.com`. Add the following line to `/etc/gitlab/gitlab.rb`:
48 68
  69 +```ruby
  70 +external_url "http://gitlab.example.com"
49 ``` 71 ```
  72 +
  73 +Run `sudo gitlab-ctl reconfigure` for the change to take effect.
  74 +
  75 +### Invoking Rake tasks
  76 +
  77 +To invoke a GitLab Rake task, use `gitlab-rake`. For example:
  78 +
  79 +```shell
50 sudo gitlab-rake gitlab:backup:create 80 sudo gitlab-rake gitlab:backup:create
51 ``` 81 ```
52 82
53 -There is no need to change the user or the `RAILS_ENV` environment variable;  
54 -this is taken care of by the `gitlab-rake` wrapper script. 83 +Contrary to with a traditional GitLab installation, there is no need to change
  84 +the user or the `RAILS_ENV` environment variable; this is taken care of by the
  85 +`gitlab-rake` wrapper script.
55 86
56 ### Directory structure 87 ### Directory structure
57 88
@@ -67,4 +98,4 @@ Omnibus-gitlab uses four different directories. @@ -67,4 +98,4 @@ Omnibus-gitlab uses four different directories.
67 98
68 ## Building your own package 99 ## Building your own package
69 100
70 -See (doc/build.md). 101 +See [the separate build documentation](doc/build.md).
files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
@@ -21,11 +21,13 @@ require 'chef/mash' @@ -21,11 +21,13 @@ require 'chef/mash'
21 require 'chef/json_compat' 21 require 'chef/json_compat'
22 require 'chef/mixin/deep_merge' 22 require 'chef/mixin/deep_merge'
23 require 'securerandom' 23 require 'securerandom'
  24 +require 'uri'
24 25
25 module Gitlab 26 module Gitlab
26 extend(Mixlib::Config) 27 extend(Mixlib::Config)
27 28
28 bootstrap Mash.new 29 bootstrap Mash.new
  30 + user Mash.new
29 postgresql Mash.new 31 postgresql Mash.new
30 redis Mash.new 32 redis Mash.new
31 gitlab_rails Mash.new 33 gitlab_rails Mash.new
@@ -33,6 +35,7 @@ module Gitlab @@ -33,6 +35,7 @@ module Gitlab
33 sidekiq Mash.new 35 sidekiq Mash.new
34 nginx Mash.new 36 nginx Mash.new
35 node nil 37 node nil
  38 + external_url nil
36 39
37 class << self 40 class << self
38 41
@@ -72,10 +75,39 @@ module Gitlab @@ -72,10 +75,39 @@ module Gitlab
72 end 75 end
73 end 76 end
74 77
  78 + def parse_external_url
  79 + return unless external_url
  80 +
  81 + uri = URI(external_url.to_s)
  82 +
  83 + unless uri.host
  84 + raise "External URL must include a FQDN"
  85 + end
  86 + Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}"
  87 + Gitlab['gitlab_rails']['external_fqdn'] = uri.host
  88 + Gitlab['gitlab_rails']['notification_email'] ||= "gitlab@#{uri.host}"
  89 +
  90 + case uri.scheme
  91 + when "http"
  92 + Gitlab['gitlab_rails']['external_https'] = false
  93 + when "https"
  94 + Gitlab['gitlab_rails']['external_https'] = true
  95 + else
  96 + raise "Unsupported external URL scheme: #{uri.scheme}"
  97 + end
  98 +
  99 + unless ["", "/"].include?(uri.path)
  100 + raise "Unsupported external URL path: #{uri.path}"
  101 + end
  102 +
  103 + Gitlab['gitlab_rails']['external_port'] = uri.port
  104 + end
  105 +
75 def generate_hash 106 def generate_hash
76 results = { "gitlab" => {} } 107 results = { "gitlab" => {} }
77 [ 108 [
78 "bootstrap", 109 "bootstrap",
  110 + "user",
79 "redis", 111 "redis",
80 "gitlab_rails", 112 "gitlab_rails",
81 "unicorn", 113 "unicorn",
@@ -92,6 +124,7 @@ module Gitlab @@ -92,6 +124,7 @@ module Gitlab
92 124
93 def generate_config(node_name) 125 def generate_config(node_name)
94 generate_secrets(node_name) 126 generate_secrets(node_name)
  127 + parse_external_url
95 generate_hash 128 generate_hash
96 end 129 end
97 end 130 end