[packages/gitlab-ce] gitlab-ctl

glen glen at pld-linux.org
Thu May 26 22:19:12 CEST 2016


commit e62d7f310fa08b7786e09acc3c0ce6badb2e9af9
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu May 26 23:18:24 2016 +0300

    gitlab-ctl
    
    trying to have similar commands that gitlab-omnibus has

 gitlab-ce.spec | 11 ++++++----
 gitlab-ctl.sh  | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 4 deletions(-)
---
diff --git a/gitlab-ce.spec b/gitlab-ce.spec
index 4c3e849..9b26650 100644
--- a/gitlab-ce.spec
+++ b/gitlab-ce.spec
@@ -17,14 +17,11 @@
 Summary:	A Web interface to create projects and repositories, manage access and do code reviews
 Name:		gitlab-ce
 Version:	8.8.1
-Release:	0.33
+Release:	0.34
 License:	MIT
 Group:		Applications/WWW
 # md5 deliberately omitted until this package is useful
 Source0:	https://github.com/gitlabhq/gitlabhq/archive/v%{version}/%{name}-%{version}.tar.gz
-Patch0:		3774.patch
-Patch1:		pld.patch
-Patch2:		bug-14972.patch
 Source1:	gitlab.target
 Source2:	gitlab-sidekiq.service
 Source3:	gitlab-sidekiq.init
@@ -35,6 +32,10 @@ Source7:	gitlab.tmpfiles.d
 Source8:	gitlab-apache-conf
 Source9:	gitlab-rake.sh
 Source10:	gitconfig
+Source11:	gitlab-ctl.sh
+Patch0:		3774.patch
+Patch1:		pld.patch
+Patch2:		bug-14972.patch
 URL:		https://www.gitlab.com/gitlab-ce/
 BuildRequires:	cmake
 BuildRequires:	gmp-devel
@@ -193,6 +194,7 @@ cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/logrotate.d/gitlab.logrotate
 cp -p %{SOURCE8} $RPM_BUILD_ROOT/etc/httpd/webapps.d/gitlab.conf
 cp -p %{SOURCE10} $RPM_BUILD_ROOT%{homedir}/.gitconfig
 install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/gitlab-rake
+install -p %{SOURCE11} $RPM_BUILD_ROOT%{_sbindir}/gitlab-ctl
 
 %clean
 rm -rf "$RPM_BUILD_ROOT"
@@ -235,6 +237,7 @@ fi
 %attr(754,root,root) /etc/rc.d/init.d/gitlab-sidekiq
 %attr(754,root,root) /etc/rc.d/init.d/gitlab-unicorn
 %attr(755,root,root) %{_sbindir}/gitlab-rake
+%attr(755,root,root) %{_sbindir}/gitlab-ctl
 %{systemdunitdir}/gitlab-sidekiq.service
 %{systemdunitdir}/gitlab-unicorn.service
 %{systemdunitdir}/gitlab.target
diff --git a/gitlab-ctl.sh b/gitlab-ctl.sh
new file mode 100755
index 0000000..2b35353
--- /dev/null
+++ b/gitlab-ctl.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# gitlab-ctl implementing similar commands as gitlab omnibus package does
+#
+set -e
+
+auto_migrations_skip_file=/etc/gitlab/skip-auto-migrations
+
+die() {
+	cat >&2
+	exit 1
+}
+
+# Run backup before package upgrade
+# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/config/templates/package-scripts/preinst.erb#L10
+backup_before_upgrade() {
+	if ! gitlab-rake gitlab:backup:create SKIP=repositories,uploads,builds,artifacts,lfs,registry; then
+		cat >&2 <<-EOF
+
+		Backup failed! If you want to skip this backup, run the following command and try again:
+
+		touch ${auto_migrations_skip_file}
+
+		EOF
+		exit 1
+	fi
+}
+
+# Run migrations after a package upgrade
+# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/files/gitlab-ctl-commands/upgrade.rb
+upgrade() {
+	gitlab-rake db:migrate
+}
+
+# Run migrations after a package upgrade
+pkg_upgrade() {
+	if [ -f $auto_migrations_skip_file ]; then
+		echo >&2 "Found $auto_migrations_skip_file, exiting..."
+		return
+	fi
+
+	backup_before_upgrade
+	upgrade
+
+	cat >&2 <<-EOF
+		Upgrade complete!
+
+		If you need to roll back to the previous version you can
+		use the database backup made during the upgrade (scroll up for the filename).
+	EOF
+
+}
+
+# http://docs.gitlab.com/ce/administration/restart_gitlab.html#installations-from-source
+restart() {
+	:
+}
+
+case "$1" in
+pkg-upgrade)
+	pkg_upgrade
+	;;
+upgrade)
+	upgrade
+	;;
+esac
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/gitlab-ce.git/commitdiff/e62d7f310fa08b7786e09acc3c0ce6badb2e9af9



More information about the pld-cvs-commit mailing list