Commit 330f5492cb3bcda630be4f8cd931085746a9f490
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,7 +17,11 @@ yum -y install gitlab | ||
17 | # Coisas estranhas: | 17 | # Coisas estranhas: |
18 | # | 18 | # |
19 | # Installing : gitlab-shell-2.4.0-5.1.noarch | 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 | # id: git: no such user | 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 | # mkdir -p /var/lib/gitlab-shell/repositories/: OK | 25 | # mkdir -p /var/lib/gitlab-shell/repositories/: OK |
22 | # mkdir -p /var/lib/gitlab-shell/.ssh: OK | 26 | # mkdir -p /var/lib/gitlab-shell/.ssh: OK |
23 | # chmod 700 /var/lib/gitlab-shell/.ssh: OK | 27 | # chmod 700 /var/lib/gitlab-shell/.ssh: OK |
@@ -25,20 +29,27 @@ yum -y install gitlab | @@ -25,20 +29,27 @@ yum -y install gitlab | ||
25 | # chmod 600 /var/lib/gitlab-shell/.ssh/authorized_keys: OK | 29 | # chmod 600 /var/lib/gitlab-shell/.ssh/authorized_keys: OK |
26 | # chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/: OK | 30 | # chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/: OK |
27 | # find /var/lib/gitlab-shell/repositories/ -type d -exec chmod g+s {} ;: OK | 31 | # find /var/lib/gitlab-shell/repositories/ -type d -exec chmod g+s {} ;: OK |
32 | + | ||
28 | # | 33 | # |
29 | # <snip> | 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 | # chown: cannot access ‘/var/lib/gitlab-assets’: No such file or directory | 40 | # chown: cannot access ‘/var/lib/gitlab-assets’: No such file or directory |
41 | + | ||
33 | # Redirecting to /bin/systemctl start redis.service | 42 | # Redirecting to /bin/systemctl start redis.service |
34 | # rake aborted! | 43 | # rake aborted! |
44 | + | ||
45 | +### No pacote do gitlab 8.5 eu simplesmente dei permissão git:git pra pasta /usr/lib/gitlab | ||
35 | # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret | 46 | # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret |
36 | -# | 47 | +# |
37 | # Tasks: TOP => db:migrate:status => environment | 48 | # Tasks: TOP => db:migrate:status => environment |
38 | # (See full trace by running task with --trace) | 49 | # (See full trace by running task with --trace) |
39 | # rake aborted! | 50 | # rake aborted! |
40 | # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret | 51 | # Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret |
41 | -# | 52 | +# |
42 | # Tasks: TOP => gitlab:setup => environment | 53 | # Tasks: TOP => gitlab:setup => environment |
43 | # (See full trace by running task with --trace) | 54 | # (See full trace by running task with --trace) |
44 | # I, [2016-04-25T22:50:47.389656 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_32-7d94ec26bfa902d9573dac174421752a.png | 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,18 +71,18 @@ sudo -u postgres createuser git | ||
60 | cd /usr/lib/gitlab | 71 | cd /usr/lib/gitlab |
61 | sudo -u git bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done | 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 | echo 'production: redis://localhost:6379' > /usr/lib/gitlab/config/resque.yml | 76 | echo 'production: redis://localhost:6379' > /usr/lib/gitlab/config/resque.yml |
66 | sed -i 's,localhost,localhost\n relative_url_root: /gitlab,' /etc/gitlab/gitlab.yml | 77 | sed -i 's,localhost,localhost\n relative_url_root: /gitlab,' /etc/gitlab/gitlab.yml |
67 | 78 | ||
68 | cat << EOF > /usr/lib/gitlab/config/initializers/gitlab_shell_secret_token.rb | 79 | cat << EOF > /usr/lib/gitlab/config/initializers/gitlab_shell_secret_token.rb |
69 | Gitlab::Application.configure do | 80 | Gitlab::Application.configure do |
70 | - config.relative_url_root = "/gitlab" | 81 | + config.relative_url_root = "/gitlab" |
71 | end | 82 | end |
72 | EOF | 83 | EOF |
73 | 84 | ||
74 | -cat << EOF > /etc/nginx/conf.d/gitlab.conf | 85 | +cat << EOF > /etc/nginx/conf.d/gitlab.conf |
75 | upstream gitlab { | 86 | upstream gitlab { |
76 | server 0.0.0.0:8080 fail_timeout=10s; | 87 | server 0.0.0.0:8080 fail_timeout=10s; |
77 | } | 88 | } |
@@ -120,8 +131,23 @@ cd /usr/lib/gitlab && | @@ -120,8 +131,23 @@ cd /usr/lib/gitlab && | ||
120 | sudo -u git bundle exec rake assets:precompile RAILS_ENV=production | 131 | sudo -u git bundle exec rake assets:precompile RAILS_ENV=production |
121 | 132 | ||
122 | systemctl enable gitlab | 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 | # bootstrap / provision | 153 | # bootstrap / provision |