Class: OsCtld::Container::Hooks::PostMount

Inherits:
Base show all
Defined in:
lib/osctld/container/hooks.rb

Instance Attribute Summary

Attributes inherited from Base

#ct

Attributes inherited from Hook::Base

#event_instance, #opts

Instance Method Summary collapse

Methods inherited from Base

ct_hook, #setup

Methods inherited from Hook::Base

blocking, blocking?, #blocking?, #exec, hook, #initialize, #setup

Constructor Details

This class inherits a constructor from OsCtld::Hook::Base

Instance Method Details

#environment ⇒ Object (protected)



93
94
95
96
97
98
# File 'lib/osctld/container/hooks.rb', line 93

def environment
  super.merge({
    'OSCTL_CT_ROOTFS_MOUNT' => opts[:rootfs_mount],
    'OSCTL_CT_NS_PID' => opts[:ns_pid].to_s
  })
end

#executable(hook_path) ⇒ Object (protected)



100
101
102
103
104
105
106
# File 'lib/osctld/container/hooks.rb', line 100

def executable(hook_path)
  if opts[:mnt_ns]
    ['nsenter', "--mount=/proc/self/fd/#{opts[:mnt_ns].fileno}", hook_path]
  else
    ['nsenter', '--target', opts.fetch(:ns_pid).to_s, '--mount', hook_path]
  end
end

#inherited_files ⇒ Object (protected)



108
109
110
# File 'lib/osctld/container/hooks.rb', line 108

def inherited_files
  [opts[:mnt_ns]].compact
end