]> git.pld-linux.org Git - packages/gitlab-ce.git/commitdiff
gitlab-ctl
authorElan Ruusamäe <glen@delfi.ee>
Thu, 26 May 2016 20:18:24 +0000 (23:18 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 26 May 2016 20:18:24 +0000 (23:18 +0300)
trying to have similar commands that gitlab-omnibus has

gitlab-ce.spec
gitlab-ctl.sh [new file with mode: 0755]

index 4c3e849ade5a6e581d66c6df265d8726b357c6e4..9b2665041e4dc5a8e5ad7ff959cb6e405d046e0c 100644 (file)
 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 (executable)
index 0000000..2b35353
--- /dev/null
@@ -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
This page took 0.033551 seconds and 4 git commands to generate.