BigW Consortium Gitlab

4.2-to-5.0.md 5.56 KB
Newer Older
1 2 3 4
---
comments: false
---

5
# From 4.2 to 5.0
6
*Make sure you view this [upgrade guide from the `master` branch](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/update/4.2-to-5.0.md) for the most up to date instructions.*
7

8
## Warning
9

10
GitLab 5.0 is affected by critical security vulnerability CVE-2013-4490.
11

12 13
## Important changes

14
- We don't use `gitlab` user any more. Everything will be moved to `git` user
15
- Self signed SSL certificates are not supported until GitLab 5.1
16
- **requires ruby1.9.3**
17

18
## 0. Stop GitLab
19 20 21

    sudo service gitlab stop

22
## 1. add bash to git user
23 24 25 26 27

```
sudo chsh -s /bin/bash git
```

28
## 2. git clone gitlab-shell
29 30

```
31
cd /home/git/
32 33 34
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git /home/git/gitlab-shell
```

35
## 3. setup gitlab-shell
36 37 38 39 40 41 42 43

```bash
# chmod all repos and files under git
sudo chown git:git -R /home/git/repositories/

# login as git
sudo su git
cd /home/git/gitlab-shell
44
git checkout v1.1.0
45 46 47 48

# copy config
cp config.yml.example config.yml

49 50
# change URL to GitLab instance
# ! make sure the URL ends with '/' like 'https://gitlab.example/'
51 52 53 54 55 56
vim config.yml

# rewrite hooks
./support/rewrite-hooks.sh

# check ruby version for git user ( 1.9 required!! )
57
# GitLab shell requires system ruby 1.9
58 59 60 61 62 63
ruby -v

# exit from git user
exit
```

64
## 4. Copy GitLab instance to git user
65 66 67 68 69 70 71 72 73 74

```bash
sudo cp -R /home/gitlab/gitlab /home/git/gitlab
sudo chown git:git -R /home/git/gitlab
sudo rm -rf /home/gitlab/gitlab-satellites

# if exists
sudo rm /tmp/gitlab.socket
```

75
## 5. Update GitLab to recent version
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

```bash
cd /home/git/gitlab

# backup current config
sudo -u git -H cp config/gitlab.yml config/gitlab.yml.old

sudo -u git -H git fetch
sudo -u git -H git checkout 5-0-stable

# replace config with recent one
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

# edit it
sudo -u git -H vim config/gitlab.yml

92 93 94 95
# The Modernizr gem was yanked from RubyGems. It is required for GitLab >= 2.8.0
# Edit `Gemfile` and change `gem "modernizr", "2.5.3"` to
# `gem "modernizr-rails", "2.7.1"``
sudo -u git -H vim Gemfile
96

97 98 99 100
# Run a bundle install without deployment to generate the new Gemfile
sudo -u git -H bundle install --without development test postgres --no-deployment

# Install libs (with deployment this time)
101
sudo -u git -H bundle install --without development test postgres --deployment
102

103 104 105 106
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:shell:build_missing_projects RAILS_ENV=production

107
sudo -u git -H mkdir -p /home/git/gitlab-satellites
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production

# migrate wiki to git
sudo -u git -H bundle exec rake gitlab:wiki:migrate RAILS_ENV=production


# check permissions for /home/git/.ssh/
sudo -u git -H chmod 700 /home/git/.ssh
sudo -u git -H chmod 600 /home/git/.ssh/authorized_keys

# check permissions for /home/git/gitlab/
sudo chown -R git /home/git/gitlab/log/
sudo chown -R git /home/git/gitlab/tmp/
sudo chmod -R u+rwX  /home/git/gitlab/log/
sudo chmod -R u+rwX  /home/git/gitlab/tmp/
123
sudo -u git -H mkdir -p /home/git/gitlab/tmp/pids/
124 125 126 127
sudo chmod -R u+rwX  /home/git/gitlab/tmp/pids

```

128
## 6. Update init.d script and Nginx config
129 130 131 132

```bash
# init.d
sudo rm /etc/init.d/gitlab
133
sudo curl --location --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-0-stable/init.d/gitlab
134 135 136 137 138 139
sudo chmod +x /etc/init.d/gitlab

# unicorn
sudo -u git -H cp /home/git/gitlab/config/unicorn.rb /home/git/gitlab/config/unicorn.rb.old
sudo -u git -H cp /home/git/gitlab/config/unicorn.rb.example /home/git/gitlab/config/unicorn.rb

140
# Nginx
141 142 143 144 145 146
# Replace path from '/home/gitlab/' to '/home/git/'
sudo vim /etc/nginx/sites-enabled/gitlab
sudo service nginx restart

```

147
## 7. Start GitLab instance
148 149 150 151 152 153

```
sudo service gitlab start

# check if unicorn and sidekiq started
# If not try to logout, also check replaced path from '/home/gitlab/' to '/home/git/'
154
# in Nginx, unicorn, init.d etc
155 156 157 158 159
ps aux | grep unicorn
ps aux | grep sidekiq

```

160
## 8. Check installation
161 162 163 164 165 166 167 168 169 170 171 172 173


```bash
# In 5-10 seconds lets check gitlab-shell
sudo -u git -H /home/git/gitlab-shell/bin/check

# Example of success output
# Check GitLab API access: OK
# Check directories and files:
#         /home/git/repositories: OK
#         /home/git/.ssh/authorized_keys: OK


174
# Now check GitLab instance
175 176 177 178
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

```

179 180 181 182
## 9. Cleanup

**If everything works as expected you can cleanup some old things**
Recommend you wait a bit and do a backup before completing the following.
Ben Bodenmiller committed
183 184

```bash
185
# remove GitLab user from system
Ben Bodenmiller committed
186
sudo userdel -r gitlab
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

cd /home/git

# cleanup .profile
## remove text from .profile added during gitolite installation:
##   PATH=\$PATH:/home/git/bin
##   export PATH
## to see what a clean .profile for new users on your system would look like see /etc/skel/.profile
sudo -u git -H vim .profile

# remove gitolite
sudo rm -R bin
sudo rm -Rf gitolite
sudo rm -R .gitolite
sudo rm .gitolite.rc
sudo rm -f gitlab.pub
sudo rm projects.list

# reset tmp folders
sudo service gitlab stop
cd /home/git/gitlab
sudo rm -R tmp
sudo -u git -H mkdir tmp
sudo chmod -R u+rwX  tmp/

212 213 214 215 216 217
# create directory for pids, make sure GitLab can write to it
sudo -u git -H mkdir tmp/pids/
sudo chmod -R u+rwX  tmp/pids/

# if you are already running a newer version of GitLab check that installation guide for other tmp folders you need to create

218 219 220 221 222 223
# reboot system
sudo reboot

# login, check that GitLab is running fine
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Ben Bodenmiller committed
224
```