From 905aa634de8201a00d245a814c9931786b313bcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=89=E5=A5=BD=E8=89=AF=E5=92=8C?=
 <y.miyoshi@gloops.com>
Date: Thu, 23 May 2013 18:32:37 +0900
Subject: [PATCH 1/5] Fixed "recipe_content" path for 5-2-stable

---
 lib/tasks/gitlab/check.rake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 5e4a74b6260..94fd8b03016 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -144,7 +144,7 @@ namespace :gitlab do
         return
       end
 
-      recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab 2>/dev/null`
+      recipe_content = `curl https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab 2>/dev/null`
       script_content = File.read(script_path)
 
       if recipe_content == script_content
-- 
GitLab


From 37c6348d332d3eaaf70149be2ccfc62ae4d00eb0 Mon Sep 17 00:00:00 2001
From: Ben Bodenmiller <bbodenmiller@hotmail.com>
Date: Fri, 24 May 2013 16:53:32 -0700
Subject: [PATCH 2/5] update upgrade guide with backup, db specific commands,
 config changes, check, and restore

---
 doc/update/5.1-to-5.2.md | 59 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/doc/update/5.1-to-5.2.md b/doc/update/5.1-to-5.2.md
index 8f2116837b8..3f874555f49 100644
--- a/doc/update/5.1-to-5.2.md
+++ b/doc/update/5.1-to-5.2.md
@@ -1,5 +1,15 @@
 # From 5.1 to 5.2
 
+### 0. Backup
+
+It's useful to make a backup just in case things go south:
+(With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version)
+
+```bash
+cd /home/git/gitlab
+sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create
+```
+
 ### 1. Stop server
 
     sudo service gitlab stop
@@ -20,14 +30,59 @@ sudo -u git -H git fetch
 sudo -u git -H git checkout v1.4.0
 ```
 
-### 4. Install libs, migrations etc
+### 4. Install libs, migrations, etc.
 
 ```bash
 cd /home/git/gitlab
+
+# MySQL
 sudo -u git -H bundle install --without development test postgres --deployment
+
+#PostgreSQL
+sudo -u git -H bundle install --without development test mysql --deployment
+
 sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
 ```
 
-### 5. Start application
+### 5. Update config files
+
+* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/5-2-stable/config/gitlab.yml.example but with your settings.
+* Make `/home/git/gitlab/config/puma.rb` same as https://github.com/gitlabhq/gitlabhq/blob/5-2-stable/config/puma.rb.example but with your settings.
+
+### 6. Update Init script
+
+```bash
+sudo rm /etc/init.d/gitlab
+sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab
+sudo chmod +x /etc/init.d/gitlab
+```
+
+### 6. Start application
 
     sudo service gitlab start
+    sudo service nginx restart
+
+### 7. Check application status
+
+Check if GitLab and its environment are configured correctly:
+
+    sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
+
+To make sure you didn't miss anything run a more thorough check with:
+
+    sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
+
+If all items are green, then congratulations upgrade complete!
+
+## Things went south? Revert to previous version (5.1)
+
+### 1. Revert the code to the previous version
+Follow the [`upgrade guide from 5.0 to 5.1`](5.0-to-5.1.md), except for the database migration 
+(The backup is already migrated to the previous version)
+
+### 2. Restore from the backup:
+
+```bash
+cd /home/git/gitlab
+sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:restore
+```
-- 
GitLab


From a9975336e8bf26c64345aa7eb067d9fee52602c3 Mon Sep 17 00:00:00 2001
From: MeiHui FAN <mhfan@ustc.edu>
Date: Thu, 16 May 2013 11:59:26 +0800
Subject: [PATCH 3/5] improve regrex for match(sidekiq) robustness

e.g.: the sidekiq in my Debian box is v2.11.1
---
 lib/tasks/gitlab/check.rake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 94fd8b03016..4c3a607a713 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -588,7 +588,7 @@ namespace :gitlab do
     def check_sidekiq_running
       print "Running? ... "
 
-      if run_and_match("ps aux | grep -i sidekiq", /sidekiq \d\.\d\.\d.+$/)
+      if run_and_match("ps aux | grep -i sidekiq", /sidekiq \d+\.\d+\.\d+.+$/)
         puts "yes".green
       else
         puts "no".red
-- 
GitLab


From b5668bf6008a1b0c0a4dcd25bce9add470e53394 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Salmer=C3=B3n=20Amselem?=
 <daniel.amselem@gmail.com>
Date: Wed, 29 May 2013 01:13:42 +0300
Subject: [PATCH 4/5] Fix typo in smtp_settings.rb.sample

---
 config/initializers/smtp_settings.rb.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config/initializers/smtp_settings.rb.sample b/config/initializers/smtp_settings.rb.sample
index 333c388f5ff..e62ad0f4b71 100644
--- a/config/initializers/smtp_settings.rb.sample
+++ b/config/initializers/smtp_settings.rb.sample
@@ -1,7 +1,7 @@
 # To enable smtp email delivery for your GitLab instance do next: 
 # 1. Change config/environments/production.rb to use smtp
 #    config.action_mailer.delivery_method = :smtp
-# 2. Rename this file to smpt_settings.rb
+# 2. Rename this file to smtp_settings.rb
 # 3. Edit settings inside this file
 # 4. Restart GitLab instance
 #
-- 
GitLab


From 86874f00c36a543e12ea2b086908e73f92a50d5b Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Tue, 28 May 2013 17:08:21 +0300
Subject: [PATCH 5/5] init.d: Ensure socket is removed before starting service

---
 lib/support/init.d/gitlab | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab
index 4c5499bbf23..f4ca07b3676 100644
--- a/lib/support/init.d/gitlab
+++ b/lib/support/init.d/gitlab
@@ -2,7 +2,7 @@
 
 # GITLAB
 # Maintainer: @randx
-# App Version: 5.1
+# App Version: 5.2
 
 ### BEGIN INIT INFO
 # Provides:          gitlab
@@ -19,6 +19,7 @@ APP_ROOT="/home/git/gitlab"
 APP_USER="git"
 DAEMON_OPTS="-C $APP_ROOT/config/puma.rb"
 PID_PATH="$APP_ROOT/tmp/pids"
+SOCKET_PATH="$APP_ROOT/tmp/sockets"
 WEB_SERVER_PID="$PID_PATH/puma.pid"
 SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
 STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
@@ -50,6 +51,7 @@ start() {
     exit 1
   else
     if [ `whoami` = root ]; then
+      execute "rm $SOCKET_PATH/gitlab.socket"
       execute "RAILS_ENV=production bundle exec puma $DAEMON_OPTS"
       execute "mkdir -p $PID_PATH && $START_SIDEKIQ  > /dev/null  2>&1 &"
       echo "$DESC started"
-- 
GitLab