Sha256: 53c89a42d93cfd0d5a8a8b5f5beff95eff159ffc4c70c12cbfcd3ba01645eeff

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

# takeltau info status ssh
module InfoStatusSSH
  # Backend method for info status ssh.
  # @return [Boolean] is ssh available?
  # rubocop:disable Metrics/MethodLength
  def info_status_ssh
    log.debug 'Check ssh status'

    ssh_auth_sock = ENV['SSH_AUTH_SOCK']
    gpg_ssh_socket = _info_status_ssh_socket_path.chomp

    unless ssh_auth_sock == gpg_ssh_socket
      log.error 'ssh does not use gpg ssh socket'
      return false
    end

    unless _file_exists? gpg_ssh_socket
      log.error 'gpg ssh socket is not available'
      return false
    end

    unless _info_status_ssh_keys
      log.error 'ssh keys are not available'
      return false
    end

    log.debug 'ssh is available'
    true
  end
  # rubocop:enable Metrics/MethodLength

  private

  # Get ssh socket path
  def _info_status_ssh_socket_path
    run config.active['cmd_info_status_ssh_socket']
  end

  # Check ssh keys
  def _info_status_ssh_keys
    status_keys = try config.active['cmd_info_status_ssh_keys']
    status_keys.exitstatus.zero?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
takeltau-0.34.15 lib/takeltau/info/status/ssh.rb
takeltau-0.34.14 lib/takeltau/info/status/ssh.rb
takeltau-0.34.13 lib/takeltau/info/status/ssh.rb
takeltau-0.34.12 lib/takeltau/info/status/ssh.rb
takeltau-0.34.11 lib/takeltau/info/status/ssh.rb
takeltau-0.34.9 lib/takeltau/info/status/ssh.rb