Skip to content

Commit

Permalink
support mysql on a non standard port as well and document that (READM…
Browse files Browse the repository at this point in the history
…E.md and metadata.rb)
  • Loading branch information
MichaelSp committed Jun 4, 2015
1 parent 7cdb4be commit 772844c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ Attributes
<td>Host running the ownCloud database</td>
<td><code>"127.0.0.1"</code></td>
</tr>
<tr>
<td><code>node['owncloud']['config']['dbport']</code></td>
<td>Port the ownCloud database is running at</td>
<td><code>"127.0.0.1"</code></td>
</tr>
<tr>
<td><code>node['owncloud']['config']['dbtableprefix']</code></td>
<td>Prefix for the ownCloud tables in the database</td>
Expand Down
2 changes: 1 addition & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 7 additions & 4 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -130,15 +131,16 @@
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

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
Expand All @@ -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]
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit 772844c

Please sign in to comment.