Commit 330f5492cb3bcda630be4f8cd931085746a9f490

Authored by David Silva
1 parent 92a6ee95
Exists in master

Add restore step

Showing 1 changed file with 34 additions and 8 deletions   Show diff stats
provision.sh
... ... @@ -17,7 +17,11 @@ yum -y install gitlab
17 17 # Coisas estranhas:
18 18 #
19 19 # Installing : gitlab-shell-2.4.0-5.1.noarch
  20 +### Aparentemente, tanto as receitas quanto os specs, esperam que exista um usuário git
  21 +### criado nas máquinaso usuário git
20 22 # id: git: no such user
  23 +
  24 +### Isso não é uma coisa estranha, é o output padrão quando se instala o gitlab-shell
21 25 # mkdir -p /var/lib/gitlab-shell/repositories/: OK
22 26 # mkdir -p /var/lib/gitlab-shell/.ssh: OK
23 27 # chmod 700 /var/lib/gitlab-shell/.ssh: OK
... ... @@ -25,20 +29,27 @@ yum -y install gitlab
25 29 # chmod 600 /var/lib/gitlab-shell/.ssh/authorized_keys: OK
26 30 # chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/: OK
27 31 # find /var/lib/gitlab-shell/repositories/ -type d -exec chmod g+s {} ;: OK
  32 +
28 33 #
29 34 # <snip>
30 35 #
31   -# Installing : gitlab-7.6.2-13.2.noarch
  36 +# Installing : gitlab-7.6.2-13.2.noarch
  37 +### Isso é um erro no pacote do gitlab-7.6. Ele cria um link simbólico apontado
  38 +### para /var/lib/gitlab-assets, e depois tenta dar um chown, mas a pasta ainda não existe.
  39 +### Podemos fazer esse fix.
32 40 # chown: cannot access ‘/var/lib/gitlab-assets’: No such file or directory
  41 +
33 42 # Redirecting to /bin/systemctl start redis.service
34 43 # rake aborted!
  44 +
  45 +### No pacote do gitlab 8.5 eu simplesmente dei permissão git:git pra pasta /usr/lib/gitlab
35 46 # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret
36   -#
  47 +#
37 48 # Tasks: TOP => db:migrate:status => environment
38 49 # (See full trace by running task with --trace)
39 50 # rake aborted!
40 51 # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret
41   -#
  52 +#
42 53 # Tasks: TOP => gitlab:setup => environment
43 54 # (See full trace by running task with --trace)
44 55 # I, [2016-04-25T22:50:47.389656 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_32-7d94ec26bfa902d9573dac174421752a.png
... ... @@ -60,18 +71,18 @@ sudo -u postgres createuser git
60 71 cd /usr/lib/gitlab
61 72 sudo -u git bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done
62 73  
63   -sed -i 's,http://localhost:8080/,http://localhost:8080/gitlab,' /etc/gitlab-shell/config.yml
  74 +sed -i 's,http://localhost:8080/,http://localhost:8080/gitlab,' /etc/gitlab-shell/config.yml
64 75  
65 76 echo 'production: redis://localhost:6379' > /usr/lib/gitlab/config/resque.yml
66 77 sed -i 's,localhost,localhost\n relative_url_root: /gitlab,' /etc/gitlab/gitlab.yml
67 78  
68 79 cat << EOF > /usr/lib/gitlab/config/initializers/gitlab_shell_secret_token.rb
69 80 Gitlab::Application.configure do
70   - config.relative_url_root = "/gitlab"
  81 + config.relative_url_root = "/gitlab"
71 82 end
72 83 EOF
73 84  
74   -cat << EOF > /etc/nginx/conf.d/gitlab.conf
  85 +cat << EOF > /etc/nginx/conf.d/gitlab.conf
75 86 upstream gitlab {
76 87 server 0.0.0.0:8080 fail_timeout=10s;
77 88 }
... ... @@ -120,8 +131,23 @@ cd /usr/lib/gitlab &amp;&amp;
120 131 sudo -u git bundle exec rake assets:precompile RAILS_ENV=production
121 132  
122 133 systemctl enable gitlab
123   -systemctl start gitlab
124   -
  134 +systemctl start gitlab
  135 +
  136 +##### restore backup
  137 +
  138 +backup=$(echo *_backup.tar)
  139 +if [[ -e /vagrant/$backup ]]; then
  140 + printf "####################################################"
  141 + printf "Restaurando backup"
  142 + systemctl stop gitlab
  143 + sleep 3
  144 + printf "Movendo backup para diretório correto"
  145 + install -D -m 755 -o git -g git /vagrant/$backup /var/lib/gitlab/backups
  146 + ### O task do gitlab espera uma resposta via bash, não sei se tem como mandarmos essa resposta via bash.
  147 + # (cd /usr/lib/gitlab && sudo -u git bundle exec rake gitlab:backup:restore RAILS_ENV=production)
  148 +else
  149 + printf "Backup não encontrado"
  150 +fi
125 151  
126 152  
127 153 # bootstrap / provision
... ...