[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#854658: unblock pre-approval request for gitlab



On ഞായര്‍ 12 ഫെബ്രുവരി 2017 12:24 രാവിലെ, Niels Thykier wrote:
> The two patches in the bug looks ok; assuming only a changelog entry on
> top of that, then it is a approved.
>
> For future requests: Could you please provide a source debdiff? It makes
> it easier for us for us to figure out what will be approved (which will
> hopefully also give you faster response times from us).
Attaching the debdiff (I'll upload it once current version in unstable
migrates to testing).

I just wanted to check if such changes will be accepted before starting
the work on it.
diff -Nru gitlab-8.13.11+dfsg/debian/adduser.sh gitlab-8.13.11+dfsg/debian/adduser.sh
--- gitlab-8.13.11+dfsg/debian/adduser.sh	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/adduser.sh	2017-02-16 17:35:29.000000000 +0530
@@ -8,9 +8,9 @@
 
 # Create gitlab user with home in /var/lib
 echo "Creating/updating ${gitlab_user} user account..."
-adduser --system --home /var/lib/${gitlab_user} --gecos "${gitlab_user} user" --shell /bin/sh \
+adduser --system --home ${gitlab_data_dir} --gecos "${gitlab_user} user" --shell /bin/sh \
 	--quiet --disabled-password --group ${gitlab_user} || {
 echo "Proceeding with existing ${gitlab_user} user..."
   }
-echo "Making ${gitlab_user} owner of /var/lib/${gitlab_user}..."
-chown -R ${gitlab_user} /var/lib/${gitlab_user}
+echo "Making ${gitlab_user} owner of ${gitlab_data_dir}..."
+chown -R ${gitlab_user} ${gitlab_data_dir}
diff -Nru gitlab-8.13.11+dfsg/debian/changelog gitlab-8.13.11+dfsg/debian/changelog
--- gitlab-8.13.11+dfsg/debian/changelog	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/changelog	2017-02-16 17:35:29.000000000 +0530
@@ -1,3 +1,14 @@
+gitlab (8.13.11+dfsg-3) unstable; urgency=medium
+
+  * Allow choosing gitlab user (Closes: #854617)
+  * Optionally remove all data on purge (Closes: #821087, #839929)
+
+  [ Johannes Schauer ]
+  * Amend the README.Debian with instructions of how to upgrade from
+    non-Debian installations (Closes: #823743)
+
+ -- Pirate Praveen <praveen@debian.org>  Thu, 16 Feb 2017 17:35:29 +0530
+
 gitlab (8.13.11+dfsg-2) unstable; urgency=medium
 
   * Use upstream patch for git 2.11 support (Closes: #853251)
diff -Nru gitlab-8.13.11+dfsg/debian/conf/gitlab-debian.conf.example gitlab-8.13.11+dfsg/debian/conf/gitlab-debian.conf.example
--- gitlab-8.13.11+dfsg/debian/conf/gitlab-debian.conf.example	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/conf/gitlab-debian.conf.example	2017-02-16 17:35:29.000000000 +0530
@@ -1,6 +1,5 @@
 RAILS_ENV=production
 DB=postgres
-gitlab_user=gitlab
 gitlab_app_root=/usr/share/gitlab
 gitlab_data_dir=/var/lib/gitlab
 gitlab_cache_path=/var/cache/gitlab
@@ -20,6 +19,9 @@
 gitlab_shell_log=/var/log/gitlab-shell
 gitlab_log_dir=/var/log/gitlab
 gitlab_pid_path=/run/gitlab
+gitlab_tmpfiles_example=/usr/share/doc/gitlab/tmpfiles.d/gitlab.conf.example
+gitlab_tmpfiles_private=/var/lib/gitlab/tmpfiles.d-gitlab.conf
+gitlab_tmpfiles=/usr/lib/tmpfiles.d/gitlab.conf
 nginx_user=www-data
 nginx_conf_example=/usr/share/doc/gitlab/nginx.conf.example
 nginx_ssl_conf_example_gz=/usr/share/doc/gitlab/nginx.ssl.conf.example.gz
diff -Nru gitlab-8.13.11+dfsg/debian/conf/gitlab.yml.example gitlab-8.13.11+dfsg/debian/conf/gitlab.yml.example
--- gitlab-8.13.11+dfsg/debian/conf/gitlab.yml.example	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/conf/gitlab.yml.example	2017-02-16 17:35:29.000000000 +0530
@@ -46,7 +46,7 @@
     # relative_url_root: /gitlab
 
     # Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
-    user: gitlab
+    user: GITLAB_USER
     user_home: /var/lib/gitlab
 
     ## Date & Time settings
diff -Nru gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf
--- gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf	1970-01-01 05:30:00.000000000 +0530
@@ -1,2 +0,0 @@
-d /run/gitlab 2750 gitlab www-data -
-L /run/gitlab/cache - - - - /var/cache/gitlab
diff -Nru gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf.example gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf.example
--- gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf.example	1970-01-01 05:30:00.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/conf/tmpfiles.d/gitlab.conf.example	2017-02-16 17:35:29.000000000 +0530
@@ -0,0 +1,2 @@
+d /run/gitlab 2750 GITLAB_USER www-data -
+L /run/gitlab/cache - - - - /var/cache/gitlab
diff -Nru gitlab-8.13.11+dfsg/debian/config gitlab-8.13.11+dfsg/debian/config
--- gitlab-8.13.11+dfsg/debian/config	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/config	2017-02-16 17:35:29.000000000 +0530
@@ -24,3 +24,7 @@
     db_go
   fi
 fi
+
+# Do you want to change gitlab user?
+db_input high gitlab/user || true
+db_go
diff -Nru gitlab-8.13.11+dfsg/debian/gitlab.gitlab-mailroom.service gitlab-8.13.11+dfsg/debian/gitlab.gitlab-mailroom.service
--- gitlab-8.13.11+dfsg/debian/gitlab.gitlab-mailroom.service	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/gitlab.gitlab-mailroom.service	2017-02-16 17:35:29.000000000 +0530
@@ -9,7 +9,6 @@
 
 [Service]
 Type=simple
-User=gitlab
 WorkingDirectory=/usr/share/gitlab
 EnvironmentFile=/etc/gitlab/gitlab-debian.conf
 SyslogIdentifier=gitlab-mailroom
diff -Nru gitlab-8.13.11+dfsg/debian/gitlab.gitlab-sidekiq.service gitlab-8.13.11+dfsg/debian/gitlab.gitlab-sidekiq.service
--- gitlab-8.13.11+dfsg/debian/gitlab.gitlab-sidekiq.service	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/gitlab.gitlab-sidekiq.service	2017-02-16 17:35:29.000000000 +0530
@@ -9,7 +9,6 @@
 
 [Service]
 Type=simple
-User=gitlab
 WorkingDirectory=/usr/share/gitlab
 EnvironmentFile=/etc/gitlab/gitlab-debian.conf
 SyslogIdentifier=gitlab-sidekiq
diff -Nru gitlab-8.13.11+dfsg/debian/gitlab.gitlab-unicorn.service gitlab-8.13.11+dfsg/debian/gitlab.gitlab-unicorn.service
--- gitlab-8.13.11+dfsg/debian/gitlab.gitlab-unicorn.service	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/gitlab.gitlab-unicorn.service	2017-02-16 17:35:29.000000000 +0530
@@ -9,7 +9,6 @@
 
 [Service]
 Type=simple
-User=gitlab
 WorkingDirectory=/usr/share/gitlab
 EnvironmentFile=/etc/gitlab/gitlab-debian.conf
 EnvironmentFile=-/etc/default/gitlab
diff -Nru gitlab-8.13.11+dfsg/debian/gitlab.gitlab-workhorse.service gitlab-8.13.11+dfsg/debian/gitlab.gitlab-workhorse.service
--- gitlab-8.13.11+dfsg/debian/gitlab.gitlab-workhorse.service	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/gitlab.gitlab-workhorse.service	2017-02-16 17:35:29.000000000 +0530
@@ -9,7 +9,6 @@
 
 [Service]
 Type=simple
-User=gitlab
 WorkingDirectory=/usr/share/gitlab
 EnvironmentFile=/etc/gitlab/gitlab-debian.conf
 SyslogIdentifier=gitlab-workhorse
diff -Nru gitlab-8.13.11+dfsg/debian/gitlab.templates gitlab-8.13.11+dfsg/debian/gitlab.templates
--- gitlab-8.13.11+dfsg/debian/gitlab.templates	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/gitlab.templates	2017-02-16 17:35:29.000000000 +0530
@@ -11,6 +11,15 @@
  If a reverse proxy is used, give the hostname that the proxy server
  responds to.
 
+Template: gitlab/user
+Type: string
+Default: gitlab
+_Description: Operating System user for this instance of Gitlab:
+ Please choose the username of the user used to run this instance of Gitlab.
+ .
+ This username will also be used in SSH urls of projects hosted with this
+ instance of Gitlab. For example, git@git.example.com:foo/bar.git
+
 Template: gitlab/ssl
 Type: boolean
 Default: false
@@ -48,3 +57,10 @@
  Note: letsencrypt does not have a usable nginx plugin currently, so
  certificates must be renewed manually after 3 months, when current
  letsencrypt certificate expire.
+
+Template: gitlab/purge
+Type: boolean
+Default: true 
+_Description: Remove all data?
+ This will permanently remove all data of this Gitlab instance such as database,
+ repositories, uploaded files, SSH public keys etc.
diff -Nru gitlab-8.13.11+dfsg/debian/grantpriv.sh gitlab-8.13.11+dfsg/debian/grantpriv.sh
--- gitlab-8.13.11+dfsg/debian/grantpriv.sh	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/grantpriv.sh	2017-02-16 17:35:29.000000000 +0530
@@ -1,30 +1,25 @@
 #!/bin/sh
+set -e
 
-user=gitlab
 dbname=gitlab_production
 
+# Take gitlab_user from envornment variable or use gitlab
+gitlab_user=${gitlab_user:-gitlab}
+
 # If gitlab user cannot access gitlab_production,
 # then it means the gitlab role does not exist
-if ! su gitlab -c 'psql gitlab_production -c ""'
+if ! su ${gitlab_user} -c 'psql gitlab_production -c ""'
 then
-	echo "Create $user user with create database privillege..."
-	su postgres -c "psql -c \"CREATE USER $user CREATEDB;\"" || {
-	  exit 1 
-	  }
+	echo "Create ${gitlab_user} user with create database privillege..."
+	su postgres -c "psql -c \"CREATE USER ${gitlab_user} CREATEDB;\""
 fi
 
 # By default the gitlab_prodcution is not owned by gitlab user
-echo "Make $user user owner of $dbname database..."
-su postgres -c "psql -c \"ALTER DATABASE $dbname OWNER to $user;\"" || {
-  exit 1 
-  }
-
-echo "Grant all privileges to $user user..."
-su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE template1 to $user;\"" || {
-  exit 1
-  }
+echo "Make ${gitlab_user} user owner of $dbname database..."
+su postgres -c "psql -c \"ALTER DATABASE $dbname OWNER to ${gitlab_user};\""
+
+echo "Grant all privileges to ${gitlab_user} user..."
+su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE template1 to ${gitlab_user};\""
 
 # enable the pg_trgm extension
-su postgres -c "psql -d $dbname -c \"CREATE EXTENSION IF NOT EXISTS pg_trgm;\"" || {
-  exit 1
-    }
+su postgres -c "psql -d $dbname -c \"CREATE EXTENSION IF NOT EXISTS pg_trgm;\""
diff -Nru gitlab-8.13.11+dfsg/debian/install gitlab-8.13.11+dfsg/debian/install
--- gitlab-8.13.11+dfsg/debian/install	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/install	2017-02-16 17:35:29.000000000 +0530
@@ -6,7 +6,7 @@
 debian/conf/gitlab-debian.conf.example usr/share/doc/gitlab
 debian/conf/*.target lib/systemd/system
 debian/conf/smtp_settings.rb etc/gitlab/initializers
-debian/conf/tmpfiles.d/gitlab.conf usr/lib/tmpfiles.d
+debian/conf/tmpfiles.d/gitlab.conf.example usr/share/doc/gitlab/tmpfiles.d
 debian/adduser.sh usr/lib/gitlab/scripts
 debian/grantpriv.sh usr/lib/gitlab/scripts
 debian/rake-tasks.sh usr/lib/gitlab/scripts
diff -Nru gitlab-8.13.11+dfsg/debian/postinst gitlab-8.13.11+dfsg/debian/postinst
--- gitlab-8.13.11+dfsg/debian/postinst	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/postinst	2017-02-16 17:35:29.000000000 +0530
@@ -44,6 +44,14 @@
 # If /etc/gitlab/gitlab-debian.conf is already present, use it
 test -f ${gitlab_debian_conf} && export $(cat ${gitlab_debian_conf})
 
+# Read gitlab_user from debconf db
+db_get gitlab/user
+gitlab_user=${RET:-gitlab} >/dev/null
+
+if ! grep gitlab_user ${gitlab_debian_conf_private}; then
+  echo "gitlab_user=${gitlab_user}" >> ${gitlab_debian_conf_private}
+fi
+
 # Create gitlab user
 . /usr/lib/gitlab/scripts/adduser.sh
 
@@ -135,6 +143,8 @@
       test -f ${gitlab_shell_config_private} || \
       cp ${gitlab_shell_config_example} ${gitlab_shell_config_private}
 
+      sed -i "s/GITLAB_USER/${gitlab_user}/" ${gitlab_yml_private}
+
       if [ "${RET}" = "true" ]; then
         echo "Configuring nginx with HTTPS..."
         if ! grep GITLAB_HTTPS ${gitlab_debian_conf_private}; then
@@ -186,7 +196,22 @@
 	  fi
         fi
       fi
-        
+
+      # Manage tmpfiles.d/gitlab.conf via ucf
+      test -f ${gitlab_tmpfiles_private} || \
+      cp ${gitlab_tmpfiles_example} ${gitlab_tmpfiles_private}
+      sed -i "s/GITLAB_USER/${gitlab_user}/" ${gitlab_tmpfiles_private}
+      echo "Registering ${gitlab_tmpfiles} via ucf"
+      ucf --debconf-ok --three-way ${gitlab_tmpfiles_private} ${gitlab_tmpfiles}
+      ucfr gitlab ${gitlab_tmpfiles}
+
+      # Override User for systemd services
+      for service in mailroom unicorn sidekiq workhorse; do
+        path=/etc/systemd/system/gitlab-${service}.service.d
+        mkdir -p $path
+        printf "[Service]\nUser=${gitlab_user}\n" > $path/override.conf
+      done
+
       # Manage gitlab-shell's config.yml via ucf
       mkdir -p /etc/gitlab-shell
       echo "Registering ${gitlab_shell_config} via ucf"
diff -Nru gitlab-8.13.11+dfsg/debian/postrm gitlab-8.13.11+dfsg/debian/postrm
--- gitlab-8.13.11+dfsg/debian/postrm	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/postrm	2017-02-16 17:35:29.000000000 +0530
@@ -14,7 +14,9 @@
 # Ensure the menu system is updated
 
 # Read and export debian specific configuration
-# Only exported variables will be passed on to gitlab app
+gitlab_debian_conf=/etc/gitlab/gitlab-debian.conf
+test -f ${gitlab_debian_conf} && export $(cat ${gitlab_debian_conf})
+
 case "$1" in
   remove)
     # This package is being removed, but its configuration has not yet
@@ -34,13 +36,32 @@
     if [ -e /usr/share/debconf/confmodule ]; then
       # Source debconf library.
       . /usr/share/debconf/confmodule
+
+      # Do you want to remove all data?
+      db_input high gitlab/purge || true
+      db_go
+      
+      # Check if we should remove data?
+      db_get gitlab/purge
+      if [ "${RET}" = "true" ]; then
+        rm -rf ${gitlab_data_dir}/shared
+        rm -rf ${gitlab_data_dir}/public
+        rm -rf ${gitlab_data_dir}/db
+	rm -rf ${gitlab_data_dir}/repositories
+	rm -rf ${gitlab_data_dir}/secrets.yml
+	rm -rf ${gitlab_data_dir}/Gemfile.lock
+        rm -rf ${gitlab_log_dir}
+        rm -rf ${gitlab_cache_path}
+        rm -rf ${gitlab_pid_path}
+        userdel -r ${gitlab_user}
+        rm -rf ${gitlab_data_dir}
+        su postgres -c "dropdb gitlab_production"
+      fi
+
       # Remove my changes to the db.
       db_purge
     fi
 
-    echo "Reading gitlab-debian.conf..."
-    gitlab_debian_conf=/etc/gitlab/gitlab-debian.conf
-    test -f ${gitlab_debian_conf} && export $(cat ${gitlab_debian_conf})
     nginx_site="/etc/nginx/sites-available/${GITLAB_HOST}"
 
     test -f ${nginx_site} && echo "Found nginx site configuration at ${nginx_site}..."
@@ -53,29 +74,49 @@
 	rm -f ${nginx_site}$ext
 	rm -f ${gitlab_debian_conf}$ext
 	rm -f ${gitlab_yml}$ext
+	rm -f ${gitlab_tmpfiles}$ext
+	rm -f ${gitlab_shell_config}$ext
     done
  
     # remove the configuration file itself
     test -f ${nginx_site} && rm -f ${nginx_site}
     test -f ${gitlab_debian_conf} && rm -f ${gitlab_debian_conf}
     test -f ${gitlab_yml} && rm -f ${gitlab_yml}
+    test -f ${gitlab_tmpfiles} && rm -f ${gitlab_tmpfiles}
+    test -f ${gitlab_shell_config} && rm -f ${gitlab_shell_config}
 
     # and finally clear it out from the ucf database
     if which ucf >/dev/null; then
       test -n "${nginx_site}" && ucf --purge ${nginx_site}
       test -n "${gitlab_debian_conf}" && ucf --purge ${gitlab_debian_conf}
       test -n "${gitlab_yml}" && ucf --purge ${gitlab_yml}
-      test -n "${gitlab_shell_config}" && ucf -purge ${gitlab_shell_config}
-    fi    
+      test -n "${gitlab_tmpfiles}" && ucf --purge ${gitlab_tmpfiles}
+      test -n "${gitlab_shell_config}" && ucf -purge ${gitlab_shell_config}        
+    fi
+    
     if which ucfr >/dev/null; then
       test -n "${nginx_site}" && ucfr --purge gitlab ${nginx_site}
       test -n "${gitlab_debian_conf}" && ucfr --purge gitlab ${gitlab_debian_conf}
       test -n "${gitlab_yml}" && ucfr --purge gitlab ${gitlab_yml}
+      test -n "${gitlab_tmpfiles}" && ucfr --purge gitlab ${gitlab_tmpfiles}
       test -n "${gitlab_shell_config}" && ucfr -purge gitlab ${gitlab_shell_config}
     fi
 
     # remove generated assets
-    rm -rf /var/lib/gitlab/public/assets
+    rm -rf ${gitlab_data_dir}/public/assets
+      
+    # Remove private copies of configuration files
+    rm -f ${nginx_site_private}
+    rm -f ${gitlab_debian_conf_private}
+    rm -f ${gitlab_yml_private}
+    rm -f ${gitlab_tmpfiles_private}
+    rm -f ${gitlab_shell_config_private}
+
+    # Remove systemd service overrides
+    for service in mailroom unicorn sidekiq workhorse; do
+      path=/etc/systemd/system/gitlab-${service}.service.d
+      rm -rf $path
+    done
 
        # cleanup complete
     exit 0
diff -Nru gitlab-8.13.11+dfsg/debian/README.Debian gitlab-8.13.11+dfsg/debian/README.Debian
--- gitlab-8.13.11+dfsg/debian/README.Debian	2017-02-07 11:24:36.000000000 +0530
+++ gitlab-8.13.11+dfsg/debian/README.Debian	2017-02-16 17:35:29.000000000 +0530
@@ -64,10 +64,7 @@
 directory /usr/share/gitlab and with the environment variables from
 /etc/gitlab/gitlab-debian.conf set. So above command could be run like:
 
-    # su gitlab
-    $ cd /usr/share/gitlab
-    $ export $(cat /etc/gitlab/gitlab-debian.conf)
-    $ rake XXX RAILS_ENV=production
+    $ runuser -u gitlab -- sh -c 'cd /usr/share/gitlab && export $(cat /etc/gitlab/gitlab-debian.conf) && rake XXX RAILS_ENV=production'
 
 One useful command to run in this environment is:
 
@@ -80,7 +77,7 @@
 
 To see service status with systemd, you can use:
 
-    $ systemctl status gitlab.target
+    $ systemctl status gitlab.service -l
     $ systemctl status gitlab-unicorn.service -l
     $ systemctl status gitlab-sidekiq.service -l
     $ systemctl status gitlab-workhorse.service -l
@@ -96,29 +93,46 @@
       - the repositories/ directory
       - the public/uploads/ directory
       - your .ssh/authorized_keys
- 1. Rename your old database to gitlab_production and set the user gitlab as
+ 1. Remove the init script for your old gitlab installation, like:
+      $ rm /etc/init.d/gitlab
+ 2. Install Debian gitlab:
+      $ apt-get install gitlab
+ 3. Stop gitlab services:
+      $ systemctl stop gitlab.service
+ 4. Rename your old database to gitlab_production and set the user gitlab as
     its owner and the owner of all its tables, sequences and views
- 2. Copy your old repository directory to /var/lib/gitlab/repositories/
- 3. Copy your old public/uploads/ directory to /var/lib/gitlab/public/uploads/
- 4. Copy your old .ssh/authorized_keys to /var/lib/gitlab/.ssh/authorized_keys
- 5. Start gitlab using `systemctl start gitlab.target`
- 6. Check the status of your installation using gitlab:check (see section
-    above). The output of that command will tell you the necessary remaining
-    fixes. You might be told to run:
-
-       $ sudo chmod -R ug+rwX,o-rwx /var/lib/gitlab/repositories/
-       $ sudo -u gitlab -H /usr/share/gitlab-shell/bin/create-hooks
-       $ sudo -u gitlab -H bundle exec rake db:migrate RAILS_ENV=production
-
-    See the last section of how to execute the db:migrate command.
+      $ su - postgres
+      $ psql
+      # drop database gitlab_production;
+      # alter database gitlabhq_production rename to gitlab_production;
+      # alter database gitlab_production owner to gitlab;
+      # \q
+      $ for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" gitlab_production` ; do  psql -c "alter table \"$tbl\" owner to gitlab" gitlab_production ; done
+      $ for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" gitlab_production` ; do  psql -c "alter table \"$tbl\" owner to gitlab" gitlab_production ; done
+ 5. Copy your old repository directory to /var/lib/gitlab/repositories/
+ 6. Copy your old public/uploads/ directory to /var/lib/gitlab/public/uploads/
+ 7. Copy your old .ssh/authorized_keys to /var/lib/gitlab/.ssh/authorized_keys
+ 8. Fix your /var/lib/gitlab/.ssh/authorized_keys to contain the right path to gitlab-shell like:
+      $ sed -i 's/^command="[^ ]\+gitlab-shell /command="\/usr\/share\/gitlab-shell\/bin\/gitlab-shell /' /usr/share/gitlab/.ssh/authorized_keys
+ 9. Fix permission:
+      $ chown -R gitlab:gitlab /var/lib/gitlab/repositories/ /var/lib/gitlab/public/uploads/ /var/lib/gitlab/.ssh/authorized_keys
+      $ chmod -R ug+rwX,o-rwx /var/lib/gitlab/repositories/
+      $ find /var/lib/gitlab/public/uploads -type f -exec chmod 0644 {} \;
+      $ find /var/lib/gitlab/public/uploads -type d -not -path /var/lib/gitlab/public/uploads -exec chmod 0700 {} \;
+ 10. Migrate the database:
+      $ runuser -u gitlab -- sh -c 'cd /usr/share/gitlab && export $(cat /etc/gitlab/gitlab-debian.conf) && rake db:migrate RAILS_ENV=production'
+ 11. Fix hooks:
+      # su gitlab
+      $ /usr/share/gitlab-shell/bin/create-hooks
+ 12. Start gitlab:
+       $ systemctl start gitlab.service
+ 13. Check the installation:
+      $ runuser -u gitlab -- sh -c 'cd /usr/share/gitlab && export $(cat /etc/gitlab/gitlab-debian.conf) && rake gitlab:check RAILS_ENV=production'
 
 Resetting admin password without web interface
 ==============================================
 
-    # su gitlab
-    $ cd /usr/share/gitlab
-    $ export $(cat /etc/gitlab/gitlab-debian.conf)
-    $ rails console production
+    $ runuser -u gitlab -- sh -c 'cd /usr/share/gitlab && export $(cat /etc/gitlab/gitlab-debian.conf) && rails console production'
     irb(main):001:0> user = User.where(admin: true).first
     irb(main):002:0> user.password = 'secret_pass'
     irb(main):003:0> user.password_confirmation = 'secret_pass'

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: