dkdeploy-typo3-cms 7.0.0

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.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.rubocop.yml +23 -0
  4. data/.travis.yml +12 -0
  5. data/Berksfile +3 -0
  6. data/Berksfile.lock +66 -0
  7. data/CHANGELOG.md +12 -0
  8. data/CONTRIBUTORS.md +16 -0
  9. data/Gemfile +3 -0
  10. data/LICENSE +7 -0
  11. data/README.md +87 -0
  12. data/Rakefile +1 -0
  13. data/Vagrantfile +62 -0
  14. data/assets/dkdeploy-logo.png +0 -0
  15. data/config/vm/cookbooks/dkdeploy-typo3-cms/metadata.rb +12 -0
  16. data/config/vm/cookbooks/dkdeploy-typo3-cms/recipes/default.rb +71 -0
  17. data/dkdeploy-typo3-cms.gemspec +29 -0
  18. data/features/advanced_typo3.feature +156 -0
  19. data/features/caretaker_key_management.feature +36 -0
  20. data/features/clear_cache_on_rollback.feature +17 -0
  21. data/features/cli.feature +61 -0
  22. data/features/step_definitions/mysql.rb +75 -0
  23. data/features/step_definitions/typo3.rb +16 -0
  24. data/features/support/env.rb +11 -0
  25. data/features/typo3.feature +100 -0
  26. data/features/typoscript_upload_and_merge_config.feature +128 -0
  27. data/features/typoscript_upload_and_merge_pagets.feature +128 -0
  28. data/features/typoscript_upload_and_merge_userts.feature +128 -0
  29. data/features/update_database.feature +23 -0
  30. data/lib/capistrano/dkdeploy/typo3_cms.rb +37 -0
  31. data/lib/dkdeploy/typo3/cms.rb +1 -0
  32. data/lib/dkdeploy/typo3/cms/dsl.rb +27 -0
  33. data/lib/dkdeploy/typo3/cms/helpers/cli.rb +165 -0
  34. data/lib/dkdeploy/typo3/cms/helpers/erb.rb +25 -0
  35. data/lib/dkdeploy/typo3/cms/i18n.rb +111 -0
  36. data/lib/dkdeploy/typo3/cms/tasks/cache.rake +18 -0
  37. data/lib/dkdeploy/typo3/cms/tasks/caretaker_key_management.rake +60 -0
  38. data/lib/dkdeploy/typo3/cms/tasks/cli.rake +45 -0
  39. data/lib/dkdeploy/typo3/cms/tasks/typo3.rake +272 -0
  40. data/lib/dkdeploy/typo3/cms/tasks/typoscript.rake +288 -0
  41. data/lib/dkdeploy/typo3/cms/version.rb +16 -0
  42. data/spec/fixtures/application/Capfile +8 -0
  43. data/spec/fixtures/application/Gemfile +3 -0
  44. data/spec/fixtures/application/config/deploy.rb +8 -0
  45. data/spec/fixtures/application/config/deploy/dev.rb +41 -0
  46. data/spec/fixtures/application/htdocs/.hidden/.gitkeep +0 -0
  47. data/spec/fixtures/application/htdocs/catalog/index.html +1 -0
  48. data/spec/fixtures/application/htdocs/composer.json +24 -0
  49. data/spec/fixtures/application/htdocs/typo3/cli_dispatch.phpsh +2 -0
  50. data/spec/fixtures/application/htdocs/typo3conf/AdditionalConfiguration.php +3 -0
  51. data/spec/fixtures/application/htdocs/typo3conf/LocalConfiguration.php +28 -0
  52. data/spec/fixtures/application/htdocs/typo3conf/PackageStates.php +358 -0
  53. data/spec/fixtures/application/vendor/composer.phar +0 -0
  54. data/spec/fixtures/capistrano/configuration/additional_configuration_for_server.rb +1 -0
  55. data/spec/fixtures/capistrano/configuration/cli_break_after_one_run_in_release_path.rb +14 -0
  56. data/spec/fixtures/capistrano/configuration/cli_break_after_three_runs_in_release_path.rb +14 -0
  57. data/spec/fixtures/capistrano/configuration/cli_test_tasks.rb +19 -0
  58. data/spec/fixtures/capistrano/configuration/cli_test_tasks_with_path.rb +15 -0
  59. data/vendor/AdditionalConfiguration.php.erb +57 -0
  60. data/vendor/create_caretaker_instance_keys.php.erb +18 -0
  61. metadata +222 -0
