capistrano-typo3 0.2.4 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,14 +2,23 @@
2
2
 
3
3
  #----- DEFAULT SETTINGS, OVERRIDE WHEN NEEDED
4
4
 
5
+ set :debug, 0
5
6
  set :git_no_cache, 0
6
7
  set :restart_webserver, "sudo /etc/init.d/apache2 restart"
7
8
  set :bundle_executable, "/usr/bin/bundle"
8
9
  set :rake_executable, "./bin/rake"
9
10
  set :rake_mysql_exec_dir, "/usr/bin"
10
11
  set :rake_php_executable, "/usr/bin/php"
12
+
11
13
  set :t3_dont_upgrade_source, 0
12
14
  set :t3_alternative_source_url, nil
15
+ set :t3_main_version, '7.6'
16
+ set :t3_post_deployment_commands, []
17
+ set :t3_db_sync_ignore_tables, []
18
+
19
+
20
+ set :typo3_v6_local_conf_path, File.join('current','dummy','typo3conf','LocalConfiguration.php')
21
+ set :http_protocol, 'http'
13
22
 
14
23
  #----- INTERNAL VARIABLES, DON'T CHANGE OR OVERRIDE THESE
15
24
  set :hooks_before_suite_run, 0
@@ -17,266 +26,345 @@ set :install_or_update_rake_typo3_run, 0
17
26
 
18
27
  namespace :typo3 do
19
28
 
20
- # Empty repository must exist in git remote.
21
- # This creates useable fresh skeleton for TYPO3
22
- #
23
- # From here:
24
- # - a new TYPO3 enviroment can be created
25
- # - an existing TYPO3 environment can be imported in this module
26
- desc "init a initial dev environment"
27
- task :init1_empty_dummy do
28
-
29
- invoke 'typo3:helper:rm_deploy_to'
30
- invoke 'typo3:hooks:before_suite'
31
-
32
- invoke 'deploy:check'
33
- invoke 'deploy:updating'
34
- invoke 'typo3:helper:setup_shared_typo3_dirs'
35
- invoke 'typo3:helper:current_relative_symlink'
36
-
37
- on roles(:all) do
38
- execute "cd #{fetch(:deploy_to)}/current/ && git remote set-url origin #{fetch(:repo_url)}"
39
- execute "cd #{fetch(:deploy_to)}/current/ && mkdir -p deploy/patches"
40
- execute "cd #{fetch(:deploy_to)}/current/ && touch deploy/patches/.keep"
41
- execute "cd #{fetch(:deploy_to)}/current/ && mkdir -p deploy/migrations"
42
- execute "cd #{fetch(:deploy_to)}/current/ && touch deploy/migrations/.keep"
43
- execute "cd #{fetch(:deploy_to)}/current/ && mkdir -p dummy/typo3conf/ext"
44
- execute "cd #{fetch(:deploy_to)}/current/ && touch dummy/typo3conf/ext/index.html"
45
- end
46
-
47
- invoke 'typo3:helper:create_gitignore'
48
- invoke 'typo3:helper:upgrade_source'
49
- print "initial environment has been setup"
50
- end
51
-
52
- # desc "init step 2: install a fresh TYPO3 in the designated version"
53
- task :init2_install_typo3 do
54
- print "SORRY NOT YET IMPLEMENTED"
55
- end
56
-
57
- desc "init step 2: clone from extisting TYPO3 environment"
58
- task :init2_install_typo3 do
59
-
60
- print "\nNOTE: When this task fails most times there is a problem with your ssh authorized public keys\n\n"
29
+ desc "Setup a new production environment. Don't sync content from old production"
30
+ task :setup_new_stage_no_sync do
31
+ invoke 'typo3:helper:rm_deploy_to' #OKE
32
+ invoke 'deploy' #OKE
33
+ invoke 'typo3:helper:setup_shared_typo3_dirs' #OKE
34
+ invoke 'typo3:helper:update_localconf' #OKE
35
+ invoke 'typo3:helper:current_relative_symlink' #OKE
36
+ invoke 'typo3:helper:restart_webserver' #OKE
61
37
 
