vaguerent/plugins/guests/smartos/cap/change_host_name.rb
James Nugent b0b9d044b5 guests/smartos: Add/fix various guest capabilities
This commit adds a variety of fixes for SmartOS guest support:

- Host name setting now works in the global zone and in non-global zones
- NFS now works in the global zone and the non-global zone.
- Tests are updated and moved to the (apparently) more modern style
2017-06-16 17:00:50 -04:00

27 lines
704 B
Ruby

module VagrantPlugins
module GuestSmartos
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
sudo = machine.config.smartos.suexec_cmd
machine.communicate.tap do |comm|
comm.execute <<-EOH.sub(/^ */, '')
if hostname | grep '#{name}' ; then
exit 0
fi
if [ -d /usbkey ] && [ "$(zonename)" == "global" ] ; then
#{sudo} sed -i '' 's/hostname=.*/hostname=#{name}/' /usbkey/config
fi
#{sudo} echo '#{name}' > /etc/nodename
#{sudo} hostname #{name}
EOH
end
end
end
end
end
end