#!/bin/bash
#  remote - remote host command support

set -e

lib_load 'net/tool/ssh'


######
# Stub functions

# remote_host - Map a hostname to a name that will allow remote connections
#  $1 - name of host
is_function remote_host || remote_host() { echo "$1"; }

# remote_host_port - Print an alternative port for connecting to a host.
#  $1 - name of host
is_function remote_port || remote_port() { true; }


######
# Public interface

_remote_command() {
	min_args 3 "$@"
	local func=$1
	local host=$2
	shift 2
	local ssh_host ssh_port
	ssh_host=$(remote_host $host)
	ssh_port=$(remote_port $host)
	$func "$@"
}

remote_run() { _remote_command run_ssh "$@"; }
remote_sudo() { _remote_command run_ssh_sudo "$@"; }
remote_deploy_file() { _remote_command ssh_deploy_file "$@"; }

remote_copy_to() { _remote_command ssh_copy_to "$@"; }
remote_copy_from() { _remote_command ssh_copy_from "$@"; }

View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:35:50 PDT 2017 by mcsh d14 v0.23.0.