Class: Nib::Exec

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/nib/exec.rb

Instance Method Summary collapse

Methods included from Command

#execute, included, #initialize

Instance Method Details

#actionObject



14
15
16
# File 'lib/nib/exec.rb', line 14

def action
  command.to_s.empty? ? '' : "-c '#{command}'"
end

#entrypointObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nib/exec.rb', line 18

def entrypoint
  "
    if hash bash 2>/dev/null ; then
      bash #{action}
    elif hash ash 2>/dev/null ; then
      ash #{action}
    else
      sh #{action}
    fi
  "
end

#scriptObject



4
5
6
7
8
9
10
11
12
# File 'lib/nib/exec.rb', line 4

def script
  @script ||= <<~SCRIPT
    docker-compose \
      exec \
      #{options} \
      #{service} \
      /bin/sh -c "#{entrypoint}"
  SCRIPT
end