Class: VMC::Micro::Switcher::Darwin
- Inherits:
-
Base
show all
- Defined in:
- lib/vmc/micro/switcher/darwin.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #offline, #online, #status
Instance Method Details
#adminrun(command) ⇒ Object
4
5
6
|
# File 'lib/vmc/micro/switcher/darwin.rb', line 4
def adminrun(command)
VMC::Micro.run_command("osascript", "-e 'do shell script \"#{command}\" with administrator privileges'")
end
|
#set_nameserver(domain, ip) ⇒ Object
8
9
10
11
|
# File 'lib/vmc/micro/switcher/darwin.rb', line 8
def set_nameserver(domain, ip)
File.open("/tmp/#{domain}", 'w') { |file| file.write("nameserver #{ip}") }
adminrun("mkdir -p /etc/resolver;mv /tmp/#{domain} /etc/resolver/")
end
|
#unset_nameserver(domain, ip) ⇒ Object
13
14
15
16
|
# File 'lib/vmc/micro/switcher/darwin.rb', line 13
def unset_nameserver(domain, ip)
err "domain missing" unless domain
adminrun("rm -f /etc/resolver/#{domain}")
end
|