blob: 393982acd7bf4c6e3274598488b2f491ff3c4ea9 [file] [log] [blame]
tomac77d762014-09-18 19:59:42 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom1a2908c2014-09-23 16:37:39 -07003# ONOS remote command-line client.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tomac77d762014-09-18 19:59:42 -07005
Ayaka Koshibef17f34a2015-09-24 19:31:48 -07006function _usage () {
7cat << _EOF_
Thomas Vachuskad76b6792018-02-01 11:46:12 -08008usage: $(basename $0) [node [command]]
Ayaka Koshibef17f34a2015-09-24 19:31:48 -07009
Thomas Vachuskad76b6792018-02-01 11:46:12 -080010ONOS remote command-line client.
Ayaka Koshibef17f34a2015-09-24 19:31:48 -070011
Thomas Vachuskad76b6792018-02-01 11:46:12 -080012Parameters:
13 - node ip or hostname of cluster node to attach to
14 - command command to be executed
Ayaka Koshibef17f34a2015-09-24 19:31:48 -070015
Thomas Vachuskad76b6792018-02-01 11:46:12 -080016If node is unspecified, the value of \$OCI environment variable is used.
Ayaka Koshibef17f34a2015-09-24 19:31:48 -070017_EOF_
18}
Ayaka Koshibef17f34a2015-09-24 19:31:48 -070019
Thomas Vachuskad76b6792018-02-01 11:46:12 -080020[ "$1" = "-h" -o "$1" = '-?' ] && _usage && exit 0
21[ "$1" = "-w" ] && echo "-w option is deprecated" && shift # Deprecated
22[ "$1" = "-f" ] && echo "-f option is deprecated" && shift # Deprecated
Pavlin Radoslavov4b154072014-10-15 10:49:23 -070023
Thomas Vachuskad76b6792018-02-01 11:46:12 -080024# If ONOS_HOME is set, respect its value.
25# If ONOS_HOME is not set (e.g. in the init or service environment),
26# set it based on this script's path.
27ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
28[ $(dirname $0)/find-node.sh ] && . $(dirname $0)/find-node.sh
29[ -x ${ONOS_HOME}/bin/_find-node ] && . ${ONOS_HOME}/bin/_find-node
toma6bc21b2014-09-30 09:39:02 -070030
Jonathan Hart518e5e72014-10-31 15:28:35 -070031[ -n "$1" ] && OCI=$(find_node $1) && shift
Thomas Vachuska12bf4452015-06-26 09:15:38 -070032
You Wangdafd5b72017-09-08 14:23:15 -070033ssh -q -p 8101 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $OCI "$@"