62
- invoke 'typo3:hooks:before_suite'
63
- invoke 'typo3:sync_from_production'
64
-
65
- on roles(:all) do
66
-
67
- execute "rsync -v #{fetch(:t3_clone_original)[:ssh_user]}@#{fetch(:t3_clone_original)[:ssh_host]}:#{fetch(:t3_clone_original)[:dummy_root]}/* #{fetch(:deploy_to)}/current/dummy/"
68
- execute "rsync -v #{fetch(:t3_clone_original)[:ssh_user]}@#{fetch(:t3_clone_original)[:ssh_host]}:#{fetch(:t3_clone_original)[:dummy_root]}/.* #{fetch(:deploy_to)}/current/dummy/"
69
- execute "rsync -av --exclude ext --exclude *.log --exclude temp* #{fetch(:t3_clone_original)[:ssh_user]}@#{fetch(:t3_clone_original)[:ssh_host]}:#{fetch(:t3_clone_original)[:dummy_root]}/typo3conf/ #{fetch(:deploy_to)}/current/dummy/typo3conf/"
70
- execute "rsync -avL #{fetch(:t3_clone_original)[:ssh_user]}@#{fetch(:t3_clone_original)[:ssh_host]}:#{fetch(:t3_clone_original)[:dummy_root]}/typo3conf/ext/ #{fetch(:deploy_to)}/current/dummy/typo3conf/ext/"
71
-
72
- #TODO do git module magic
73
- #execute "cd #{fetch(:deploy_to)}/current && find `dummy/typo3conf/ext -name '.git'`"
74
- end
75
-
76
- invoke 'typo3:hooks:after_suite'
77
- end
78
-
79
- desc "Setup a new production environment. Manually sync content from old production"
80
- task :init3_setup_new_stage_no_sync do
81
- invoke 'typo3:helper:rm_deploy_to'
82
- invoke 'typo3:hooks:before_suite'
83
- invoke 'typo3:helper:setup_shared_typo3_dirs'
84
- invoke 'deploy'
85
- invoke('typo3:hooks:after_suite') #FIXME Only run it init3_setup_new_stage_no_sync is called
86
38
  print "environment has been setup, you do need to sync content from old production"
87
39
  end
88
40
 
89
41
  desc "Setup a new staged typo3 environment when a it's already in model"
90
- task :init3_setup_new_stage_sync do
91
- invoke 'typo3:helper:rm_deploy_to'
92
- invoke 'typo3:hooks:before_suite'
93
- invoke 'typo3:helper:setup_shared_typo3_dirs'
94
- invoke 'deploy'
95
- invoke 'typo3:sync_from_production' # SAME BUT THIS ONE
96
- invoke('typo3:hooks:after_suite')
42
+ task :setup_new_stage_sync do
43
+
44
+ invoke 'typo3:helper:rm_deploy_to' #OKE
45
+ invoke 'deploy' #OKE
46
+ invoke 'typo3:helper:setup_shared_typo3_dirs' #OKE
47
+
48
+ invoke 'typo3:content:sync_files_from_production' #OKE
49
+ invoke 'typo3:content:sync_db_from_production' #OKE
50
+ invoke 'typo3:content:flush_cache_in_db' #OKE
51
+ invoke 'typo3:helper:update_localconf' #OKE
52
+ invoke 'typo3:helper:current_relative_symlink' #OKE
53
+ invoke 'typo3:helper:restart_webserver' #OKE
97
54
  end
98
55
 
99
- desc 'merge with [remote_branch]'
100
- task :merge_with, :remotebranch do |t, args|
101
-
102
- invoke 'typo3:hooks:before_suite'
56
+ desc "sync db & files and then deploy. Typically for Continuous Integration"
57
+ task :sync_n_deploy do
103
58
  invoke 'deploy'
104
-
105
- on roles(:all) do
106
- branch = args[:remotebranch]
107
- execute "cd #{fetch(:deploy_to)}/current && git remote set-url origin #{fetch(:repo_url)}"
108
- execute "cd #{fetch(:deploy_to)}/current && git stash"
109
- execute "cd #{fetch(:deploy_to)}/current && git fetch"
110
- execute "cd #{fetch(:deploy_to)}/current && git checkout #{branch}"
111
- execute "cd #{fetch(:deploy_to)}/current && git checkout master"
112
- execute "cd #{fetch(:deploy_to)}/current && git merge --strategy-option ours #{branch}"
113
- end
114
-
115
- invoke('typo3:hooks:after_suite')
59
+ invoke 'typo3:content:sync_files_from_production'
60
+ invoke 'typo3:content:sync_db_from_production'
61
+ invoke 'typo3:content:flush_cache_in_db'
62
+ invoke 'typo3:helper:update_localconf'
63
+ invoke 'typo3:helper:current_relative_symlink'
64
+ invoke 'typo3:helper:restart_webserver'
116
65
  end
117
66
 
118
67
  desc "deploy the typo3 way"
119
68
  task :deploy do
120
- invoke 'typo3:hooks:before_suite'
121
69
  invoke 'deploy'
122
- invoke('typo3:hooks:after_suite')
70
+ invoke 'typo3:helper:update_localconf'
71
+ invoke 'typo3:helper:current_relative_symlink'
72
+ invoke 'typo3:helper:restart_webserver'
123
73
  end
