]> git.pld-linux.org Git - packages/gitlab-ce.git/blob - gitlab-ctl.sh
schama.rb needs to be writable
[packages/gitlab-ce.git] / gitlab-ctl.sh
1 #!/bin/sh
2 #
3 # gitlab-ctl implementing similar commands as gitlab omnibus package does
4 #
5 set -e
6
7 auto_migrations_skip_file=/etc/gitlab/skip-auto-migrations
8
9 die() {
10         cat >&2
11         exit 1
12 }
13
14 notice() {
15         echo "gitlab $*"
16 }
17
18 # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
19 upgrade() {
20         gitlab-rake db:migrate "$@"
21 }
22
23 # GitLab | Create a backup of the GitLab system
24 backup() {
25         gitlab-rake gitlab:backup:create "$@"
26 }
27
28 # http://docs.gitlab.com/ce/administration/restart_gitlab.html#installations-from-source
29 restart() {
30         :
31 }
32
33 # Run backup before package upgrade
34 # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/config/templates/package-scripts/preinst.erb#L10
35 preinst() {
36         if [ -f $auto_migrations_skip_file ]; then
37                 notice "preinstall: Found $auto_migrations_skip_file, skipping auto backup..."
38                 return
39         fi
40
41         notice "preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)"
42
43         if ! backup SKIP=repositories,uploads,builds,artifacts,lfs,registry; then
44                 cat >&2 <<-EOF
45
46                 Backup failed! If you want to skip this backup, run the following command and try again:
47
48                 touch ${auto_migrations_skip_file}
49
50                 EOF
51                 exit 1
52         fi
53 }
54
55 # Run migrations after a package upgrade
56 # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/config/templates/package-scripts/posttrans.erb
57 # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8.8.1+ce.0/files/gitlab-ctl-commands/upgrade.rb
58 posttrans() {
59         upgrade
60
61         cat >&2 <<-EOF
62                 Upgrade complete!
63
64                 If you need to roll back to the previous version you can
65                 use the database backup made during the upgrade (scroll up for the filename).
66         EOF
67 }
68
69 case "$1" in
70 preinst)
71         preinst
72         ;;
73 posttrans)
74         posttrans
75         ;;
76 backup)
77         backup "$@"
78         ;;
79 upgrade)
80         upgrade
81         ;;
82 esac
This page took 0.042523 seconds and 3 git commands to generate.