#!/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 "$@"; }

remote_backup() {
	local host=$1
	local target=$2
	warn "$FUNCNAME: FIXME: $target backup unimplemented ($host)"
}

remote_restore() {
	local host=$1
	local target=$2
	warn "$FUNCNAME: FIXME: $target restore unimplemented ($host)"
}

View the Developer Guide Index

View the Reference Manual Index


Generated on Wed Jun 28 07:40:10 PDT 2017 by mcsh d14 v0.20.0.