124
74
 
125
- desc "sync db & files and then deploy. Typically for Continuous Integration"
126
- task :sync_n_deploy do
127
- invoke 'typo3:hooks:before_suite'
128
- invoke 'typo3:sync_from_production'
129
- invoke 'deploy'
130
- invoke('typo3:hooks:after_suite')
75
+ desc "Make db & files in env. identical to production"
76
+ task :sync_from_production do
77
+ invoke 'typo3:content:sync_files_from_production'
78
+ invoke 'typo3:content:sync_db_from_production'
79
+ invoke 'typo3:content:flush_cache_in_db'
131
80
  end
132
81
 
133
- desc "Clear all db and file content and config cache"
134
- task :clear_all_cache do
135
- invoke 'typo3:helper:flush_content_cache'
136
- on roles(:all) do
137
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} env:flush_cache"
82
+ namespace :hooks do
83
+ task :after_deploy do
84
+ invoke 'git:set_remote_url_no_cache'
85
+ invoke 'typo3:helper:execute_post_deployment_commands'
138
86
  end
139
87
  end
140
88
 
141
- # desc "Run site presuite rspecs"
142
- task :rspec_pre_suite do
143
- on roles(:all) do
144
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} env:rspec_pre_suite"
89
+ namespace :content do
90
+ desc 'sync files from production'
91
+ task :sync_files_from_production do
92
+ on roles(:allow_syncfiles) do
93
+ if fetch(:t3_live_sync)['filesync']
94
+ fetch(:t3_live_sync)['filesync'].each do |key,command|
95
+ execute "cd #{fetch(:deploy_to)} && #{command}"
96
+ end
97
+ end
98
+ end
145
99
  end
146
- end
147
100
 
148
- # desc "Run site post browser rspecs"
149
- task :rspec_post_browser do
150
- on roles(:all) do
151
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} env:rspec_post_browser"
152
- end
153
- end
101
+ desc 'sync database from production and run sql updates'
102
+ task :sync_db_from_production do
103
+ on roles(:allow_syncdatabase) do
154
104
 
155
- desc "Make db & files in env. identical to production"
156
- task :sync_from_production do
157
- invoke 'typo3:hooks:before_suite'
158
- invoke 'typo3:helper:sync_files_from_production'
159
- invoke 'typo3:helper:sync_db_from_production'
160
- invoke 'typo3:helper:flush_content_cache'
161
- end
105
+ ignorestring = ""
162
106
 
163
- desc "Show environment information"
164
- task :info do
165
- invoke 'typo3:hooks:before_suite'
166
- on roles(:all) do
167
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} env:info"
168
- end
169
- end
107
+ if(:t3_db_sync_ignore_tables)
170
108
 
171
- # Suite are large combined tasks like init3_setup_new_stage_sync
172
- # Suite hooks are run only one time per session
173
- namespace :hooks do
109
+ fetch(:t3_db_sync_ignore_tables).each do | ignore_tbl |
110
+ ignorestring = "#{ignorestring} --ignore-table=#{fetch(:t3_live_sync)['dbsync']['dbname']}.#{ignore_tbl}"
111
+ end
112
+ end
174
113
 
175
- task :before_suite do
176
- if(fetch(:hooks_before_suite_run)==0)
114
+ # DUMP DATABASE TO IMAGE
115
+ execute <<DBSYNC1
116
+ ssh #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']} \
117
+ 'mysqldump -u#{fetch(:t3_live_sync)['dbsync']['dbuser']} \
118
+ -h#{fetch(:t3_live_sync)['dbsync']['dbhost']} \
119
+ -p#{fetch(:t3_live_sync)['dbsync']['dbpass']} \
120
+ #{ignorestring} \
121
+ #{fetch(:t3_live_sync)['dbsync']['dbname']} > /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}'
122
+ DBSYNC1
123
+
124
+ if(:t3_db_sync_ignore_tables)
125
+ fetch(:t3_db_sync_ignore_tables).each do | ignore_tbl |
126
+
127
+ execute <<DBSYNC1
128
+ ssh #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']} \
129
+ 'mysqldump -u#{fetch(:t3_live_sync)['dbsync']['dbuser']} \
130
+ -h#{fetch(:t3_live_sync)['dbsync']['dbhost']} \
131
+ -p#{fetch(:t3_live_sync)['dbsync']['dbpass']} \
132
+ --no-data \
133
+ #{fetch(:t3_live_sync)['dbsync']['dbname']} #{ignore_tbl} >> /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}'
134
+ DBSYNC1
135
+ end
136
+ end
177
137
 
