From d8c26c73ee855a95a2e9370431f150def8c6b28e Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 18 Feb 2011 13:53:38 +0100 Subject: [PATCH] proper host detection through ifconfig --- lib/murder/murder.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/murder/murder.rb b/lib/murder/murder.rb index a3360b2..a696873 100644 --- a/lib/murder/murder.rb +++ b/lib/murder/murder.rb @@ -15,6 +15,8 @@ # limitations under the License. namespace :murder do + HOST = "LC_ALL=C ifconfig | grep 'inet addr' | awk '{print $2}' | awk -F : '{print $2}' | head -1" + desc <<-DESC Compresses the directory specified by the passed-in argument 'files_path' and creates a .torrent file identified by the 'tag' argument. Be sure to use the same 'tag' value with any following commands. Any .git directories will be skipped. Once completed, the .torrent will be downloaded to your local /tmp/TAG.tgz.torrent. DESC @@ -53,7 +55,7 @@ DESC task :start_seeding, :roles => :seeder do require_tag - run "SCREENRC=/dev/null SYSSCREENRC=/dev/null screen -dms 'seeder-#{tag}' python #{remote_murder_path}/murder_client.py seeder '#{filename}.torrent' '#{filename}' `LC_ALL=C host $HOSTNAME | awk '/has address/ {print $4}' | head -n 1`" + run "SCREENRC=/dev/null SYSSCREENRC=/dev/null screen -dms 'seeder-#{tag}' python #{remote_murder_path}/murder_client.py seeder '#{filename}.torrent' '#{filename}' `#{HOST}`" end desc <<-DESC @@ -91,7 +93,7 @@ end upload("#{filename}.torrent", "#{filename}.torrent", :via => :scp) - run "python #{remote_murder_path}/murder_client.py peer '#{filename}.torrent' '#{filename}' `LC_ALL=C host $CAPISTRANO:HOST$ | awk '/has address/ {print $4}' | head -n 1`" + run "python #{remote_murder_path}/murder_client.py peer '#{filename}.torrent' '#{filename}' `#{HOST}`" if ENV['path_is_file'] run "cp #{filename} #{destination_path}"