Class: Vtk::Commands::Socks::Setup

Inherits:
Vtk::Command show all
Defined in:
lib/vtk/commands/socks/setup.rb

Overview

Sets up socks access to the VA network

Constant Summary collapse

PROXY_URL =
'https://raw.githubusercontent.com/department-of-veterans-affairs/va.gov-team/master/' \
'scripts/socks/proxy.pac'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Vtk::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #screen, #which

Constructor Details

#initialize(options) ⇒ Setup

Returns a new instance of Setup.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vtk/commands/socks/setup.rb', line 18

def initialize(options)
  @options = options
  @prompt = TTY::Prompt.new interrupt: :exit
  @port = options['port'] || '2001'
  @boot_script_path = options['boot_script_path'] || "#{ENV['HOME']}/Library"
  @ssh_key_path = options['ssh_key_path'] || "#{ENV['HOME']}/.ssh/id_rsa_vagov"
  @ssh_config_path = options['ssh_config_path'] || "#{ENV['HOME']}/.ssh/config"
  @skip_test = options['skip_test'] || false

  super()
end

Instance Attribute Details

#boot_script_pathObject (readonly)

Returns the value of attribute boot_script_path.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def boot_script_path
  @boot_script_path
end

#inputObject (readonly)

Returns the value of attribute input.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def output
  @output
end

#portObject (readonly)

Returns the value of attribute port.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def port
  @port
end

#promptObject (readonly)

Returns the value of attribute prompt.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def prompt
  @prompt
end

#skip_testObject (readonly)

Returns the value of attribute skip_test.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def skip_test
  @skip_test
end

#ssh_config_pathObject (readonly)

Returns the value of attribute ssh_config_path.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def ssh_config_path
  @ssh_config_path
end

#ssh_key_pathObject (readonly)

Returns the value of attribute ssh_key_path.



16
17
18
# File 'lib/vtk/commands/socks/setup.rb', line 16

def ssh_key_path
  @ssh_key_path
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vtk/commands/socks/setup.rb', line 30

def execute(input: $stdin, output: $stdout)
  define_stdin_out_vars input: input, output: output

  setup_ssh_config
  check_ssh_key
  ssh_agent_add

  unless @ssh_key_created
    test_ssh_connection unless skip_test
    configure_system_boot
    configure_system_proxy
  end

  log "SOCKS setup complete. #{'Re-run `vtk socks setup` after your key is approved.' if @ssh_key_created}"
end