178
- set :hooks_before_suite_run, 1
179
- invoke 'typo3:helper:install_or_update_rake_typo3'
180
- invoke 'typo3:helper:create_typo3yaml'
181
- invoke 'typo3:helper:set_stage'
138
+ # COMPRESS IMAGE
139
+ execute <<DBSYNC2
140
+ ssh #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']} \
141
+ 'gzip -f /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}'
142
+ DBSYNC2
143
+
144
+ # TRANSFER IMAGE
145
+ execute <<DBSYNC3
146
+ scp #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']}:/tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}.gz \
147
+ /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}.gz
148
+ DBSYNC3
149
+
150
+ # DECOMPRESS IMAGE
151
+ execute <<DBSYNC4
152
+ gunzip -f /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}.gz
153
+ DBSYNC4
154
+
155
+ # IMPORT AND REMOVE IMAGE
156
+ execute <<DBSYNC5
157
+ mysql -u#{fetch(:dbuser)} -h#{fetch(:dbhost)} -p#{fetch(:dbpass)} #{fetch(:dbname)} < /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']} && \
158
+ rm -f /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}
159
+ DBSYNC5
160
+
161
+ # REMOVE IMAGE
162
+ execute <<DBSYNC6
163
+ ssh #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']} \
164
+ 'rm -f /tmp/.captypo3dump-#{fetch(:t3_live_sync)['dbsync']['dbname']}.gz'
165
+ DBSYNC6
182
166
  end
167
+
168
+ invoke 'typo3:content:sql_updates'
183
169
  end
184
170
 
185
- task :after_deploy do
186
- invoke 'git:set_remote_url_no_cache'
171
+ desc 'run necessary sql queries for environment'
172
+ task :sql_updates do
173
+ on roles(:allow_syncdatabase) do
174
+ if fetch(:t3_sql_updates)
175
+ fetch(:t3_sql_updates).each do |command|
176
+ execute DT3MySQL::mysql_execute(command)
177
+ end
178
+ end
179
+ end
187
180
  end
188
181
 
189
- task :after_suite do
190
- invoke 'typo3:helper:run_filesearchandreplace'
191
- invoke 'typo3:helper:update_localconf'
192
- invoke 'typo3:helper:upgrade_source'
193
- invoke 'typo3:helper:db_em_migrations'
194
- invoke 'typo3:helper:run_migrations'
195
- invoke 'typo3:helper:current_relative_symlink'
196
- invoke 'typo3:helper:restart_webserver'
182
+ desc 'flush cache and session tables in database'
183
+ task :flush_cache_in_db do
184
+ on roles(:all) do
185
+
186
+ all_current_tables = capture(DT3MySQL::show_tables).split("\n")
187
+
188
+ cache_tables= %w(cache_extensions cache_hash cache_imagesizes cache_md5params cache_pages cache_pagesection cache_sys_dmail_stat cache_treelist cache_typo3temp_log cachingframework_cache_hash cachingframework_cache_hash_tags cachingframework_cache_pages cachingframework_cache_pages_tags cachingframework_cache_pagesection cachingframework_cache_pagesection_tags cf_cache_hash cf_cache_hash_tags cf_cache_pages cf_cache_pages_tags cf_cache_pagesection cf_cache_pagesection_tags cf_extbase_object cf_extbase_object_tags cf_extbase_reflection cf_extbase_reflection_tags cf_tt_news_cache cf_tt_news_cache_tags cf_tx_solr cf_tx_solr_tags tt_news_cache tt_news_cache_tags tx_realurl_chashcache tx_realurl_errorlog tx_realurl_pathcache tx_realurl_uniqalias tx_realurl_urldecodecache tx_realurl_urlencodecache tx_solr_cache tx_solr_cache_tags)
189
+
190
+ cache_tables.each do |table|
191
+ if all_current_tables.include?(table)
192
+ execute DT3MySQL::truncate_table(table)
193
+ end
194
+ end
195
+
196
+ session_tables=%w(be_sessions fe_session_data fe_sessions)
197
+ session_tables.each do |table|
198
+ if all_current_tables.include?(table)
199
+ execute DT3MySQL::truncate_table(table)
200
+ end
201
+ end
202
+ end
197
203
  end
198
204
  end
199
205
 
200
- namespace :helper do
206
+ namespace :vagrant do
207
+ desc "when homestead is not yet configured"
208
+ task "init_homestead_conf" do
209
+ invoke 'typo3:vagrant:check_branch'
210
+ sh "mkdir -p config"
211
+ sh "cd config && curl -O https://raw.githubusercontent.com/t3labcom/capistrano-typo3/master/homestead_files/vagrant.yml"
212
+ sh "cd config/deploy && curl -O https://raw.githubusercontent.com/t3labcom/capistrano-typo3/master/homestead_files/homestead.rb"
213
+ sh "curl -O https://raw.githubusercontent.com/t3labcom/capistrano-typo3/master/homestead_files/Vagrantfile"
214
+ end
201
215
 
