Class: Host::Zeroconf
Instance Attribute Summary
Attributes inherited from Host
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(string) ⇒ Zeroconf
constructor
A new instance of Zeroconf.
- #setup ⇒ Object
Methods inherited from Host
#control_path_string, #remote?, #rsync_scp_local, #rsync_scp_remote, #ssh, #sshfs
Constructor Details
#initialize(string) ⇒ Zeroconf
Returns a new instance of Zeroconf.
104 105 106 |
# File 'lib/hostmanager.rb', line 104 def initialize(string) @string = string end |
Class Method Details
.from_string(string) ⇒ Object
101 102 103 |
# File 'lib/hostmanager.rb', line 101 def self.from_string(string) return new(string) end |
Instance Method Details
#setup ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/hostmanager.rb', line 107 def setup return if @user_name and @host @user_name, host = @string.split('@') @user_name.gsub!(/ /, '\ ') host = host.sub(/\(zeroconf\)/, '') raise 'avahi-utils required for zeroconf hosts' unless system 'avahi-resolve --version > /dev/null' # # puts system "avahi-resolve -n #{host} > /dev/null" unless `avahi-resolve -n #{host}` =~ /\d\./ puts "Must restart avahi-daemon - please enter an adminstrator password" # puts system 'sudo /usr/sbin/avahi-daemon -c' if system 'sudo /usr/sbin/avahi-daemon -c' puts `sudo /usr/sbin/avahi-daemon -r` else puts `sudo /usr/sbin/avahi-daemon -D` end end @host = `avahi-resolve -n #{host}`.split(/\s+/)[1] end |