Created
November 12, 2011 16:06
-
-
Save robhurring/1360736 to your computer and use it in GitHub Desktop.
Update or export wordpress using Thor from the command line : http://proccli.com/update-wordpress-ruby-thor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. install thor gem | |
> gem install thor | |
2. add wordpress script to your wordpress install root and chmod it | |
> chmod a+x wordpress | |
3. update wordpress | |
> ./wordpress update | |
4. export wordpress (php must have CLI support) | |
> ./wordpress export | gzip -c > ~/Desktop/wp_export.xml.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'thor' | |
require 'open-uri' | |
class Wordpress < Thor | |
include Thor::Actions | |
WORDPRESS_URL = %{http://wordpress.org} | |
FILENAME = %{latest.tar.gz} | |
TMP_PATH = %{/tmp} | |
desc 'update', 'Update wordpress to the latest version' | |
def update | |
download_url = URI.join(WORDPRESS_URL, FILENAME) | |
tmp_path = File.join(TMP_PATH, FILENAME) | |
install_path = File.expand_path(File.dirname(__FILE__)) | |
say %{Downloading latest version of wordpress from #{download_url}}, :yellow | |
run %{`which curl` #{download_url} -o #{tmp_path}} | |
say %{Installing to #{install_path}}, :yellow | |
if yes?(%{Continue? [yes/no]: }, :green) | |
say %{Updating...}, :yellow | |
run %{tar -C #{install_path} -xzf #{tmp_path} --strip 1} | |
else | |
say %{Update Aborted}, :red | |
end | |
end | |
# See: http://drincruz.blogspot.com/2009/11/wordpress-cli-export.html | |
desc 'export', 'Export wordpress to STDOUT (same as using the website)' | |
def export | |
code = %{ | |
require_once('wp-config.php'); | |
require_once('wp-admin/includes/export.php'); | |
export_wp(); | |
}.gsub(/\n|\s*/,'') | |
run %{`which php` -r "#{code}"}, :verbose => false | |
end | |
end | |
Wordpress.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment