summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2015-04-30 12:17:50 -0400
committerThomas Wiest <twiest@users.noreply.github.com>2015-04-30 12:17:50 -0400
commit1f9585b57aeaab70108e98ed4adcb80574acc949 (patch)
treee83f95fdd71cc015e5d220cd1af3c21fd63521e7 /bin
parent935da07e94b27ad1eb6c9085d3d182c9e0bc9b0d (diff)
parenta9abcc3646053ca8f2bf2dd3ee39b06ac12d35c6 (diff)
downloadopenshift-1f9585b57aeaab70108e98ed4adcb80574acc949.tar.gz
openshift-1f9585b57aeaab70108e98ed4adcb80574acc949.tar.bz2
openshift-1f9585b57aeaab70108e98ed4adcb80574acc949.tar.xz
openshift-1f9585b57aeaab70108e98ed4adcb80574acc949.zip
Merge pull request #196 from twiest/pr
added opscp
Diffstat (limited to 'bin')
-rw-r--r--bin/openshift-ansible-bin.spec2
-rwxr-xr-xbin/opscp117
2 files changed, 118 insertions, 1 deletions
diff --git a/bin/openshift-ansible-bin.spec b/bin/openshift-ansible-bin.spec
index c7db6f684..f28d1d35e 100644
--- a/bin/openshift-ansible-bin.spec
+++ b/bin/openshift-ansible-bin.spec
@@ -23,7 +23,7 @@ mkdir -p %{buildroot}%{python_sitelib}/openshift_ansible
mkdir -p %{buildroot}/etc/bash_completion.d
mkdir -p %{buildroot}/etc/openshift_ansible
-cp -p ossh oscp opssh ohi %{buildroot}%{_bindir}
+cp -p ossh oscp opssh opscp ohi %{buildroot}%{_bindir}
cp -p openshift_ansible/* %{buildroot}%{python_sitelib}/openshift_ansible
cp -p ossh_bash_completion %{buildroot}/etc/bash_completion.d
diff --git a/bin/opscp b/bin/opscp
new file mode 100755
index 000000000..445c838f5
--- /dev/null
+++ b/bin/opscp
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+
+function usage() {
+ cat << EOF
+Usage: opscp [OPTIONS] local remote
+
+Options:
+ --version show program's version number and exit
+ --help show this help message and exit
+ -l USER, --user=USER username (OPTIONAL)
+ -p PAR, --par=PAR max number of parallel threads (OPTIONAL)
+ --errdir=ERRDIR output directory for stderr files (OPTIONAL)
+ --outdir=OUTDIR output directory for stdout files (OPTIONAL)
+ -e ENV, --env ENV Which environment to use
+ -t HOST_TYPE, --host-type HOST_TYPE
+ Which host type to use
+ -O OPTION, --option=OPTION
+ SSH option (OPTIONAL)
+ -v, --verbose turn on warning and diagnostic messages (OPTIONAL)
+ -A, --askpass Ask for a password (OPTIONAL)
+ -x ARGS, --extra-args=ARGS
+ Extra command-line arguments, with processing for
+ spaces, quotes, and backslashes
+ -X ARG, --extra-arg=ARG
+ Extra command-line argument
+ -r, --recursive recusively copy directories (OPTIONAL)
+
+Example: opscp -t ex-srv -e stg -l irb2 foo.txt /home/irb2/foo.txt
+
+EOF
+}
+
+if [ $# -eq 0 ] || [ "$1" == "--help" ]
+then
+ usage
+ exit 1
+fi
+
+PSCP_PAR=200
+USER=root
+PSCP_OPTIONS=""
+ENV=""
+HOST_TYPE=""
+while [ $# -gt 0 ] ; do
+ if [ "$1" == "-t" -o "$1" == "--host-type" ] ; then
+ shift # get past the option
+ HOST_TYPE=$1
+ shift # get past the value of the option
+
+ elif [ "$1" == "-e" ] ; then
+ shift # get past the option
+ ENV=$1
+ shift # get past the value of the option
+
+ elif [ "$1" == "-p" -o "$1" == "--par" ] ; then
+ shift # get past the option
+ PSCP_PAR=$1
+ shift # get past the value of the option
+
+ elif [ "$1" == "-l" -o "$1" == "--user" ] ; then
+ shift # get past the option
+ USER=$1
+ shift # get past the value of the option
+
+ elif [ "$1" == "-h" -o "$1" == "--hosts" -o "$1" == "-H" -o "$1" == "--host" ] ||
+ [ "$1" == "-o" ] ; then
+ echo "ERROR: unknown option $1"
+ exit 20
+
+ else
+ if [ "${1:0:1}" == "-" ] ; then
+ # It's an option, don't quote
+ PSCP_OPTIONS="$PSCP_OPTIONS $1"
+ else
+ PSCP_OPTIONS="$PSCP_OPTIONS '$1'"
+ fi
+ shift # Get past this option
+ fi
+done
+
+if [ -z "$ENV" ]
+then
+ echo
+ echo "-e is a required paramemeter"
+ echo
+ exit 10
+fi
+
+if [ -z "$HOST_TYPE" ]
+then
+ echo
+ echo "-t is a required paramemeter"
+ echo
+ exit 15
+fi
+
+PSCP_OPTIONS="-t 0 -p $PSCP_PAR -l $USER -h <(ohi -t $HOST_TYPE -e $ENV 2>/dev/null) $PSCP_OPTIONS"
+
+
+# See if the ohi options are valid
+ohi -t $HOST_TYPE -e $ENV &> /dev/null
+ECODE=$?
+if [ $ECODE -ne 0 ] ; then
+ echo
+ echo "ERROR: ohi failed with exit code $ECODE"
+ echo
+ echo "This is usually caused by a bad value passed for host-type or environment."
+ echo
+ exit 25
+fi
+
+echo
+echo "Running: pscp.pssh $PSCP_OPTIONS"
+echo
+
+eval pscp.pssh $PSCP_OPTIONS