vaguerent/plugins/guests/openwrt/cap/change_host_name.rb
Jeff Bonhag 50d995f51d
Guest support for OpenWrt
This commit includes the following capabilties for OpenWrt:

- Guest detection
- SSH key replacement
- Change host name
- Rsync
2020-07-29 11:32:46 -04:00

20 lines
500 B
Ruby

module VagrantPlugins
module GuestOpenWrt
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
comm = machine.communicate
if !comm.test("uci get system.@system[0].hostname | grep '^#{name}$'", sudo: false)
comm.execute <<~EOH
uci set system.@system[0].hostname='#{name}'
uci commit system
/etc/init.d/system reload
EOH
end
end
end
end
end
end