class RailsPwnerer::Scaffolds::HookDyndns
hooks up the dynamic dns service
Public Class Methods
go(ddns_hostname, ddns_username, ddns_password)
click to toggle source
standalone runner
# File lib/rails_pwnerer/scaffolds/hook_dyndns.rb 43 def self.go(ddns_hostname, ddns_username, ddns_password) 44 self.new.run ddns_hostname, ddns_username, ddns_password 45 end
Public Instance Methods
configure(ddns_hostname, ddns_username, ddns_password)
click to toggle source
configures ddclient
# File lib/rails_pwnerer/scaffolds/hook_dyndns.rb 18 def configure(ddns_hostname, ddns_username, ddns_password) 19 File.open(RailsPwnerer::Config.path_to(:ddclient_config), 'w') do |f| 20 f << <<END_CONFIG 21 pid=/var/run/ddclient.pid 22 use=web, web=checkip.dyndns.com/, web-skip='IP Address' 23 24 protocol=dyndns2 25 server=members.dyndns.org 26 27 login=#{ddns_username} 28 password='#{ddns_password}' 29 #{ddns_hostname} 30 END_CONFIG 31 end 32 end
enable_daemon()
click to toggle source
patches the ddclient boot script and configuration to enable the daemon
# File lib/rails_pwnerer/scaffolds/hook_dyndns.rb 7 def enable_daemon 8 boot_script = File.open(path_to_boot_script('ddclient'), 'r') { |f| f.read } 9 boot_script.gsub!(/run_daemon\=false/, 'run_daemon=true') 10 File.open(path_to_boot_script('ddclient'), 'w') { |f| f.write boot_script } 11 12 dd_defaults = File.open(path_to_boot_script_defaults('ddclient'), 'r') { |f| f.read } 13 dd_defaults.gsub!(/run_daemon\=\"false\"/, 'run_daemon="true"') 14 File.open(path_to_boot_script_defaults('ddclient'), 'w') { |f| f.write dd_defaults } 15 end
run(ddns_hostname, ddns_username, ddns_password)
click to toggle source
runner
# File lib/rails_pwnerer/scaffolds/hook_dyndns.rb 35 def run(ddns_hostname, ddns_username, ddns_password) 36 control_boot_script 'ddclient', :stop 37 configure ddns_hostname, ddns_username, ddns_password 38 enable_daemon 39 control_boot_script 'ddclient', :start 40 end