Class: Central::Cli::Vpn::ConfigCommand

Inherits:
Clamp::Command
  • Object
show all
Includes:
Common, StackOptions
Defined in:
lib/central/cli/vpn/config_command.rb

Instance Method Summary collapse

Methods included from StackOptions

included

Methods included from Common

#access_token=, #add_master, #api_url, #api_url=, #clear_current_stack, #client, #current_master, #current_master=, #current_master_index, #current_stack, #current_stack=, #ensure_custom_ssl_ca, #require_api_url, #require_current_stack, #require_token, #reset_client, #save_settings, #settings, #settings_filename

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/central/cli/vpn/config_command.rb', line 6

def execute
  require 'rbconfig'
  require_api_url
  payload = { cmd: ['/usr/local/bin/ovpn_getclient', 'CENTRAL_VPN_CLIENT'] }
  stdout, stderr = client(require_token).post("containers/#{current_stack}/vpn/vpn-1/exec", payload)
  if linux?
    stdout << "\n"
    stdout << "up /etc/openvpn/update-resolv-conf\n"
    stdout << "down /etc/openvpn/update-resolv-conf\n"
  end
  puts stdout
end

#linux?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/central/cli/vpn/config_command.rb', line 20

def linux?
  host_os = RbConfig::CONFIG['host_os']
  host_os.include?('linux')
end