Class: VMC::Micro::Switcher::Linux
- Defined in:
- lib/vmc/micro/switcher/linux.rb
Instance Method Summary collapse
Methods inherited from Base
#initialize, #offline, #online, #status
Constructor Details
This class inherits a constructor from VMC::Micro::Switcher::Base
Instance Method Details
#set_nameserver(domain, ip) ⇒ Object
4 5 6 7 8 |
# File 'lib/vmc/micro/switcher/linux.rb', line 4 def set_nameserver(domain, ip) VMC::Micro.run_command("sudo", "sed -i'.backup' '1 i nameserver #{ip}' /etc/resolv.conf") # lock resolv.conf so Network Manager doesn't clear out the file when offline VMC::Micro.run_command("sudo", "chattr +i /etc/resolv.conf") end |
#unset_nameserver(domain, ip) ⇒ Object
10 11 12 13 |
# File 'lib/vmc/micro/switcher/linux.rb', line 10 def unset_nameserver(domain, ip) VMC::Micro.run_command("sudo", "chattr -i /etc/resolv.conf") VMC::Micro.run_command("sudo", "sed -i'.backup' '/#{ip}/d' /etc/resolv.conf") end |