202
- task :sync_files_from_production do
203
- on roles(:devtest,:syncfiles) do
204
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:sync_files_from_production"
216
+ desc "setup new homestead vagrant machine for TYPO3 development"
217
+ task "setup_machine" do
218
+ invoke 'typo3:vagrant:check_branch'
219
+
220
+ if `vagrant status | grep running`.strip != ""
221
+ sh "vagrant destroy"
205
222
  end
206
- end
207
223
 
208
- task :sync_db_from_production do
209
- on roles(:devtest,:syncdb) do
210
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:sync_db_from_production"
211
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:run_sql_updates"
224
+ sh "rm -f local.typo3.org"
225
+ sh "rm -Rf .vagrant"
226
+
227
+ if `vagrant plugin list | grep vagrant-bind`.include? 'vagrant-bindfs'
228
+ print "vagrant bindfs plugin is already installed\n"
229
+ else
230
+ sh "vagrant plugin install vagrant-bindfs"
212
231
  end
213
- end
214
232
 
215
- # Truncate tables with content cache
216
- task :flush_content_cache do
233
+ sh "vagrant up"
234
+
217
235
  on roles(:all) do
218
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} env:truncate_cache_tables"
219
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} env:truncate_session_tables"
236
+ execute "sudo aptitude update"
237
+ execute "sudo aptitude install ruby-dev make -y"
238
+ execute "sudo gem install bundler"
220
239
  end
240
+
241
+ invoke 'typo3:vagrant:set_no_site'
242
+ invoke 'typo3:helper:restart_webserver'
221
243
  end
222
244
 
223
- # remove deploy_to directory
224
- task :rm_deploy_to do
245
+ desc "setup homestead"
246
+ task "setup_site" do
247
+ invoke 'typo3:vagrant:check_branch'
248
+
225
249
  on roles(:all) do
226
- execute "rm -Rf #{fetch(:deploy_to)}"
250
+ ## PURGE IF NEEDED
251
+ execute "sudo rm -Rf /var/shared/fileadmin /var/shared/typo3temp /var/shared/uploads"
252
+ execute "sudo rm -f /var/current"
253
+ execute "sudo mysql -e 'DROP DATABASE IF EXISTS #{fetch(:dbname)}'"
254
+
255
+ ## CREATE
256
+ execute "sudo mkdir -p /var/shared/fileadmin /var/shared/typo3temp /var/shared/uploads"
257
+ execute "sudo chown -Rf vagrant.vagrant /var/shared/fileadmin /var/shared/typo3temp /var/shared/uploads"
258
+ execute "sudo ln -s /var/www/local.typo3.org /var/current"
227
259
  end
228
- end
229
260
 
230
- # TODO move to typo3-rake?
231
- # create typo3 dirs in shared
232
- task :setup_shared_typo3_dirs do
233
261
  on roles(:all) do
234
- execute "cd #{fetch(:deploy_to)} && mkdir -p shared/fileadmin shared/typo3temp shared/uploads"
262
+ execute "sudo mysqladmin create #{fetch(:dbname)}"
235
263
  end
236
- end
237
264
 
238
- # set stage
239
- task :set_stage do
265
+ invoke 'typo3:vagrant:fixknownhosts'
266
+ invoke 'typo3:content:sync_db_from_production'
267
+ invoke 'typo3:content:flush_cache_in_db'
268
+ invoke 'typo3:helper:update_localconf'
269
+
240
270
  on roles(:all) do
241
- execute "echo '#{fetch(:stage).to_s}' > #{fetch(:deploy_to)}/STAGE"
271
+ if fetch(:hs_default_upstream_php_engine)
272
+ execute "sudo sed -i 's/set $upstream .*/set $upstream #{fetch(:hs_default_upstream_php_engine)};/g' /etc/nginx/sites-available/local.typo3.org.conf"
273
+ end
274
+ execute "sudo sed -i 's/root .*/root \"\\/var\\/www\\/local\\.typo3\\.org\\/dummy\\/\";/g' /etc/nginx/sites-available/local.typo3.org.conf"
242
275
  end
