Commit 65d1973fed4005a46695d121eb9e5887acfca2ec

Authored by David Silva
1 parent 32abf6e8
Exists in master

Complete gitlab configuration

    - start services
    - run migrations
    - TODO: gitlab-shell cannot conect to the internal api
Showing 1 changed file with 81 additions and 75 deletions   Show diff stats
provision.sh
... ... @@ -2,10 +2,15 @@
2 2  
3 3 set -x
4 4  
5   -enable_start_gitlab()
  5 +enable_start_service()
6 6 {
7   - systemctl enable gitlab
8   - systemctl start gitlab
  7 + args=("$@")
  8 + i="0"
  9 + while [[ ! -z "${args[i]// }" ]]; do
  10 + systemctl enable ${args[i]// }
  11 + systemctl start ${args[i]// }
  12 + i=$[$i + 1]
  13 + done
9 14 }
10 15  
11 16 package()
... ... @@ -24,61 +29,20 @@ sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
24 29 setenforce 0
25 30  
26 31 package epel-release
27   -package wget postgresql-server nginx
28   -
29   -wget -P /etc/yum.repos.d/ https://copr.fedorainfracloud.org/coprs/softwarepublico/v4/repo/epel-7/softwarepublico-v4-epel-7.repo
30   -
31   -package gitlab
32   -
33   -############################################
34   -# Coisas estranhas:
35   -#
36   -# Installing : gitlab-shell-2.4.0-5.1.noarch
37   -### Aparentemente, tanto as receitas quanto os specs, esperam que exista um usuário git
38   -### criado nas máquinaso usuário git
39   -# id: git: no such user
40   -
41   -### Isso não é uma coisa estranha, é o output padrão quando se instala o gitlab-shell
42   -# mkdir -p /var/lib/gitlab-shell/repositories/: OK
43   -# mkdir -p /var/lib/gitlab-shell/.ssh: OK
44   -# chmod 700 /var/lib/gitlab-shell/.ssh: OK
45   -# touch /var/lib/gitlab-shell/.ssh/authorized_keys: OK
46   -# chmod 600 /var/lib/gitlab-shell/.ssh/authorized_keys: OK
47   -# chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/: OK
48   -# find /var/lib/gitlab-shell/repositories/ -type d -exec chmod g+s {} ;: OK
49   -
50   -#
51   -# <snip>
52   -#
53   -# Installing : gitlab-7.6.2-13.2.noarch
54   -### Isso é um erro no pacote do gitlab-7.6. Ele cria um link simbólico apontado
55   -### para /var/lib/gitlab-assets, e depois tenta dar um chown, mas a pasta ainda não existe.
56   -### Podemos fazer esse fix.
57   -# chown: cannot access ‘/var/lib/gitlab-assets’: No such file or directory
58   -
59   -# Redirecting to /bin/systemctl start redis.service
60   -# rake aborted!
61   -
62   -### No pacote do gitlab 8.5 eu simplesmente dei permissão git:git pra pasta /usr/lib/gitlab
63   -# Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret
64   -#
65   -# Tasks: TOP => db:migrate:status => environment
66   -# (See full trace by running task with --trace)
67   -# rake aborted!
68   -# Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret
69   -#
70   -# Tasks: TOP => gitlab:setup => environment
71   -# (See full trace by running task with --trace)
72   -# I, [2016-04-25T22:50:47.389656 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_32-7d94ec26bfa902d9573dac174421752a.png
73   -# I, [2016-04-25T22:50:47.391563 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_64-cfef80f36a1826b9c90eeb38534dbd18.png
74   -#
75   -# <snip>
76   -#
77   -############################################
78   -
  32 +package wget postgresql-server postgresql-contrib nginx redis
  33 +
  34 +#### Redis configuration
  35 +echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis.conf
  36 +echo 'unixsocketperm 770' | sudo tee -a /etc/redis.conf
  37 +mkdir /var/run/redis
  38 +chown redis:redis /var/run/redis
  39 +chmod 755 /var/run/redis
  40 +if [ -d /etc/tmpfiles.d ]; then
  41 + echo 'd /var/run/redis 0755 redis redis 10d -' | sudo tee -a /etc/tmpfiles.d/redis.conf
  42 +fi
79 43  
  44 +### Postgresql config
80 45 postgresql-setup initdb
81   -
82 46 cat << EOF > /var/lib/pgsql/data/pg_hba.conf
83 47 # METHOD can be "trust", "reject", "md5", "password", "gss", "sspi",
84 48  
... ... @@ -87,13 +51,15 @@ local all all trust
87 51 host all all 127.0.0.1/32 trust
88 52 host all all ::1/128 trust
89 53 EOF
  54 +enable_start_service postgresql redis
  55 +sudo usermod -aG redis git
90 56  
91   -enable_start_gitlab
92   -sudo -u postgres createuser git
  57 +sudo -u postgres createuser git -d -l
  58 +psql -U git -d template1 -c "create database gitlabhq_production with owner git"
93 59  
  60 +wget -P /etc/yum.repos.d/ https://copr.fedorainfracloud.org/coprs/softwarepublico/v4/repo/epel-7/softwarepublico-v4-epel-7.repo
  61 +package gitlab
94 62 cd /usr/lib/gitlab
95   -sudo -u git bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done
96   -
97 63 sed -i 's,http://localhost:8080/,http://localhost:8080/gitlab,' /etc/gitlab-shell/config.yml
98 64  
99 65 echo 'production: redis://localhost:6379' > /usr/lib/gitlab/config/resque.yml
... ... @@ -104,6 +70,14 @@ Gitlab::Application.configure do
104 70 config.relative_url_root = "/gitlab"
105 71 end
106 72 EOF
  73 +sed -i 's/# ENV/ENV/' /etc/gitlab/unicorn.rb
  74 +sed -i 's/# config.relative_url_root/config.relative_url_root/' /usr/lib/gitlab/config/application.rb
  75 +chown -R git:git /usr/lib/gitlab/tmp/cache
  76 +chown -R git:git /usr/lib/gitlab/public/assets
  77 +chown -R git:git /var/lib/gitlab-assets
  78 +enable_start_service gitlab
  79 +
  80 +sudo -u git bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done
107 81  
108 82 cat << EOF > /etc/nginx/conf.d/gitlab.conf
109 83 upstream gitlab {
... ... @@ -138,17 +112,8 @@ server {
138 112 }
139 113 EOF
140 114  
141   -systemctl enable nginx
142   -systemctl restart nginx
143   -
  115 +enable_start_service nginx
144 116  
145   -sed -i 's/# ENV/ENV/' /etc/gitlab/unicorn.rb
146   -
147   -sed -i 's/# config.relative_url_root/config.relative_url_root/' /usr/lib/gitlab/config/application.rb
148   -
149   -chown -R git:git /usr/lib/gitlab/tmp/cache
150   -chown -R git:git /usr/lib/gitlab/public/assets
151   -chown -R git:git /var/lib/gitlab-assets
152 117  
153 118 cd /usr/lib/gitlab &&
154 119 sudo -u git bundle exec rake assets:precompile RAILS_ENV=production
... ... @@ -170,7 +135,7 @@ if [[ -e $backup ]]; then
170 135 chown git.git $backup
171 136 ln $backup /var/lib/gitlab/backups/
172 137 cd /usr/lib/gitlab
173   - #sudo -u git bundle exec rake gitlab:backup:restore RAILS_ENV=production force=yes
  138 + sudo -u git bundle exec rake gitlab:backup:restore RAILS_ENV=production force=yes
174 139 else
175 140 printf "Backup não encontrado"
176 141 fi
... ... @@ -179,7 +144,48 @@ printf &quot;Instalando gitlab 8.5&quot;
179 144  
180 145 wget -P /etc/yum.repos.d/ https://copr.fedorainfracloud.org/coprs/softwarepublico/experimental/repo/epel-7/softwarepublico-experimental-epel-7.repo
181 146  
182   -package centos-release-scl
183   -package rh-ruby22
184   -yum -y update gitlab
185   -enable_start_gitlab
  147 +package centos-release-scl rh-ruby22
  148 +package gitlab
  149 +sudo chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/
  150 +sudo chmod -R ug-s /var/lib/gitlab-shell/repositories/
  151 +sudo find /var/lib/gitlab-shell/repositories/ -type d -print0 | sudo xargs -0 chmod g+s
  152 +sudo chmod -R 777 /var/log/gitlab-shell/
  153 +
  154 +cat << EOF > /usr/lib/gitlab-shell/config.yml
  155 +
  156 +user: git
  157 +gitlab_url: "http://127.0.0.1:8080/gitlab"
  158 +
  159 +http_settings:
  160 +# user: someone
  161 +# password: somepass
  162 +# ca_file: /etc/ssl/cert.pem
  163 +# ca_path: /etc/pki/tls/certs
  164 + self_signed_cert: false
  165 +
  166 +repos_path: "/var/lib/gitlab-shell/repositories/"
  167 +auth_file: "/var/lib/gitlab-shell/.ssh/authorized_keys"
  168 +
  169 +redis:
  170 + bin: /usr/bin/redis-cli
  171 + host: 127.0.0.1
  172 + port: 6379
  173 + # pass: redispass # Allows you to specify the password for Redis
  174 + #database: 0
  175 + #socket: /var/run/redis/redis.sock # Comment out this line if you want to use TCP
  176 + #namespace: resque:gitlab
  177 +
  178 +log_file: "/var/log/gitlab-shell/gitlab-shell.log"
  179 +log_level: INFO
  180 +audit_usernames: false
  181 +EOF
  182 +
  183 +
  184 +
  185 +enable_start_service gitlab
  186 +
  187 +sudo -u git env PATH=/opt/rh/rh-ruby22/root/usr/bin/:/opt/rh/nodejs010/root/usr/bin/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin LD_LIBRARY_PATH=/opt/rh/rh-ruby22/root/usr/lib64:/opt/rh/nodejs010/root/lib64/:/opt/rh/v8314/root/usr/lib64/ bundle exec rake db:migrate RAILS_ENV=production
  188 +
  189 +sudo -u git env PATH=/opt/rh/rh-ruby22/root/usr/bin/:/opt/rh/nodejs010/root/usr/bin/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin LD_LIBRARY_PATH=/opt/rh/rh-ruby22/root/usr/lib64:/opt/rh/nodejs010/root/lib64/:/opt/rh/v8314/root/usr/lib64/ bundle exec rake assets:precompile RAILS_ENV=production
  190 +
  191 +sudo -u git env PATH=/opt/rh/rh-ruby22/root/usr/bin/:/opt/rh/nodejs010/root/usr/bin/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin LD_LIBRARY_PATH=/opt/rh/rh-ruby22/root/usr/lib64:/opt/rh/nodejs010/root/lib64/:/opt/rh/v8314/root/usr/lib64/ bundle exec rake gitlab:check RAILS_ENV=production
... ...