Class: OsCtl::ExportFS::Operations::Server::Attach

Inherits:
Base
  • Object
show all
Includes:
Lib::Utils::Log, Lib::Utils::System
Defined in:
lib/osctl/exportfs/operations/server/attach.rb

Overview

Attach to the server’s namespaces and run shell

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

run

Constructor Details

#initialize(name) ⇒ Attach

Returns a new instance of Attach.

Parameters:

  • name (String)


10
11
12
13
# File 'lib/osctl/exportfs/operations/server/attach.rb', line 10

def initialize(name)
  super()
  @server = Server.new(name)
end

Instance Attribute Details

#serverObject (readonly, protected)

Returns the value of attribute server.



27
28
29
# File 'lib/osctl/exportfs/operations/server/attach.rb', line 27

def server
  @server
end

Instance Method Details

#bash_interactiveObject (protected)



29
30
31
# File 'lib/osctl/exportfs/operations/server/attach.rb', line 29

def bash_interactive
  syscmd("nix-build --no-out-link '<nixpkgs>'  -A bashInteractive").output.strip
end

#executeObject



15
16
17
18
19
20
21
22
23
# File 'lib/osctl/exportfs/operations/server/attach.rb', line 15

def execute
  bin_bash = File.join(bash_interactive, 'bin/bash')

  Operations::Server::Exec.run(server) do
    ENV['PATH'] = "#{ENV.fetch('PATH', nil)}:/run/current-system/sw/bin"
    ENV['PS1'] = "[NFSD #{server.name}]# "
    Process.exec(bin_bash, '--norc')
  end
end