Class: Vagrant::LXC::Action::Boot

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lxc/action/boot.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Boot

Returns a new instance of Boot.



5
6
7
# File 'lib/vagrant-lxc/action/boot.rb', line 5

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-lxc/action/boot.rb', line 9

def call(env)
  @env = env

  config = env[:machine].provider_config

  utsname = env[:machine].config.vm.hostname || env[:machine].id
  config.customize 'utsname', utsname

  # Fix apparmor issues when starting Ubuntu 14.04 containers
  # See https://github.com/fgrehm/vagrant-lxc/issues/278 for more information
  if Dir.exists?('/sys/fs/pstore')
    config.customize 'mount.entry', '/sys/fs/pstore sys/fs/pstore none bind,optional 0 0'
  end

  # Make selinux read-only, see
  # https://github.com/fgrehm/vagrant-lxc/issues/301
  if Dir.exists?('/sys/fs/selinux')
    config.customize 'mount.entry', '/sys/fs/selinux sys/fs/selinux none bind,ro 0 0'
  end

  # Make /tmp a tmpfs to prevent init scripts from nuking synced folders mounted in here
  config.customize 'mount.entry', 'tmpfs tmp tmpfs nodev,nosuid,size=2G 0 0'

  env[:ui].info I18n.t("vagrant_lxc.messages.starting")
  env[:machine].provider.driver.start(config.customizations)

  @app.call env
end