276
+
277
+ invoke 'typo3:helper:restart_webserver'
278
+ invoke 'typo3:content:sync_files_from_production'
279
+
280
+ print <<MSG
281
+
282
+ ----------------------------------------------------------------------
283
+ The website seems to be succesfully installed in the Homestead Vagrant
284
+ machine.
285
+
286
+ Open the site at http://local.typo3.org"
287
+
288
+ And live edit the website via the shortcut local.typo3.org in this
289
+ directory
290
+ ----------------------------------------------------------------------
291
+ MSG
292
+ end
293
+
294
+ desc "purge .vagrant files"
295
+ task "purge_machine" do
296
+ print "OBSOLETE: you can run 'setup_machine' over and over again\n"
243
297
  end
244
298
 
245
- # install rake-typo3 from github
246
- task :install_or_update_rake_typo3 do
299
+ #desc "purge homestead site and database"
300
+ task "purge_site" do
301
+ print "OBSOLETE: you can run 'setup_site' over and over again\n"
302
+ end
247
303
 
248
- if(fetch(:install_or_update_rake_typo3_run)==0)
304
+ task "check_branch" do
305
+ current_branch = `git branch | grep \\* | cut -d ' ' -f2`.strip
306
+ if current_branch != fetch(:branch)
307
+ raise "current branch differs from homestead.rb configuration.\n see config/deploy/homestead.rb\n\n Current branch: #{current_branch}\n Homestead branch: #{fetch(:branch)} "
308
+ end
309
+ end
310
+
311
+ task "fixknownhosts" do
312
+ on roles(:all) do
313
+ execute "ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']} uptime"
314
+ end
315
+ end
249
316
 
250
- on roles(:all) do
317
+ task "set_no_site" do
318
+ on roles(:all) do
319
+ execute "sudo sed -i 's/root .*/root \"\\/var\\/\";/g' /etc/nginx/sites-available/local.typo3.org.conf"
320
+ execute "sudo su -c 'echo \"THERE IS NO DIRECTORY local.typo3.org ... YOU MAY WANT TO RUN cap homstead:setup_site\" > /var/index.php'"
321
+ end
322
+ end
323
+ end
251
324
 
252
- gitexist = capture "if [ -e '#{fetch(:deploy_to)}/.git/config' ]; then echo -n 'true'; fi"
325
+ namespace :test do
253
326
 
254
- if(gitexist.chomp=='true')
327
+ desc "ssh_password_less_login_rsync"
328
+ task :ssh_password_less_login_rsync do
329
+ on roles(:all) do |server|
330
+ begin
331
+ capture("ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']} uptime")
332
+ rescue
333
+ er = "password less login to #{fetch(:t3_live_sync)['dbsync']['ssh_user']}@#{fetch(:t3_live_sync)['dbsync']['ssh_server']} is not possible\n"
334
+ er += "You need to fix this first.\n"
335
+ er += "solution 1: ssh-add.\n"
336
+ er += "solution 2: install public key on the remote server.\n"
255
337
 
256
- #remove old deployTYPO3 version
257
- remote = capture "cd #{fetch(:deploy_to)} && git remote -v"
258
- if remote.include?('deploy')
259
- print "removing old repository"
260
- execute "cd #{fetch(:deploy_to)} && rm -Rf .bundle config docs lib log spec .gitignore .rspec .travis.yml CHANGELOG.md Gemfile Gemfile.lock README.md Rakefile.rb VERSION .git"
261
- execute "git clone https://github.com/Lingewoud/rake-typo3.git #{fetch(:deploy_to)}/.clone"
262
- execute "cd #{fetch(:deploy_to)}/.clone && mv ./* ../"
263
- execute "cd #{fetch(:deploy_to)}/.clone && mv .bundle .git .gitignore .rspec .travis.yml ../"
264
- end
338
+ raise "#{er}"
339
+ end
340
+ end
341
+ end
342
+ end
265
343
 
266
- execute "cd #{fetch(:deploy_to)} && git pull"
267
- execute "cd #{fetch(:deploy_to)} && #{fetch(:bundle_executable)} install --binstubs"
344
+ namespace :helper do
345
+ task :execute_post_deployment_commands do
346
+ on roles(:all) do
268
347
 
269
- else
270
- execute "rm -Rf #{fetch(:deploy_to)}"
271
- execute "git clone https://github.com/Lingewoud/rake-typo3.git #{fetch(:deploy_to)}"
272
- execute "cd #{fetch(:deploy_to)} && #{fetch(:bundle_executable)} install --binstubs"
273
- print "rake-typo3 has been installed"
348
+ if fetch(:t3_post_deployment_commands)
349
+ fetch(:t3_post_deployment_commands).each do |command|
350
+ execute command
274
351
  end
352
+ end
353
+ end
275
354
 
276
- set :install_or_update_rake_typo3_run, 1
355
+ end #ENDTASK
277
356
 
