2014-03-06 08:18:29 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module GuestSmartos
|
|
|
|
module Cap
|
|
|
|
class ChangeHostName
|
|
|
|
def self.change_host_name(machine, name)
|
2017-06-16 20:58:07 +00:00
|
|
|
sudo = machine.config.smartos.suexec_cmd
|
2014-03-06 08:18:29 +00:00
|
|
|
|
2017-06-16 20:58:07 +00:00
|
|
|
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
|
2014-03-06 08:18:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|