From aee0dbc330e98c8a0dca5fc740ff4fda2e474388 Mon Sep 17 00:00:00 2001
From: Stefan Galinski <stefan@sgalinski.de>
Date: Wed, 31 Aug 2016 22:16:03 +0200
Subject: [PATCH] [FEATURE] Add a web_directory option for e.g. composer setups

---
 attributes/default.rb |  1 +
 recipes/default.rb    | 23 ++++++++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/attributes/default.rb b/attributes/default.rb
index d4cc462..896b903 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -3,6 +3,7 @@ default['typo3_site']['webroot'] = '/var/www'
 default['typo3_site']['site_configuration'] = 'SiteConfiguration.php'
 default['typo3_site']['server_aliases'] = 'www.site.dev'
 default['typo3_site']['hostname'] = 'site.dev'
+default['typo3_site']['web_directory'] = ''
 default['typo3_site']['repository'] = ''
 default['typo3_site']['repository_hostname'] = ''
 default['typo3_site']['repository_port'] = 22
diff --git a/recipes/default.rb b/recipes/default.rb
index f0c12e7..1ba6303 100644
--- a/recipes/default.rb
+++ b/recipes/default.rb
@@ -243,16 +243,17 @@ end
 if node['platform_version'] == '16.04'
 	web_app node['typo3_site']['hostname'] do
 		template 'vHost-xenial.conf.erb'
-		docroot "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/"
+		docroot "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/"
 		server_name node['typo3_site']['hostname']
 		server_aliases node['typo3_site']['server_aliases']
 	end
 else
 	web_app node['typo3_site']['hostname'] do
 		template 'vHost.conf.erb'
-		docroot "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/"
+		docroot "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/"
 		server_name node['typo3_site']['hostname']
 		server_aliases node['typo3_site']['server_aliases']
+		server_aliases node['typo3_site']['server_aliases']
 	end
 end
 
@@ -318,8 +319,8 @@ bash 'Setup TYPO3' do
 				-C #{node['typo3_site']['webroot']}/typo3_src-#{node['typo3_site']['typo3_version']};
 		fi
 
-		mkdir -p #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']};
-		cd #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}
+		mkdir -p #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}
+		cd #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}
 		rm -f typo3_src
 		ln -s ../typo3_src-#{node['typo3_site']['typo3_version']} typo3_src
 		touch typo3conf/ENABLE_INSTALL_TOOL
@@ -354,19 +355,19 @@ node['typo3_site']['sync_directories'].each do |sync_data|
 		group data_bag['groupId']
 		timeout 3000000
 		only_if {
-			sync_data['sync'] or not ::File.exists?("#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{sync_data['local']}")
+			sync_data['sync'] or not ::File.exists?("#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}")
 		}
 
 		if sync_data['hostname']
 			code <<-EOF
 				rsync --delete -auvz --progress -e "ssh -p #{sync_data['port']} -o StrictHostKeyChecking=no" \
 					--no-o --no-g #{sync_data['user']}@#{sync_data['hostname']}:#{sync_data['remote']} \
-					"#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{sync_data['local']}";
+					"#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}";
 			EOF
 		else
 			code <<-EOF
 				rsync --delete -auvz --progress --no-o --no-g #{sync_data['remote']} \
-				"#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{sync_data['local']}";
+				"#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}";
 			EOF
 		end
 		action :run
@@ -392,13 +393,13 @@ end
 ### Provide site specific configuration ###
 ###########################################
 
-directory "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/typo3conf/" do
+directory "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3conf/" do
 	owner 'vagrant'
 	mode '0755'
 	action :create
 end
 
-template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/typo3conf/#{node['typo3_site']['site_configuration']}" do
+template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3conf/#{node['typo3_site']['site_configuration']}" do
 	source 'SiteConfiguration.php.erb'
 	owner 'vagrant'
 	mode '0660'
@@ -407,7 +408,7 @@ template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/typ
 	})
 end
 
-template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/typo3conf/AdditionalConfiguration.php" do
+template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3conf/AdditionalConfiguration.php" do
 	source 'AdditionalConfiguration.php'
 	owner 'vagrant'
 	mode '0660'
@@ -546,7 +547,7 @@ if node['typo3_site']['solr']['init']
 	end
 
 	execute 'solr-updateConnections' do
-		command "php #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/typo3/cli_dispatch.phpsh solr updateConnections || true"
+		command "php #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3/cli_dispatch.phpsh solr updateConnections || true"
 		user 'vagrant'
 		group data_bag['groupId']
 		action :run
-- 
GitLab