property :directory, :kind_of => String
property :version, :kind_of => String, :default => "1.33"
property :database_name, :kind_of => String, :required => true
-property :database_user, :kind_of => String, :required => true
-property :database_password, :kind_of => String, :required => true
+property :database_user, :kind_of => String, :required => [:create, :update]
+property :database_password, :kind_of => String, :required => [:create, :update]
property :sitename, :kind_of => String, :default => "OpenStreetMap Wiki"
property :metanamespace, :kind_of => String, :default => "OpenStreetMap"
property :logo, :kind_of => String, :default => "$wgStylePath/common/images/wiki.png"
property :site_notice, :kind_of => [String, TrueClass, FalseClass], :default => false
property :site_readonly, :kind_of => [String, TrueClass, FalseClass], :default => false
property :admin_user, :kind_of => String, :default => "Admin"
-property :admin_password, :kind_of => String, :required => true
+property :admin_password, :kind_of => String, :required => [:create]
property :private_accounts, :kind_of => [TrueClass, FalseClass], :default => false
property :private_site, :kind_of => [TrueClass, FalseClass], :default => false
property :recaptcha_public_key, :kind_of => String
property :recaptcha_private_key, :kind_of => String
property :extra_file_extensions, :kind_of => [String, Array], :default => []
+property :fpm_max_children, :kind_of => Integer, :default => 5
property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true
action :create do
- node.normal_unless[:mediawiki][:sites][new_resource.site] = {}
+ node.default[:mediawiki][:sites][new_resource.site] = {
+ :directory => site_directory,
+ :version => new_resource.version
+ }
- node.normal[:mediawiki][:sites][new_resource.site][:directory] = site_directory
- node.normal[:mediawiki][:sites][new_resource.site][:version] = new_resource.version
-
- node.normal_unless[:mediawiki][:sites][new_resource.site][:wgSecretKey] = SecureRandom.base64(48)
+ secret_key = persistent_token("mediawiki", new_resource.site, "wgSecretKey")
mysql_user "#{new_resource.database_user}@localhost" do
password new_resource.database_password
declare_resource :directory, site_directory do
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o775
+ mode "775"
end
declare_resource :directory, mediawiki_directory do
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o775
+ mode "775"
end
mediawiki_reference = "REL#{new_resource.version}".tr(".", "_")
source "composer.local.json.erb"
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o664
+ mode "664"
end
# Safety catch if git doesn't update but install.php hasn't run
declare_resource :directory, "#{mediawiki_directory}/images" do
owner "www-data"
group node[:mediawiki][:group]
- mode 0o775
+ mode "775"
end
declare_resource :directory, "#{mediawiki_directory}/cache" do
owner "www-data"
group node[:mediawiki][:group]
- mode 0o775
+ mode "775"
end
declare_resource :directory, "#{mediawiki_directory}/LocalSettings.d" do
user node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o775
+ mode "775"
end
template "#{mediawiki_directory}/LocalSettings.php" do
source "LocalSettings.php.erb"
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o664
+ mode "664"
variables :name => new_resource.site,
:directory => mediawiki_directory,
:database_params => database_params,
- :mediawiki => mediawiki_params
+ :mediawiki => mediawiki_params,
+ :secret_key => secret_key
notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]"
end
- template "/etc/cron.d/mediawiki-#{cron_name}" do
- cookbook "mediawiki"
- source "mediawiki.cron.erb"
- owner "root"
- group "root"
- mode 0o644
- variables :name => new_resource.site, :directory => site_directory,
- :user => node[:mediawiki][:user]
+ cron_d "mediawiki-#{cron_name}-sitemap" do
+ comment "Generate sitemap.xml daily"
+ minute "30"
+ hour "0"
+ user node[:mediawiki][:user]
+ command "/usr/bin/nice /usr/bin/php -d memory_limit=2048M -d error_reporting=22517 #{site_directory}/w/maintenance/generateSitemap.php --server=https://#{new_resource.site} --urlpath=https://#{new_resource.site}/ --fspath=#{site_directory} --quiet --skip-redirects"
+ end
+
+ cron_d "mediawiki-#{cron_name}-jobs" do
+ comment "Run mediawiki jobs"
+ minute "*/3"
+ user node[:mediawiki][:user]
+ command "/usr/bin/nice /usr/bin/php -d memory_limit=2048M -d error_reporting=22517 #{site_directory}/w/maintenance/runJobs.php --server=https://#{new_resource.site} --maxtime=160 --memory-limit=2048M --procs=8 --quiet"
+ end
+
+ cron_d "mediawiki-#{cron_name}-email-jobs" do
+ comment "Run mediawiki email jobs"
+ user node[:mediawiki][:user]
+ command "/usr/bin/nice /usr/bin/php -d memory_limit=2048M -d error_reporting=22517 #{site_directory}/w/maintenance/runJobs.php --server=https://#{new_resource.site} --maxtime=30 --type=enotifNotify --memory-limit=2048M --procs=4 --quiet"
+ end
+
+ cron_d "mediawiki-#{cron_name}-refresh-links" do
+ comment "Run mediawiki refresh links table weekly"
+ minute "5"
+ hour "0"
+ weekday "0"
+ user node[:mediawiki][:user]
+ command "/usr/bin/nice /usr/bin/php -d memory_limit=2048M -d error_reporting=22517 #{site_directory}/w/maintenance/refreshLinks.php --server=https://#{new_resource.site} --memory-limit=2048M --quiet"
+ end
+
+ cron_d "mediawiki-#{cron_name}-cleanup-gs" do
+ comment "Clean up imagemagick garbage"
+ minute "10"
+ hour "2"
+ user node[:mediawiki][:user]
+ command "/usr/bin/find /tmp/ -maxdepth 1 -type f -user www-data -mmin +90 -name 'gs_*' -delete"
+ end
+
+ cron_d "mediawiki-#{cron_name}-cleanup-magick" do
+ comment "Clean up imagemagick garbage"
+ minute "20"
+ hour "2"
+ user node[:mediawiki][:user]
+ command "/usr/bin/find /tmp/ -maxdepth 1 -type f -user www-data -mmin +90 -name 'magick-*' -delete"
end
template "/etc/cron.daily/mediawiki-#{cron_name}-backup" do
source "mediawiki-backup.cron.erb"
owner "root"
group "root"
- mode 0o700
+ mode "700"
variables :name => new_resource.site,
:directory => site_directory,
:database_params => database_params
update_site false
end
- # LocalisationUpdate Update Cron
- # template "/etc/cron.d/mediawiki-#{name}-LocalisationUpdate" do
- # cookbook "mediawiki"
- # source "mediawiki-LocalisationUpdate.cron.erb"
- # owner "root"
- # group "root"
- # mode 0755
- # variables :name => name, :directory => site_directory, :user => node[:mediawiki][:user]
- # end
-
# mediawiki_extension "Translate" do
# site new_resource.site
# template "mw-ext-Translate.inc.php.erb"
mediawiki_extension "CheckUser" do
site new_resource.site
template "mw-ext-CheckUser.inc.php.erb"
- repository "git://github.com/migurski/extension-checkuser.git"
- reference "0e3bf4aa3d05b60240b0abc1a00d87c9fc4c5cf7"
update_site false
end
cookbook "mediawiki"
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o644
+ mode "644"
backup false
end
cookbook "mediawiki"
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o644
+ mode "644"
backup false
end
cookbook "mediawiki"
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o644
+ mode "644"
backup false
end
domains [new_resource.site] + Array(new_resource.aliases)
end
+ php_fpm new_resource.site do
+ pm_max_children new_resource.fpm_max_children
+ php_admin_values "open_basedir" => "#{site_directory}/:/usr/share/php/:/dev/null:/tmp/"
+ php_values "memory_limit" => "500M",
+ "max_execution_time" => "240",
+ "upload_max_filesize" => "70M",
+ "post_max_size" => "100M"
+ end
+
apache_site new_resource.site do
cookbook "mediawiki"
template "apache.erb"
source "LocalSettings.php.erb"
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
- mode 0o664
+ mode "664"
variables :name => new_resource.site,
:directory => mediawiki_directory,
:database_params => database_params,
end
action_class do
+ include Chef::Mixin::PersistentToken
+
def site_directory
new_resource.directory || "/srv/#{new_resource.site}"
end