Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-5452 - "Wrong number of arguments" launching MR operation #2374

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions opencga-app/app/misc/scripts/hadoop-ssh.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
#!/usr/bin/env sh


if [ -z ${HADOOP_SSH_USER} ] ; then
if [ -z "${HADOOP_SSH_USER}" ] ; then
echo "Undefined HADOOP_SSH_USER" 1>&2
exit 1
fi

if [ -z ${HADOOP_SSH_HOST} ] ; then
if [ -z "${HADOOP_SSH_HOST}" ] ; then
echo "Undefined HADOOP_SSH_HOST" 1>&2
exit 1
fi

SSHPASS_CMD=
if [ -z ${SSHPASS} ] ; then
if [ -z "${SSHPASS}" ] ; then
# If empty, assume ssh-key exists in the system
SSHPASS_CMD=""
else
# If non zero, use sshpass command
SSHPASS_CMD="sshpass -e"
SSHPASS_CMD="sshpass -e "
fi

SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=60"
if [ ! -z ${HADOOP_SSH_KEY} ] && [ -f ${HADOOP_SSH_KEY} ] ; then
if [ -n "${HADOOP_SSH_KEY}" ] && [ -f "${HADOOP_SSH_KEY}" ] ; then
SSH_OPTS="${SSH_OPTS} -i ${HADOOP_SSH_KEY}"
fi

echo "Connect to Hadoop edge node ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" 1>&2

echo "${SSHPASS_CMD} ssh ${SSH_OPTS} ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" 1>&2
echo "${SSHPASS_CMD}ssh ${SSH_OPTS} ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" 1>&2

# Escape args with single quotes
CMD=
for arg in $@ ; do
for arg in "$@" ; do
# Escape single quote, if any :
# arg=`echo $arg | sed "s/'/'\"'\"'/g"` # aaa'aaa --> 'aaa'"'"'aaa'
arg=`echo $arg | sed "s/'/'\\\\\\''/g"` # aaa'aaa --> 'aaa'\''aaa'
arg=$(echo "$arg" | sed "s/'/'\\\\\\''/g") # aaa'aaa --> 'aaa'\''aaa'
CMD="${CMD}'${arg}' "
done
echo ${CMD}

${SSHPASS_CMD} ssh ${SSH_OPTS} ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST} /bin/bash << EOF
${SSHPASS_CMD} ssh ${SSH_OPTS} "${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" /bin/bash << EOF

export HADOOP_CLASSPATH=${HADOOP_CLASSPATH}
export HADOOP_USER_CLASSPATH_FIRST=${HADOOP_USER_CLASSPATH_FIRST}
Expand Down
Loading