278
- end
357
+ # remove deploy_to directory
358
+ task :rm_deploy_to do
359
+ on roles(:all) do
360
+ execute "rm -Rf #{fetch(:deploy_to)}"
361
+ end
362
+ end
279
363
 
364
+ # create typo3 dirs in shared
365
+ task :setup_shared_typo3_dirs do
366
+ on roles(:all) do
367
+ execute "cd #{fetch(:deploy_to)} && mkdir -p shared/fileadmin shared/typo3temp shared/uploads"
280
368
  end
281
369
  end
282
370
 
@@ -290,116 +378,48 @@ namespace :typo3 do
290
378
  *.swp
291
379
  *.swo
292
380
  ENABLE_INSTALL_TOOL
293
- VERSION
381
+ /VERSION
294
382
  temp_CACHE*.php
295
383
  deprecation_*.log
296
384
  "
297
-
298
385
  contents = StringIO.new(ignorestring)
299
386
  upload! contents, "#{fetch(:deploy_to)}/current/.gitignore"
300
387
  end
301
388
  end
302
389
 
303
- task :create_typo3yaml do
304
-
305
- on roles(:all) do
306
-
307
- if(fetch(:t3_main_version))
308
- t3yaml = {}
309
- t3yaml['all'] = {}
310
- t3yaml['all']['TYPO3_MAIN_VERSION'] = fetch(:t3_main_version)
311
- t3yaml['all']['SYNCLIVE'] = {}
312
- t3yaml['all']['SYNCLIVE']['SYNCCMDS'] = fetch(:t3_live_sync)['filesync']
313
- t3yaml['all']['SYNCLIVE']['SSH_DB_SERVER'] = fetch(:t3_live_sync)['dbsync']['ssh_server']
314
- t3yaml['all']['SYNCLIVE']['SSH_DB_USER'] = fetch(:t3_live_sync)['dbsync']['ssh_user']
315
- t3yaml['all']['SYNCLIVE']['DB'] = fetch(:t3_live_sync)['dbsync']
316
- t3yaml['all']['MYSQLEXECDIR'] = fetch(:rake_mysql_exec_dir)
317
- t3yaml['all']['PHP_EXECUTABLE'] = fetch(:rake_php_executable)
318
-
319
- stage = fetch(:stage).to_s
320
-
321
- t3yaml[stage] = {}
322
- t3yaml[stage]['DB'] = {}
323
- t3yaml[stage]['DB']['dbname'] = fetch(:dbname)
324
- t3yaml[stage]['DB']['dbuser'] = fetch(:dbuser)
325
- t3yaml[stage]['DB']['dbpass'] = fetch(:dbpass)
326
- t3yaml[stage]['DB']['dbhost'] = fetch(:dbhost)
327
-
328
- t3yaml[stage]['SQL_UPDATES'] = fetch(:t3_sql_updates)
329
- t3yaml[stage]['TYPO3_CONF_VARS'] = fetch(:t3_conf_vars)
330
- t3yaml[stage]['TYPO3_CONF_VARS_EXT_EXTCONF'] = fetch(:t3_conf_vars_ext_extconf)
331
- t3yaml[stage]['TYPO3_SOURCE_PATCHES'] = fetch(:t3_source_patches)
332
-
333
- if !fetch(:t3_alternative_source_url).nil?
334
- t3yaml[stage]['TYPO3_ALTERNATIVE_SOURCE_URL'] = fetch(:t3_alternative_source_url)
335
- end
336
-
337
-
338
- t3yaml[stage]['DISABLE_EXTENSIONS'] = fetch(:t3_disable_extensions)
339
- t3yaml[stage]['FILE_SEARCH_REPLACE'] = fetch(:t3_file_search_replace)
340
-
341
- contents = StringIO.new(t3yaml.to_yaml)
342
- upload! contents, "#{fetch(:deploy_to)}/typo3.yml"
343
- end
344
-
345
- end
346
- end
347
-
348
390
  # when not in deploy latest ls releases/ -1 | sort -r | head -n 1
349
391
  task :current_relative_symlink do
350
392
  on roles(:all) do
351
- execute "rm -f #{current_path}"
352
- execute "cd #{fetch(:deploy_to)} && ln -s releases/#{File.basename release_path} current"
393
+ execute "cd #{fetch(:deploy_to)} && rm -f current"
394
+ execute "cd #{fetch(:deploy_to)} && ln -s releases/`ls -1 releases/ | sort -r | head -n 1` current"
353
395
  end
354
396
  end
355
397
 
398
+ desc "update LocalConf with correct db credentionals"
356
399
  task :update_localconf do
