123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- function usage() {
- cat << EOF
- Usage: opscp [OPTIONS] local remote
- Options:
-
-
- -l USER,
- -p PAR,
-
-
- -e ENV,
- -t HOST_TYPE,
- which host type to use
-
-
- -O OPTION,
- SSH option (OPTIONAL)
- -v,
- -A,
- -x ARGS,
- Extra command-line arguments, with processing for
- spaces, quotes, and backslashes
- -X ARG,
- Extra command-line argument
- -r,
- Example: opscp -t ex-srv -e stg -l irb2 foo.txt /home/irb2/foo.txt
- EOF
- }
- if [ $
- then
- usage
- exit 1
- fi
- if ! which ohi &>/dev/null ; then
- echo "ERROR: can't find ohi (OpenShift Host Inventory) on your system, please either install the openshift-ansible-bin package, or add openshift-ansible/bin to your path."
- exit 10
- fi
- PAR=200
- USER=root
- TIMEOUT=0
- ENV=""
- HOST_TYPE=""
- while [ $
- case $1 in
- -t|
- shift
- HOST_TYPE=$1
- shift
- ;;
- -e)
- shift
- ENV=$1
- shift
- ;;
-
- shift
- TIMEOUT=$1
- shift
- ;;
- -p|
- shift
- PAR=$1
- shift
- ;;
- -l|
- shift
- USER=$1
- shift
- ;;
-
- ohi
- exit 0
- ;;
- -h|
- echo "ERROR: unknown option $1"
- exit 20
- ;;
- *)
- args+=("$1")
- shift
- ;;
- esac
- done
- if [ -n "$ENV" -a -n "$HOST_TYPE" ] ; then
- HOSTS="$(ohi -t "$HOST_TYPE" -e "$ENV" 2>/dev/null)"
- OHI_ECODE=$?
- elif [ -n "$ENV" ] ; then
- HOSTS="$(ohi -e "$ENV" 2>/dev/null)"
- OHI_ECODE=$?
- elif [ -n "$HOST_TYPE" ] ; then
- HOSTS="$(ohi -t "$HOST_TYPE" 2>/dev/null)"
- OHI_ECODE=$?
- else
- echo
- echo "Error: either -e or -t must be specified"
- echo
- exit 10
- fi
- if [ $OHI_ECODE -ne 0 ] ; then
- echo
- echo "ERROR: ohi failed with exit code $OHI_ECODE"
- echo
- echo "This is usually caused by a bad value passed for host-type or environment."
- echo
- exit 25
- fi
- exec pscp.pssh -t $TIMEOUT -p $PAR -l $USER -h <(echo "$HOSTS") "${args[@]}"
|