3 # Resource:: wordpress_plugin
5 # Copyright:: 2015, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
22 default_action :create
24 property :plugin, :kind_of => String, :name_property => true
25 property :site, :kind_of => String, :required => true
26 property :source, :kind_of => String
27 property :version, :kind_of => String
28 property :repository, :kind_of => String
29 property :revision, :kind_of => String
30 property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true
33 if new_resource.source
34 remote_directory plugin_directory do
36 source new_resource.source
37 owner node[:wordpress][:user]
38 group node[:wordpress][:group]
40 files_owner node[:wordpress][:user]
41 files_group node[:wordpress][:group]
45 plugin_repository = new_resource.repository || default_repository
47 if plugin_repository.end_with?(".git")
48 git plugin_directory do
50 repository plugin_repository
51 revision new_resource.revision
53 user node[:wordpress][:user]
54 group node[:wordpress][:group]
57 subversion plugin_directory do
59 repository plugin_repository
60 user node[:wordpress][:user]
61 group node[:wordpress][:group]
62 ignore_failure plugin_repository.start_with?("https://plugins.svn.wordpress.org/")
69 directory plugin_directory do
77 node[:wordpress][:sites][new_resource.site][:directory]
81 "#{site_directory}/wp-content/plugins/#{new_resource.plugin}"
84 def default_repository
85 version = new_resource.version ||
86 Chef::Wordpress.current_plugin_version(new_resource.plugin)
89 "https://plugins.svn.wordpress.org/#{new_resource.plugin}/trunk"
91 "https://plugins.svn.wordpress.org/#{new_resource.plugin}/tags/#{version}"
97 notifies :reload, "service[apache2]" if reload_apache