Class: VagrantPlugins::Linode::Actions::SetupHostname
- Inherits:
-
Object
- Object
- VagrantPlugins::Linode::Actions::SetupHostname
- Defined in:
- lib/vagrant-linode/actions/setup_hostname.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ SetupHostname
constructor
A new instance of SetupHostname.
Constructor Details
#initialize(app, env) ⇒ SetupHostname
Returns a new instance of SetupHostname.
9 10 11 12 13 |
# File 'lib/vagrant-linode/actions/setup_hostname.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::linode::setup_hostname') end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-linode/actions/setup_hostname.rb', line 15 def call(env) # Check if setup is enabled return @app.call(env) unless @machine.provider_config.setup? # Set Hostname if @machine.config.vm.hostname env[:ui].info I18n.t('vagrant_linode.info.modifying_host', name: @machine.config.vm.hostname) @machine.communicate.execute(" sudo echo -n \#{@machine.config.vm.hostname} > /etc/hostname;\n sudo hostname -F /etc/hostname\n BASH\n end\nend\n") |