X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/6d0cd3cd047cf2dc6d47d6482865d7aafe2588d2..078fb0e99fcd071b8617ccbb8aae52566e7bb122:/cookbooks/mediawiki/definitions/mediawiki_site.rb diff --git a/cookbooks/mediawiki/definitions/mediawiki_site.rb b/cookbooks/mediawiki/definitions/mediawiki_site.rb index f8f03c18e..8b0ddaccb 100644 --- a/cookbooks/mediawiki/definitions/mediawiki_site.rb +++ b/cookbooks/mediawiki/definitions/mediawiki_site.rb @@ -17,10 +17,10 @@ # limitations under the License. # -define :mediawiki_site, :action => [ :create, :enable ] do +define :mediawiki_site, :action => [:create, :enable] do name = params[:name] - #/etc/cron.d names cannot contain a dot + # /etc/cron.d names cannot contain a dot cron_name = name.tr(".", "_") aliases = Array(params[:aliases]) @@ -46,7 +46,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do :logo => params[:logo] || "$wgStylePath/common/images/wiki.png", :email_contact => params[:email_contact] || "", :email_sender => params[:email_sender] || "", - :email_sender_name => params[:email_sender_name] || "MediaWiki Mail", + :email_sender_name => params[:email_sender_name] || "MediaWiki Mail", :commons => params[:commons] || TRUE, :skin => params[:skin] || "vector", :site_notice => params[:site_notice] || "", @@ -57,10 +57,10 @@ define :mediawiki_site, :action => [ :create, :enable ] do :private_accounts => params[:private_accounts] || FALSE, :private => params[:private] || FALSE, :recaptcha_public => params[:recaptcha_public_key], - :recaptcha_private => params[:recaptcha_private_key], + :recaptcha_private => params[:recaptcha_private_key] } -#---------------- + #---------------- node.set_unless[:mediawiki][:sites][name] = {} node.set[:mediawiki][:sites][name][:site_directory] = site_directory @@ -68,7 +68,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do node.set[:mediawiki][:sites][name][:version] = mediawiki_version node.set_unless[:mediawiki][:sites][name][:wgSecretKey] = random_password(64) -#---------------- + #---------------- mysql_user "#{database_params[:username]}@localhost" do password database_params[:password] @@ -81,21 +81,21 @@ define :mediawiki_site, :action => [ :create, :enable ] do ruby_block "rename-installer-localsettings" do action :nothing block do - ::File.rename("#{mediawiki[:directory]}/LocalSettings.php","#{mediawiki[:directory]}/LocalSettings-install.php") + ::File.rename("#{mediawiki[:directory]}/LocalSettings.php", "#{mediawiki[:directory]}/LocalSettings-install.php") end end execute "#{mediawiki[:directory]}/maintenance/install.php" do action :nothing - #Use metanamespace as Site Name to ensure correct set namespace + # Use metanamespace as Site Name to ensure correct set namespace command "php maintenance/install.php --server '#{name}' --dbtype 'mysql' --dbname '#{database_params[:name]}' --dbuser '#{database_params[:username]}' --dbpass '#{database_params[:password]}' --dbserver '#{database_params[:host]}' --scriptpath /w --pass '#{mediawiki[:site_admin_pw]}' '#{mediawiki[:metanamespace]}' '#{mediawiki[:site_admin_user]}'" cwd mediawiki[:directory] user node[:mediawiki][:user] group node[:mediawiki][:group] not_if do - File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php") + File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php") end - notifies :create, 'ruby_block[rename-installer-localsettings]', :immediately + notifies :create, "ruby_block[rename-installer-localsettings]", :immediately end execute "#{mediawiki[:directory]}/maintenance/update.php" do @@ -106,38 +106,38 @@ define :mediawiki_site, :action => [ :create, :enable ] do group node[:mediawiki][:group] end - directory "#{site_directory}" do + directory site_directory do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0775 end - directory "#{mediawiki[:directory]}" do + directory mediawiki[:directory] do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0775 end - git "#{mediawiki[:directory]}" do + git mediawiki[:directory] do action :sync repository mediawiki_repository reference mediawiki_reference - #depth 1 + # depth 1 user node[:mediawiki][:user] group node[:mediawiki][:group] - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/update.php") + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/install.php]", :immediately + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/update.php]" end - #Safety catch if git doesn't update but install.php hasn't run + # Safety catch if git doesn't update but install.php hasn't run ruby_block "catch-installer-localsettings-run" do block do # end not_if do - File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php") + File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php") end - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/install.php]", :immediately action :create end @@ -165,12 +165,8 @@ define :mediawiki_site, :action => [ :create, :enable ] do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0664 - variables({ - :name => name, - :database_params => database_params, - :mediawiki => mediawiki - }) - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/update.php") + variables :name => name, :database_params => database_params, :mediawiki => mediawiki + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/update.php]" end template "/etc/cron.d/mediawiki-#{cron_name}" do @@ -179,11 +175,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do owner "root" group "root" mode 0644 - variables({ - :name => name, - :directory => site_directory, - :user => node[:mediawiki][:user] - }) + variables :name => name, :directory => site_directory, :user => node[:mediawiki][:user] end template "/etc/cron.daily/mediawiki-#{cron_name}-backup" do @@ -192,18 +184,14 @@ define :mediawiki_site, :action => [ :create, :enable ] do owner "root" group "root" mode 0700 - variables({ - :name => name, - :directory => site_directory, - :database_params => database_params - }) + variables :name => name, :directory => site_directory, :database_params => database_params end - #MediaWiki Default Extension + # MediaWiki Default Extension mediawiki_extension "Cite" do site name - template "mw-ext-Cite.inc.php.erb" + template "mw-ext-Cite.inc.php.erb" end mediawiki_extension "ConfirmEdit" do @@ -276,7 +264,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do end # MediaWiki Language Extension Bundle - #fixme should automatically resolve tag + # FIXME: should automatically resolve tag mw_lang_ext_bundle_tag = "2014.09" mediawiki_extension "Babel" do @@ -302,25 +290,21 @@ define :mediawiki_site, :action => [ :create, :enable ] do tag mw_lang_ext_bundle_tag 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 name - # template "mw-ext-Translate.inc.php.erb" - # tag mw_lang_ext_bundle_tag - #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 name + # template "mw-ext-Translate.inc.php.erb" + # tag mw_lang_ext_bundle_tag + # end mediawiki_extension "UniversalLanguageSelector" do site name @@ -356,7 +340,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do template "mw-ext-CirrusSearch.inc.php.erb" end - #OSM specifc extensions + # OSM specifc extensions mediawiki_extension "osmtaginfo" do site name @@ -403,14 +387,11 @@ define :mediawiki_site, :action => [ :create, :enable ] do cookbook "mediawiki" template "apache.erb" directory site_directory - variables({ - :aliases => aliases, - :mediawiki => mediawiki - }) + variables :aliases => aliases, :mediawiki => mediawiki notifies :reload, "service[apache2]" end - #Fixme - Needs to run once + # FIXME: needs to run once execute "#{mediawiki[:directory]}/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php" do action :nothing command "php extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php" @@ -418,5 +399,4 @@ define :mediawiki_site, :action => [ :create, :enable ] do user node[:mediawiki][:user] group node[:mediawiki][:group] end - end