From be95a6db8336a9c809b7de38192937491c0268cd Mon Sep 17 00:00:00 2001
From: Stefan Galinski <stefan@sgalinski.de>
Date: Sat, 14 Feb 2015 17:57:07 +0100
Subject: [PATCH] [FEATURE] Allow the installation of a TYPO3 version

---
 attributes/default.rb |  2 ++
 recipes/default.rb    | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/attributes/default.rb b/attributes/default.rb
index c6f737f..fa381b3 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -6,6 +6,8 @@ default['typo3_site']['hostname'] = 'site.dev'
 default['typo3_site']['repository'] = ''
 default['typo3_site']['repository_hostname'] = 'git.domain'
 default['typo3_site']['repository_port'] = 22
+default['typo3_site']['download_typo3'] = false
+default['typo3_site']['typo3_version'] = '6.2'
 default['typo3_site']['deploy_dump'] = '~/site/dump.sql'
 
 # Example:
diff --git a/recipes/default.rb b/recipes/default.rb
index d8ba999..c183b89 100644
--- a/recipes/default.rb
+++ b/recipes/default.rb
@@ -116,6 +116,46 @@ web_app node['typo3_site']['hostname'] do
 	server_aliases node['typo3_site']['server_aliases']
 end
 
+###################
+### Setup TYPO3 ###
+###################
+
+if node['typo3_site']['download_typo3']
+	bash 'Setup TYPO3' do
+		cwd '/home/vagrant/'
+		user 'vagrant'
+		group 'vagrant'
+		timeout 3000000
+
+		code <<-EOF
+			if [ ! -d #{node['typo3_site']['webroot']}/typo3_src-#{node['typo3_site']['typo3_version']} ]
+			then
+				wget http://get.typo3.org/#{node['typo3_site']['typo3_version']} \
+					-O typo3_src-#{node['typo3_site']['typo3_version']}.tgz
+
+				mkdir -p #{node['typo3_site']['webroot']}/typo3_src-#{node['typo3_site']['typo3_version']}
+				tar -xzf typo3_src-#{node['typo3_site']['typo3_version']}.tgz --strip-components=1 \
+					-C #{node['typo3_site']['webroot']}/typo3_src-#{node['typo3_site']['typo3_version']};
+			fi
+
+			cd #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}
+			rm -f typo3_src
+			ln -s ../typo3_src-#{node['typo3_site']['typo3_version']} typo3_src
+
+			if [ ! -f typo3 ]
+			then
+				ln -s typo3_src/typo3 typo3
+			fi
+
+			if [ ! -f index.php ]
+			then
+				ln -s typo3_src/index.php index.php
+			fi
+		EOF
+		action :run
+	end
+end
+
 #######################
 ### Provide Sources ###
 #######################
@@ -172,7 +212,6 @@ end
 ### Create Links ###
 ####################
 
-
 node['typo3_site']['create_links'].each do |link_data|
 	link link_data['source'] do
 		to link_data['target']
-- 
GitLab