@@ -0,0 +1,27 @@
1
+ module Dkdeploy
2
+ module Typo3
3
+ # TYPO3 dsl api
4
+ module DSL
5
+ # Execute a rake/capistrano task only for given server
6
+ #
7
+ # @param server [Capistrano::Configuration::Server] Server to execute task
8
+ # @param task [String] Name of rake/capistrano task
9
+ # @param args [Array] Arguments of rake/capistrano task
10
+ def invoke_for_server(server, task, *args)
11
+ backup_filter = fetch :filter, {}
12
+ begin
13
+ new_server_filter = Marshal.load(Marshal.dump(backup_filter))
14
+ new_server_filter[:host] = server.hostname
15
+ set :filter, new_server_filter
16
+ env.setup_filters
17
+ info I18n.t('dsl.invoke_for_server.set_filter', task: task, host: server.hostname, scope: :dkdeploy)
18
+ invoke task, *args
19
+ Rake::Task[task].reenable
20
+ ensure
21
+ set :filter, backup_filter
22
+ env.setup_filters
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,165 @@
1
+ module Dkdeploy
2
+ module Typo3
3
+ module Cms
4
+ module Helpers
5
+ # TYPO3 cli helpers
6
+ module Cli
7
+ # Execute a task typo3/cli_dispatch.phpsh cli_params
8
+ #
9
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
10
+ # @return [Boolean] returns true/false as success of execution
11
+ def typo3_cli(*cli_params)
12
+ path_to_cli_dispatch = File.join(current_path, 'typo3', 'cli_dispatch.phpsh')
13
+ run_script(current_path, path_to_cli_dispatch, cli_params)
14
+ end
15
+
16
+ # Execute a task typo3/cli_dispatch.phpsh cli_params in a specific directory
17
+ #
18
+ # @param path [String] file path where task is to be executed
19
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
20
+ # @return [Boolean] returns true/false as success of execution
21
+ def typo3_cli_in_path(path, *cli_params)
22
+ path_to_cli_dispatch = File.join(path, 'typo3', 'cli_dispatch.phpsh')
23
+ run_script(path, path_to_cli_dispatch, cli_params)
24
+ end
25
+
26
+ # Returns the last results of invocations of a task typo3/cli_dispatch.phpsh cli_params
27
+ # Invocation can be controlled by the result of a given block.
28
+ # True repeats the invocation until maximum_loop_count is reached.
29
+ # False stops invocation regardless of loop count.
30
+ #
31
+ # @param maximum_loop_count [Integer] number of maximum attempts to run task
32
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
33
+ # @return [String] returns the last result of executing task
34
+ def capture_typo3_cli_in_loop(maximum_loop_count, *cli_params, &block)
35
+ path_to_cli_dispatch = File.join(current_path, 'typo3', 'cli_dispatch.phpsh')
36
+ capture_script_in_loop(current_path, path_to_cli_dispatch, maximum_loop_count, cli_params, &block)
37
+ end
38
+
39
+ # Returns the last results of invocations of a task typo3/cli_dispatch.phpsh cli_params
40
+ # Invocation can be controlled by the result of a given block.
41
+ # True repeats the invocation until maximum_loop_count is reached.
42
+ # False stops invocation regardless of loop count.
43
+ #
44
+ # @param path [String] file path where task is to be executed
45
+ # @param maximum_loop_count [Integer] number of maximum attempts to run task
46
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
47
+ # @return [String] returns the last result of executing task
48
+ def capture_typo3_cli_in_path_in_loop(path, maximum_loop_count, *cli_params, &block)
49
+ path_to_cli_dispatch = File.join(path, 'typo3', 'cli_dispatch.phpsh')
50
+ capture_script_in_loop(path, path_to_cli_dispatch, maximum_loop_count, cli_params, &block)
51
+ end
52
+
53
+ # Execute a typo3_console task with cli_params
54
+ #
55
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
56
+ # @return [Boolean] returns true/false as success of execution
57
+ def typo3_console(*cli_params)
58
+ path_to_typo3_console = File.join(current_path, fetch(:path_to_typo3_console))
59
+ run_script(current_path, path_to_typo3_console, cli_params)
60
+ end
61
+
62
+ # Execute a typo3_console task with cli_params in a specific directory
63
+ #
64
+ # @param path [String] file path where task is to be executed
65
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
66
+ # @return [Boolean] returns true/false as success of execution
67
+ def typo3_console_in_path(path, *cli_params)
68
+ path_to_typo3_console = File.join(path, fetch(:path_to_typo3_console))
69
+ run_script(path, path_to_typo3_console, cli_params)
70
+ end
71
+
72
+ # Returns the last results of invocations of a a typo3_console task with cli_params
73
+ # Invocation can be controlled by the result of a given block.
74
+ # True repeats the invocation until maximum_loop_count is reached.
75
+ # False stops invocation regardless of loop count.
76
+ #
77
+ # @param maximum_loop_count [Integer] number of maximum attempts to run task
78
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
79
+ # @return [String] returns the last result of executing task
80
+ def capture_typo3_console_in_loop(maximum_loop_count, *cli_params, &block)
81
+ path_to_typo3_console = File.join(current_path, fetch(:path_to_typo3_console))
82
+ capture_script_in_loop(current_path, path_to_typo3_console, maximum_loop_count, cli_params, &block)
83
+ end
84
+
85
+ # Returns the last results of invocations of a typo3_console task with cli_params
86
+ # Invocation can be controlled by the result of a given block.
87
+ # True repeats the invocation until maximum_loop_count is reached.
88
+ # False stops invocation regardless of loop count.
89
+ #
90
+ # @param path [String] file path where task is to be executed
91
+ # @param maximum_loop_count [Integer] number of maximum attempts to run task
92
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
93
+ # @return [String] returns the last result of executing task
94
+ def capture_typo3_console_in_path_in_loop(path, maximum_loop_count, *cli_params, &block)
95
+ path_to_typo3_console = File.join(path, fetch(:path_to_typo3_console))
96
+ capture_script_in_loop(path, path_to_typo3_console, maximum_loop_count, cli_params, &block)
97
+ end
98
+
99
+ # Execute a script with cli_params in a specific directory
100
+ #
101
+ # @param path [String] file path where task is to be executed
102
+ # @param script [String] path to script
103
+ # @param cli_params [Array] list of arguments for typo3/cli_dispatch.phpsh
104
+ # @return [Boolean] returns true/false as success of execution
105
+ def run_script(path, script, *cli_params)
106
+ on primary :backend do |host|
107
+ within path do
108
+ unless test " [ -e #{script} ] "
109
+ error I18n.t('resource.not_exists_on_host', resource: script, host: host.hostname, scope: :dkdeploy)
110
+ next
111
+ end
112
+
113
+ with fetch(:typo3_environment_cli) do
114
+ execute :php, script, *cli_params
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+ # Returns the last results of invocations of a script
121
+ # Invocation can be controlled by the result of a given block.
122
+ # True repeats the invocation until maximum_loop_count is reached.
123
+ # False stops invocation regardless of loop count.
124
+ #
125
+ # @param path [String] file path where task is to be executed
126
+ # @param script [String] path to script
127
+ # @param maximum_loop_count [Integer] number of maximum attempts to run task
128
+ # @param cli_params [Array] list of arguments for the script
129
+ # @return [String] returns the last result of executing task
130
+ def capture_script_in_loop(path, script, maximum_loop_count, *cli_params)
131
+ output = nil
132
+
133
+ on primary :backend do |host|
134
+ within path do
135
+ unless test "[ -e #{script} ]"
136
+ error I18n.t('resource.not_exists_on_host', resource: script, host: host.hostname, scope: :dkdeploy)
137
+ next
138
+ end
139
+
140
+ loop_counter = 1
141
+
142
+ while loop_counter <= maximum_loop_count
143
+ info I18n.t('tasks.cli.show_loop_counter', loop_counter: loop_counter, scope: :dkdeploy)
144
+ with fetch(:typo3_environment_cli) do
145
+ output = capture :php, script, *cli_params
146
+ end
147
+ if block_given?
148
+ unless yield(output, loop_counter, self)
149
+ info I18n.t('tasks.cli.block_yields_false', loop_counter: loop_counter, scope: :dkdeploy)
150
+ break
151
+ end
152
+ end
153
+ loop_counter += 1
154
+ end
155
+ info I18n.t('tasks.cli.maximum_calls_reached', scope: :dkdeploy) if loop_counter > maximum_loop_count
156
+ end
157
+ end
158
+
159
+ output
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,25 @@
1
+ module Dkdeploy
2
+ module Typo3
3
+ module Cms
4
+ module Helpers
5
+ # Erb related helpers
6
+ module Erb
7
+ # Remove "<?php" at beginning and "?>" at end of string
8
+ #
9
+ # @param php_code [String] PHP Code to sanitize
10
+ # @return [String]
11
+ def sanitize_php(php_code)
12
+ php_code.strip.reverse.chomp('php?<').reverse.chomp('?>').strip.concat("\n")
13
+ end
14
+
15
+ # Return path to default template file for "AdditionalConfiguration.php" at gem
16
+ #
17
+ # @return [String]
18
+ def default_template_file
19
+ File.join(__dir__, '..', '..', '..', '..', '..', 'vendor', 'AdditionalConfiguration.php.erb')
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,111 @@
1
+ require 'i18n'
2
+
3
+ en = {
4
+ questions: {
5
+ create_new_keys: "Please enter 'yes' to create new Caretaker keys (everything else will not touch existing keys)",
6
+ additional_configuration_template: 'Please specify the location for the additional configuration file (e.g. vendor/AdditionalConfiguration.php.erb)',
7
+ typo3_languages_to_translate: 'Please specify the languages you wish to translate',
8
+ path: 'please specify the path'
9
+ },
10
+ dsl: {
11
+ invoke_for_server: {
12
+ set_filter: "Invoking task '%{task}' for server '%{host}'"
13
+ }
14
+ },
15
+ tasks: {
16
+ caretaker: {
17
+ errors: {
18
+ public_key_not_found: 'Public key at %{public_key_path} on %{host} not found!',
19
+ creating_keys_failed: 'Could not create Caretaker SSL keys on %{host}!',
20
+ configuring_keys_failed: 'Could not configure Caretaker SSL keys on %{host}!'
21
+ },
22
+ info: {
23
+ output_file: 'Output file %{output_file} (%{host}):',
24
+ output_file_one_liner: 'One line public key (%{host}):'
25
+ }
26
+ },
27
+ cli: {
28
+ show_loop_counter: 'Running cli task for the %{loop_counter}. time',
29
+ maximum_calls_reached: 'Maximum number of cli calls reached!',
30
+ block_yields_false: 'Breaking loop after %{loop_counter} run because block yields false'
31
+ },
32
+ db: {
33
+ username: 'Please enter TYPO3 admin username',
34
+ password: 'Please enter TYPO3 admin password'
35
+ },
36
+ fetch_extension: {
37
+ extension_name: 'Please enter name of extension',
38
+ extension_not_found: "Extension '%{extension}' not found!",
39
+ download: 'Downloading %{extension}...',
40
+ rsync: 'Rsyncing %{extension}...'
41
+ },
42
+ clear_temp: {
43
+ clear: 'Clearing typo3temp directory...'
44
+ },
45
+ install_tool: {
46
+ enable: 'Enabling install tool...',
47
+ disable: 'Disabling install tool...'
48
+ },
49
+ fetch_localconf: {
50
+ fetch: 'Fetching localconf...'
51
+ },
52
+ typoscript: {
53
+ copy_source: 'Please enter a common prefix for all config paths:',
54
+ config_paths: 'Please enter a space separated list of remote config paths:',
55
+ pagets_paths: 'Please enter a space separated list of remote PageTS paths:',
56
+ userts_paths: 'Please enter a space separated list of remote UserTS paths:',
57
+ config_file: 'Please enter the name of the config file:',
58
+ pagets_file: 'Please enter the name of the PageTS file:',
59
+ userts_file: 'Please enter the name of the UserTS file:',
60
+ typoscript_config_base_path: 'Please enter the base path of config files:',
61
+ typoscript_pagets_base_path: 'Please enter the base path of PageTS files:',
62
+ typoscript_userts_base_path: 'Please enter the base path of UserTS files:',
63
+ skipping: 'Skipping %{file_or_directory} because it does not exist...',
64
+ uploading: 'Uploading %{local_file} to %{remote_file}...',
65
+ uploaded: 'Uploaded %{local_file} to %{remote_file}.',
66
+ merged: 'Merged %{source_file} with %{target_file}.'
67
+ },
68
+ encryption_key: {
69
+ enter_key: 'Enter an encryption key (should be at least 9 characters):',
70
+ validation_error: 'Encryption key is empty or less than 9 characters.'
71
+ },
72
+ install_tool_password: {
73
+ enter_password: 'Install tool password:',
74
+ validation_error: 'Install tool password is empty.'
75
+ },
76
+ processed_file_checksums: {
77
+ typo3_version: 'Running TYPO3 CMS Version %{typo3_version}',
78
+ task_does_not_apply: 'This task does not apply!',
79
+ nothing_to_do: 'No updates to perform. All processed files checksums have already been updated.',
80
+ all_done: 'All processed file checksums updated!'
81
+ },
82
+ typo3: {
83
+ cms: {
84
+ v6: {
85
+ generate_additional_configuration_template: {
86
+ info: 'No need to generate template. There already is one in %{local_configuration_template}'
87
+ },
88
+ setup_additional_configuration: {
89
+ no_template_found: 'Can not find "AdditionalConfiguration.php" template at "%{configuration_template}"',
90
+ upload_info: 'Uploading merged AdditionalConfiguration to %{remote_configuration_file}',
91
+ no_local_file_info: '%{local_configuration_template} does not exist. File upload cancelled.',
92
+ file_not_found_and_ignored: 'Configuration file %{file} does not exist. File ignored.'
93
+ },
94
+ remove_extensions: {
95
+ info: 'The following extensions were removed: %{removed_extensions}',
96
+ no_extension_found: 'No installed extension found'
97
+ }
98
+ },
99
+ update_database: {
100
+ still_updates_available: 'Still database schema updates available. See log for details.'
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
106
+
107
+ I18n.backend.store_translations(:en, dkdeploy: en)
108
+
109
+ if I18n.respond_to?(:enforce_available_locales=)
110
+ I18n.enforce_available_locales = true
111
+ end
@@ -0,0 +1,18 @@
1
+ include Capistrano::DSL
2
+
3
+ namespace :typo3 do
4
+ namespace :cms do
5
+ namespace :cache do
6
+ desc 'Clear TYPO3 file cache directory'
7
+ task :clear_file_cache do |task|
8
+ on release_roles :app do
9
+ cache_path = File.join release_path, 'typo3temp', 'Cache'
10
+ execute :rm, '-rf', cache_path if test "[ -d #{cache_path} ]"
11
+ end
12
+
13
+ # Reenable Task to allow multiple invokation
14
+ task.reenable
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,60 @@
1
+ require 'erb'
2
+ require 'capistrano/i18n'
3
+ require 'dkdeploy/typo3/cms/i18n'
4
+ require 'dkdeploy/typo3/cms/helpers/cli'
5
+
6
+ include Dkdeploy::Typo3::Cms::Helpers::Cli
7
+
8
+ namespace :caretaker do
9
+ desc 'Create - if necessary or configured - and configure TYPO3 Caretaker SSL keys'
10
+ task :create_keys, :create_new_caretaker_keys do |_, args|
11
+ create_new_keys = 'yes' == ask_variable(args, :create_new_caretaker_keys, 'questions.create_new_keys')
12
+
13
+ on roles :app do |server|
14
+ key_is_missing = !test("[ -f #{fetch(:caretaker_private_key_path)} ]")
15
+
16
+ if create_new_keys || key_is_missing
17
+ begin
18
+ execute :mkdir, '-p', File.join(shared_path, 'config')
19
+ execute :openssl, 'genrsa', '-out', fetch(:caretaker_private_key_path), '2048', '2>/dev/null'
20
+ execute :openssl, 'rsa', '-in', fetch(:caretaker_private_key_path), '-pubout', '-out', fetch(:caretaker_public_key_path), '2>&1'
21
+ rescue SSHKit::Command::Failed
22
+ error I18n.t('tasks.caretaker.errors.creating_keys_failed', host: server.hostname, scope: :dkdeploy)
23
+ execute :rm, '-f', fetch(:caretaker_private_key_path)
24
+ execute :rm, '-f', fetch(:caretaker_public_key_path)
25
+ exit 1
26
+ end
27
+ end
28
+
29
+ begin
30
+ create_caretaker_instance_keys_template = ERB.new(File.read(fetch(:create_caretaker_instance_keys_template)), nil, '>')
31
+ create_caretaker_instance_keys_content = create_caretaker_instance_keys_template.result(binding)
32
+ upload! StringIO.new(create_caretaker_instance_keys_content), fetch(:create_caretaker_instance_keys_path), scp: true
33
+ execute :php, '-f', fetch(:create_caretaker_instance_keys_path)
34
+ execute :rm, '-f', fetch(:create_caretaker_instance_keys_path)
35
+ rescue SSHKit::Command::Failed
36
+ error I18n.t('tasks.caretaker.errors.configuring_keys_failed', host: server.hostname, scope: :dkdeploy)
37
+ execute :rm, '-r', fetch(:create_caretaker_instance_keys_path)
38
+ execute :rm, '-r', fetch(:caretaker_instance_keys_path)
39
+ exit 1
40
+ end
41
+ end
42
+ end
43
+
44
+ desc 'Display Caretaker SSL public key'
45
+ task :show_public_key do
46
+ on roles :app do |server|
47
+ if test("[ -f #{fetch(:caretaker_public_key_path)} ]")
48
+ public_key = capture :cat, fetch(:caretaker_public_key_path)
49
+ else
50
+ error I18n.t('tasks.caretaker.errors.public_key_not_found', public_key_path: fetch(:caretaker_public_key_path), host: server.hostname, scope: :dkdeploy)
51
+ exit 1
52
+ end
53
+
54
+ info I18n.t('tasks.caretaker.info.output_file', output_file: fetch(:caretaker_public_key_path), host: server.hostname, scope: :dkdeploy)
55
+ info public_key
56
+ info I18n.t('tasks.caretaker.info.output_file_one_liner', output_file: fetch(:caretaker_public_key_path), host: server.hostname, scope: :dkdeploy)
57
+ info public_key.gsub(/\n/m, '|')
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,45 @@
1
+ require 'json'
2
+ require 'dkdeploy/typo3/cms/helpers/cli'
3
+
4
+ include Capistrano::DSL
5
+ include Dkdeploy::Typo3::Cms::Helpers::Cli
6
+
7
+ namespace :typo3 do
8
+ namespace :cms do
9
+ namespace :cli do
10
+ desc 'Execute TYPO3 cli task'
11
+ task :run do |task, args|
12
+ typo3_cli(args.extras)
13
+
14
+ # Reenable Task to allow multiple invokation
15
+ task.reenable
16
+ end
17
+
18
+ desc 'Execute a typo3_console task'
19
+ task :typo3_console do |task, args|
20
+ typo3_console(args.extras)
21
+
22
+ # Reenable Task to allow multiple invokation
23
+ task.reenable
24
+ end
25
+
26
+ desc 'Uploads wrapper script to initialize PHP with environment variables'
27
+ task :upload_wrapper do
28
+ path_to_typo_cms_cli_dispatch = File.join release_path, 'typo3_cms_cli_dispatch.sh'
29
+ path_to_cli_dispatch = File.join release_path, 'typo3', 'cli_dispatch.phpsh'
30
+
31
+ bash_path = SSHKit.config.command_map[:bash]
32
+ wrapper_file_content = "#!#{bash_path}\n"
33
+ fetch(:typo3_environment_cli).each do |variable_name, variable_value|
34
+ wrapper_file_content << "#{variable_name.to_s.upcase}='#{variable_value}' "
35
+ end
36
+
37
+ php_interpreter_path = SSHKit.config.command_map[:php]
38
+ wrapper_file_content << "#{php_interpreter_path} #{path_to_cli_dispatch} $@\n"
39
+ on release_roles :backend do
40
+ upload! StringIO.new(wrapper_file_content), path_to_typo_cms_cli_dispatch
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end