+DEBUG=0
+SSH_PORT=22
+
+function usage {
+ echo >&2
+ echo >&2 "usage: $0 [options] <identifier>"
+ echo >&2
+ echo >&2 " <identifier> Arvados cluster name"
+ echo >&2
+ echo >&2 "$0 options:"
+ echo >&2 " -p, --port <ssh port> SSH port to use (default 22)"
+ echo >&2 " -d, --debug Enable debug output"
+ echo >&2 " -h, --help Display this help and exit"
+ echo >&2
+ echo >&2 "Note: this script requires an arvados token created with these permissions:"
+ echo >&2 ' arv api_client_authorization create_system_auth \'
+ echo >&2 ' --scopes "[\"GET /arvados/v1/virtual_machines\",'
+ echo >&2 ' \"GET /arvados/v1/keep_services\",'
+ echo >&2 ' \"GET /arvados/v1/keep_services/\",'
+ echo >&2 ' \"GET /arvados/v1/groups\",'
+ echo >&2 ' \"GET /arvados/v1/groups/\",'
+ echo >&2 ' \"GET /arvados/v1/links\",'
+ echo >&2 ' \"GET /arvados/v1/collections\",'
+ echo >&2 ' \"POST /arvados/v1/collections\",'
+ echo >&2 ' \"POST /arvados/v1/links\"]"'
+ echo >&2
+}
+
+# NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
+TEMP=`getopt -o hdp: \
+ --long help,debug,port: \
+ -n "$0" -- "$@"`
+
+if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$TEMP"
+
+while [ $# -ge 1 ]
+do
+ case $1 in
+ -p | --port)
+ SSH_PORT="$2"; shift 2
+ ;;
+ -d | --debug)
+ DEBUG=1
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+done
+