Fix upload & checksum fail with Cygwin (for Windows)
This commit is contained in:
parent
9fc9c42f1a
commit
2c034253b4
91
src/ks-upa
91
src/ks-upa
|
@ -134,29 +134,43 @@ function showPathFile() {
|
|||
function sendFile() {
|
||||
correct=0
|
||||
countSend=0
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
#sshpass -p ${1} scp ${2} ${3}@${4}:${5} &> /dev/null
|
||||
comandOne="sshpass -p ${1} rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
# Run command for upload on Windows (Cygwin)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
echo "retry_disabled" > /dev/null
|
||||
correct=1
|
||||
else
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failure to send ${2}"
|
||||
echo "Retrying..."
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
sleep 5
|
||||
countSend=$(expr ${countSend} + 1)
|
||||
if [ ${countSend} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
comandOne="/usr/bin/sshpass -p ${1} /usr/bin/rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "/usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
comandOne="sshpass -p ${1} rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failure to send ${2}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countSend=$(expr ${countSend} + 1)
|
||||
if [ ${countSend} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
else
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -168,30 +182,30 @@ function checkChecksum() {
|
|||
countChecksum=0
|
||||
echo -n "Checking checksum... " && sleep 4
|
||||
echo ""
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
checksumLocal=$(md5sum ${2})
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: checksum_disabled"
|
||||
else
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countChecksum=$(expr ${countChecksum} + 1)
|
||||
if [ ${countChecksum} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: ${checksumServer}"
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countChecksum=$(expr ${countChecksum} + 1)
|
||||
if [ ${countChecksum} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: ${checksumServer}"
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Generate random codes
|
||||
|
@ -571,6 +585,7 @@ if [ "${1}" == "-r" ] ; then
|
|||
echo "+ Removing LOCAL PATH file configuration..."
|
||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||
echo "* Removed all configuration"
|
||||
rm -f ${dirConfig}/ks-upload-tool
|
||||
echo ""
|
||||
exit
|
||||
else
|
||||
|
|
91
src/ks-upf
91
src/ks-upf
|
@ -152,29 +152,43 @@ function showPathFile() {
|
|||
function sendFile() {
|
||||
correct=0
|
||||
countSend=0
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
#sshpass -p ${1} scp ${2} ${3}@${4}:${5} &> /dev/null
|
||||
comandOne="sshpass -p ${1} rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
# Run command for upload on Windows (Cygwin)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
echo "retry_disabled" > /dev/null
|
||||
correct=1
|
||||
else
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failure to send ${2}"
|
||||
echo "Retrying..."
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
sleep 5
|
||||
countSend=$(expr ${countSend} + 1)
|
||||
if [ ${countSend} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
comandOne="/usr/bin/sshpass -p ${1} /usr/bin/rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "/usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
comandOne="sshpass -p ${1} rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failure to send ${2}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countSend=$(expr ${countSend} + 1)
|
||||
if [ ${countSend} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
else
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -186,30 +200,30 @@ function checkChecksum() {
|
|||
countChecksum=0
|
||||
echo -n "Checking checksum... " && sleep 4
|
||||
echo ""
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
checksumLocal=$(md5sum ${2})
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: checksum_disabled"
|
||||
else
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countChecksum=$(expr ${countChecksum} + 1)
|
||||
if [ ${countChecksum} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: ${checksumServer}"
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countChecksum=$(expr ${countChecksum} + 1)
|
||||
if [ ${countChecksum} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: ${checksumServer}"
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Generate random codes
|
||||
|
@ -589,6 +603,7 @@ if [ "${1}" == "-r" ] ; then
|
|||
echo "+ Removing LOCAL PATH file configuration..."
|
||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||
echo "* Removed all configuration"
|
||||
rm -f ${dirConfig}/ks-upload-tool
|
||||
echo ""
|
||||
exit
|
||||
else
|
||||
|
|
35
src/ks-upr
35
src/ks-upr
|
@ -147,11 +147,35 @@ function showPathFile() {
|
|||
# Function to send file to server.
|
||||
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
|
||||
function sendFile() {
|
||||
#sshpass -p ${1} scp ${2} ${3}@${4}:${5} &> /dev/null
|
||||
comandOne="sshpass -p ${1} rsync -azlr -e"
|
||||
comandTwo="--progress ${2}/ ${3}@${4}:${5}/"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
echo ""
|
||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||
comandOne="/usr/bin/sshpass -p ${1} /usr/bin/rsync -azL -e"
|
||||
comandTwo="--progress ${2}/ ${3}@${4}:${5}/"
|
||||
${comandOne} "/usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
else
|
||||
echo ""
|
||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
echo ""
|
||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||
comandOne="sshpass -p ${1} rsync -azlr -e"
|
||||
comandTwo="--progress ${2}/ ${3}@${4}:${5}/"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
else
|
||||
echo ""
|
||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||
sshpass -p ${1} scp -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Generate random codes
|
||||
|
@ -531,6 +555,7 @@ if [ "${1}" == "-r" ] ; then
|
|||
echo "+ Removing LOCAL PATH file configuration..."
|
||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||
echo "* Removed all configuration"
|
||||
rm -f ${dirConfig}/ks-upload-tool
|
||||
echo ""
|
||||
exit
|
||||
else
|
||||
|
|
92
src/ks-upv
92
src/ks-upv
|
@ -129,35 +129,48 @@ function showPathFile() {
|
|||
echo ${pathFile}
|
||||
}
|
||||
|
||||
|
||||
# Function to send file to server.
|
||||
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
|
||||
function sendFile() {
|
||||
correct=0
|
||||
countSend=0
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
#sshpass -p ${1} scp ${2} ${3}@${4}:${5} &> /dev/null
|
||||
comandOne="sshpass -p ${1} rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
# Run command for upload on Windows (Cygwin)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
echo "retry_disabled" > /dev/null
|
||||
correct=1
|
||||
else
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failure to send ${2}"
|
||||
echo "Retrying..."
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
sleep 5
|
||||
countSend=$(expr ${countSend} + 1)
|
||||
if [ ${countSend} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
comandOne="/usr/bin/sshpass -p ${1} /usr/bin/rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "/usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ "${toolSelected}" == "rsync" ] ; then
|
||||
comandOne="sshpass -p ${1} rsync -azL -e"
|
||||
comandTwo="--progress ${2} ${3}@${4}:${5}"
|
||||
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failure to send ${2}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countSend=$(expr ${countSend} + 1)
|
||||
if [ ${countSend} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
else
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -169,30 +182,30 @@ function checkChecksum() {
|
|||
countChecksum=0
|
||||
echo -n "Checking checksum... " && sleep 4
|
||||
echo ""
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
checksumLocal=$(md5sum ${2})
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: checksum_disabled"
|
||||
else
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countChecksum=$(expr ${countChecksum} + 1)
|
||||
if [ ${countChecksum} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: ${checksumServer}"
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
echo "Retrying..."
|
||||
sleep 5
|
||||
countChecksum=$(expr ${countChecksum} + 1)
|
||||
if [ ${countChecksum} -eq 3 ] ; then
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "Local checksum: ${checksumLocal}"
|
||||
echo "Server checksum: ${checksumServer}"
|
||||
correct=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Generate random codes
|
||||
|
@ -572,6 +585,7 @@ if [ "${1}" == "-r" ] ; then
|
|||
echo "+ Removing LOCAL PATH file configuration..."
|
||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||
echo "* Removed all configuration"
|
||||
rm -f ${dirConfig}/ks-upload-tool
|
||||
echo ""
|
||||
exit
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user