357
- on roles(:all) do
358
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:update_localconf_db_credentials"
359
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:update_localconf_typo3conf_vars"
360
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:update_localconf_disable_extensions"
361
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:update_localconf_extconf_settings"
362
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:flush_config_cache"
363
- end
364
- end
365
-
366
- # Migrate database (typo3 Extension Manager migrations)
367
- task :db_em_migrations do
368
- on roles(:all) do
369
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:db_migrate"
370
- end
371
- end
372
-
373
- # Run search and replace
374
- task :run_filesearchandreplace do
375
- on roles(:all) do
376
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:run_file_searchreplace_updates"
377
- end
378
- end
379
-
380
- # Specific environment migration sql's. E.g. rename all fe-users etc..
381
- # migrations should be placed in current/deploy/migrations/
382
- # Run migrations (sql migrations)
383
- task :run_migrations do
384
400
 
385
401
  on roles(:all) do
386
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:run_migrations"
387
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:run_sql_updates"
388
- end
389
- end
390
402
 
391
- #desc "Upgrade TYPO3 source in environment to latest minor version"
392
- task :upgrade_source do
403
+ execute "echo '<?php' > #{fetch(:deploy_to)}/current/dummy/typo3conf/AdditionalConfiguration.php"
393
404
 
394
- if(fetch(:t3_dont_upgrade_source)!=1)
395
-
396
- on roles(:all) do
397
- execute "cd #{fetch(:deploy_to)} && #{fetch(:rake_executable)} cap:update_typo3_source"
405
+ if fetch(:t3_add_unsafe_trusted_host_pattern)
406
+ execute "echo ' $GLOBALS[\"TYPO3_CONF_VARS\"][\"SYS\"][\"trustedHostsPattern\"] = \".*\";' >> #{fetch(:deploy_to)}/current/dummy/typo3conf/AdditionalConfiguration.php"
398
407
  end
399
408
 
400
- print "\nsource has been upgraded"
401
- print "\n\nWARNING: YOU MUST RUN THE UPGRADE SCRIPTS IN BACKEND\n\n"
409
+ if fetch(:t3_store_db_credentials_in_addionalconf)
410
+ execute "echo ' $GLOBALS[\"TYPO3_CONF_VARS\"][\"DB\"][\"database\"] = \"#{fetch(:dbname)}\";' >> #{fetch(:deploy_to)}/current/dummy/typo3conf/AdditionalConfiguration.php"
411
+ execute "echo ' $GLOBALS[\"TYPO3_CONF_VARS\"][\"DB\"][\"host\"] = \"#{fetch(:dbhost)}\";' >> #{fetch(:deploy_to)}/current/dummy/typo3conf/AdditionalConfiguration.php"
412
+ execute "echo ' $GLOBALS[\"TYPO3_CONF_VARS\"][\"DB\"][\"password\"] = \"#{fetch(:dbpass)}\";' >> #{fetch(:deploy_to)}/current/dummy/typo3conf/AdditionalConfiguration.php"
413
+ execute "echo ' $GLOBALS[\"TYPO3_CONF_VARS\"][\"DB\"][\"username\"] = \"#{fetch(:dbuser)}\";' >> #{fetch(:deploy_to)}/current/dummy/typo3conf/AdditionalConfiguration.php"
414
+ else
415
+ cmd1 =Typo3Helper::make_set_localconf_database_settings_command(fetch(:dbname),fetch(:dbuser),fetch(:dbpass),fetch(:dbhost))
416
+ execute "cd #{fetch(:deploy_to)} && #{cmd1}"
417
+
418
+ cmd2 = "mv #{fetch(:typo3_v6_local_conf_path)}.tmp #{fetch(:typo3_v6_local_conf_path)}"
419
+ execute "cd #{fetch(:deploy_to)} && #{cmd2}"
420
+ end
402
421
  end
422
+
403
423
  end
404
424
 
405
425
  task :restart_webserver do
@@ -410,36 +430,3 @@ deprecation_*.log
410
430
 
411
431
  end
412
432
  end
413
-
414
-
415
- namespace :test do
416
- task :test_pre_setup do
417
- on roles(:all) do
418
- # test apache restart is allowed
419
- # test ssh access to live server is allowed
420
- # test stage is configured in typo3.yml
421
- end
422
- end
423
-
424
- task :test_post_setup do
425
- on roles(:all) do
426
- # test if dummy index.php is readable, correctly linked
427
- # temp cache files are removed
428
- end
429
- end
430
-
431
- task :test_pre_deploy do
432
- #if production test if repo is dirty
433
- on roles(:all) do
434
- end
435
- end
436
- task :test_post_deploy do
437
- on roles(:all) do
438
- #test symlinks
439
- #test source version
440
- #test database connection
441
- #test chmods
442
- #test chowns
443
- end
444
- end
445
- end