Created
March 11, 2012 15:24
-
-
Save muxcmux/2016803 to your computer and use it in GitHub Desktop.
Simple thor task for uploading via LFTP
This file contains hidden or 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
class Blog < Thor | |
no_tasks do | |
def config | |
{ | |
:u => 'username', # user | |
:p => 'password', # pass | |
:h => 'ftp://your.ftpserver.com', # host | |
:r => 'octopress', # remote dir | |
:l => File.basename(File.join(__FILE__, '..', 'public')) # local dir | |
} | |
end | |
# issue commands with lftp | |
def lftp commands | |
pre = [] | |
pre << "set ssl:verify-certificate no" | |
pre << "open -u #{config[:u]},#{config[:p]} -p 21 #{config[:h]}" | |
pre << "cd #{config[:r]}" | |
pre.reverse.each { |c| commands.unshift c} | |
%x(lftp -c "#{commands.compact.join(';')}") | |
end | |
end | |
desc "upload", "Uploads the website to server via lftp" | |
def upload | |
puts 'Cleaning up...' | |
lftp ['rm -rf public/'] | |
puts "Uploading..." | |
lftp ["mirror -R #{config[:l]}"] | |
puts "Done!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment