module SSHKit::Custom::DSL::ExecStatements

Constants

EXEC_STATEMENTS

Public Class Methods

create_delegator(method) click to toggle source

@api private @!macro [attach] dsl.create_delegator

@!method $1(*args, &block)
@api public
@ dsl
Delegates $1 to the runner
# File lib/sshkit/custom/dsl/exec_statements.rb, line 13
def self.create_delegator(method)
  define_method method do |*args, &block|
    _config_store.runner.send_cmd method, *args, &block
  end
end

Public Instance Methods

_guard_dir!(dir_to_check) click to toggle source

@api private

# File lib/sshkit/custom/dsl/exec_statements.rb, line 48
        def _guard_dir!(dir_to_check)
          execute <<-EOTEST, verbosity: Logger::DEBUG
           if test ! -d #{dir_to_check}
              then echo "Directory does not exist '#{dir_to_check}'" 1>&2
              false
           fi
          EOTEST
        end
_guard_sudo_group!(user, group) click to toggle source

@api private

# File lib/sshkit/custom/dsl/exec_statements.rb, line 38
        def _guard_sudo_group!(user, group)
          execute <<-EOTEST, verbosity: Logger::DEBUG if group
            if ! sudo -u #{user} -g #{group} whoami > /dev/null
            then echo "You cannot switch to group '#{group}' using sudo, please check the sudoers file" 1>&2
               false
            fi
          EOTEST
        end
_guard_sudo_user!(user) click to toggle source

@api private

# File lib/sshkit/custom/dsl/exec_statements.rb, line 28
        def _guard_sudo_user!(user)
          execute <<-EOTEST, verbosity: Logger::DEBUG
            if ! sudo -u #{user} whoami > /dev/null
            then echo "You cannot switch to user '#{user}' using sudo, please check the sudoers file" 1>&2
               false
            fi
          EOTEST
        end