Module: DanarchyDeploy::Applicator::WordPress

Defined in:
lib/danarchy_deploy/applicator/wordpress.rb,
lib/danarchy_deploy/applicator/wordpress/wpcli.rb,
lib/danarchy_deploy/applicator/wordpress/wpconfig.rb

Defined Under Namespace

Classes: WPCLI, WPConfig

Class Method Summary collapse

Class Method Details

.new(app, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/danarchy_deploy/applicator/wordpress.rb', line 8

def self.new(app, options)
  puts "\n" + self.name
  puts " > Checking on WordPress installation at '#{app[:path]}'."

  app[:prefix] = cmd_prefix(app)
  wpcli = WordPress::WPCLI.new(app, options)
  app   = WordPress::WPConfig.new(app, options)

  # if options[:first_run] && 
  wpcli.install if wpcli.version[:stderr] =~
                   /Error: This does not seem to be a WordPress install/

  siteurl = wpcli.siteurl
  if siteurl =~ /http.*:\/\/(www.|)#{app[:domain]}/
    puts "   |+ Siteurl: #{siteurl} found in the WP database. Continuing with deployment."
  elsif siteurl =~ /Error: The site you have requested is not installed/
    puts "   |! Domain: #{app[:domain]} not found in current database."

    db_backup = app[:path] + '/' + app[:domain].gsub('.','_') + '.sql'
    if File.exist?(db_backup) && options[:first_run]
      puts "   |+ Importing from local backup."
      import = wpcli.import
    else
      puts "   |- . No database content! Skipping deployment of #{app[:domain]}."
      return app
    end
  else
    puts "   ! Domain: #{app[:domain]} does not match the database's current siteurl: #{siteurl}"
    puts "     |- Skipping #{app[:domain]} deployment"
    return app
  end
    
  if app[:autoupdate]
    wpcli.update
  else
    wpcli.check_update
  end

  app.delete(:prefix)
  app        
end