50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/shellpress/wordpress.rb', line 50
def install
config = options[:config]
output = options[:output]
unless File.exists?("wp-content")
invoke :download
end
if config
say "*** Loading settings from #{config}", :green
settings = YAML.load_file(config)
elsif File.exists?("config.yml") && !options[:skip_config]
say "*** Loading settings from config.yml", :green
settings = YAML.load_file("config.yml")
else
settings = { "mysql" => {}, "wp" => {} }
settings["mysql"]["host"] = ask "MySQL host: "
settings["mysql"]["db"] = ask "MySQL db: "
settings["mysql"]["user"] = ask "MySQL user: "
settings["mysql"]["pass"] = ask "MySQL pass: "
settings["wp"]["title"]= ask "WordPress Title: "
settings["wp"]["user"] = ask "WordPress User: "
settings["wp"]["pass"] = ask "WordPress Pass: "
settings["wp"]["email"] = ask "WordPress Email: "
settings["wp"]["url"] = ask "WordPress URL: "
if output
File.open(output, "w") do |out|
say "*** #{output} written", :green
YAML.dump(settings, out)
end
end
end
say "*** Downloading WordPress Salt keys", :green
run "wget https://api.wordpress.org/secret-key/1.1/salt/ -O /tmp/wp.keys", :verbose => false
say "*** Updating wp-config with settings", :green
run "sed -e 's/localhost/#{settings['mysql']['host']}/' -e 's/database_name_here/#{settings['mysql']['db']}/' -e 's/username_here/#{settings['mysql']['user']}/' -e 's/password_here/#{settings['mysql']['pass']}/' wp-config-sample.php > wp-config.php", :verbose => false
run "sed -i '\/\#\@\-\/r \/tmp\/wp.keys' wp-config.php", :verbose => false
run "sed -i '\/\#\@\+\/,\/\#\@\-\/d' wp-config.php", :verbose => false
run "curl -d 'weblog_title=#{settings['wp']['title']}&user_name=#{settings['wp']['user']}&admin_password=#{settings['wp']['pass']}&admin_password2=#{settings['wp']['pass']}&admin_email=#{settings['wp']['email']}' http://#{settings['wp']['url']}/wp-admin/install.php?step=2"
end
|