From 772844cf2180ae66f359bc03875642c666c5196e Mon Sep 17 00:00:00 2001 From: Michael Sprauer Date: Thu, 4 Jun 2015 20:27:55 +0200 Subject: [PATCH] support mysql on a non standard port as well and document that (README.md and metadata.rb) --- README.md | 5 +++++ attributes/default.rb | 2 +- metadata.rb | 8 ++++++++ recipes/default.rb | 11 +++++++---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fee2616..35f27ec 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,11 @@ Attributes Host running the ownCloud database "127.0.0.1" + + node['owncloud']['config']['dbport'] + Port the ownCloud database is running at + "127.0.0.1" + node['owncloud']['config']['dbtableprefix'] Prefix for the ownCloud tables in the database diff --git a/attributes/default.rb b/attributes/default.rb index 92d68dd..f721434 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -47,7 +47,7 @@ default['owncloud']['config']['dbuser'] = 'owncloud' default['owncloud']['config']['dbpassword'] = nil default['owncloud']['config']['dbhost'] = '127.0.0.1' -default['owncloud']['config']['dbport'] = '3306' +default['owncloud']['config']['dbport'] = nil default['owncloud']['config']['dbtableprefix'] = '' default['owncloud']['config']['mail_smtpmode'] = 'sendmail' diff --git a/metadata.rb b/metadata.rb index ed4f79d..b31e039 100644 --- a/metadata.rb +++ b/metadata.rb @@ -308,6 +308,14 @@ :required => 'optional', :default => '"127.0.0.1"' + +attribute 'owncloud/config/dbport', + :display_name => 'ownCloud Database Port', + :description => 'Port the ownCloud database is running at', + :type => 'integer', + :required => 'optional', + :default => 'nil' + attribute 'owncloud/config/dbtableprefix', :display_name => 'ownCloud Database Table Prefix', :description => 'Prefix for the ownCloud tables in the database', diff --git a/recipes/default.rb b/recipes/default.rb index 56e8f0a..c6eb52c 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -119,6 +119,7 @@ # With SQLite the table prefix must be oc_ node.override['owncloud']['config']['dbtableprefix'] = 'oc_' when 'mysql' + node.default['owncloud']['config']['dbport'] = node['mysql']['port'] if node['owncloud']['config']['dbport'].nil? if %w{ localhost 127.0.0.1 }.include?(node['owncloud']['config']['dbhost']) # Install MySQL dbinstance = node['owncloud']['database']['instance'] @@ -130,7 +131,7 @@ data_dir node['owncloud']['database']['data_dir'] version node['owncloud']['database']['version'] bind_address '127.0.0.1' - port '3306' + port node['owncloud']['config']['dbport'] initial_root_password node['owncloud']['database']['rootpassword'] action [:create, :start] end @@ -138,7 +139,8 @@ mysql_connection_info = { :host => '127.0.0.1', :username => 'root', - :password => node['owncloud']['database']['rootpassword'] + :password => node['owncloud']['database']['rootpassword'], + :port => node['owncloud']['config']['dbport'] } mysql_database node['owncloud']['config']['dbname'] do @@ -150,13 +152,14 @@ connection mysql_connection_info database_name node['owncloud']['config']['dbname'] host 'localhost' + port node['owncloud']['config']['dbport'] password node['owncloud']['config']['dbpassword'] privileges [:all] action :grant end end when 'pgsql' - node.override['owncloud']['config']['dbport'] = node['postgresql']['config']['port'] + node.default['owncloud']['config']['dbport'] = node['postgresql']['config']['port'] if node['owncloud']['config']['dbport'].nil? if %w{ localhost 127.0.0.1 }.include?(node['owncloud']['config']['dbhost']) # Install PostgreSQL if ::Chef::Config[:solo] @@ -336,7 +339,7 @@ :dbname => node['owncloud']['config']['dbname'], :dbuser => node['owncloud']['config']['dbuser'], :dbpass => node['owncloud']['config']['dbpassword'], - :dbhost => node['owncloud']['config']['dbhost'] + ":#{node['owncloud']['config']['dbport']}", + :dbhost => "#{node['owncloud']['config']['dbhost']}:#{node['owncloud']['config']['dbport']}", :dbprefix => node['owncloud']['config']['dbtableprefix'], :admin_user => node['owncloud']['admin']['user'], :admin_pass => node['owncloud']['admin']['pass'],