Fix retry & checksum on cygwin (ks-upv/upa/upr)

This commit is contained in:
q3aql 2021-03-29 18:08:57 +02:00
parent 5e59548854
commit 80f6ed1bf4
3 changed files with 119 additions and 77 deletions

View File

@ -20,7 +20,10 @@ ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
cygwin="yes"
source "/usr/bin/cygwin-alias.sh" source "/usr/bin/cygwin-alias.sh"
else
cygwin="no"
fi fi
# Function to remove spaces and symbols # Function to remove spaces and symbols
@ -54,7 +57,7 @@ function convertText() {
# Syntax: listArchives <directory> # Syntax: listArchives <directory>
function listArchives() { function listArchives() {
fail=1 fail=1
formatFiles="mp3 wma ogg wav flac midi acc oga opus mp2 ra m4a mka" formatFiles="mp3 wma ogg wav flac midi acc oga opus mp2 ra m4a mka ac3"
# Rename files # Rename files
cd "${1}" cd "${1}"
mkdir -p ${ksToolsTempFolder} mkdir -p ${ksToolsTempFolder}
@ -138,17 +141,22 @@ function sendFile() {
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null ${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 sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ "${cygwin}" == "yes" ] ; then
echo "Failure to send ${2}" echo "retry_disabled" > /dev/null
echo "Retrying..." correct=1
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null else
sleep 5 if [ ${OUTPUT} -ne 0 ] ; then
countSend=$(expr ${countSend} + 1) echo "Failure to send ${2}"
if [ ${countSend} -eq 5 ] ; then echo "Retrying..."
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
sleep 5
countSend=$(expr ${countSend} + 1)
if [ ${countSend} -eq 5 ] ; then
correct=1
fi
else
correct=1 correct=1
fi fi
else
correct=1
fi fi
done done
} }
@ -160,24 +168,30 @@ function checkChecksum() {
countChecksum=0 countChecksum=0
echo -n "Checking checksum... " && sleep 4 echo -n "Checking checksum... " && sleep 4
echo "" echo ""
while [ ${correct} -eq 0 ] ; do if [ "${cygwin}" == "yes" ] ; then
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null) checksumLocal=$(md5sum ${2})
OUTPUT=$? echo "Local checksum: ${checksumLocal}"
if [ ${OUTPUT} -ne 0 ] ; then echo "Server checksum: checksum_disabled"
echo "Failed to get checksum for ${5}" else
echo "Retrying..." while [ ${correct} -eq 0 ] ; do
sleep 5 checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
countChecksum=$(expr ${countChecksum} + 1) OUTPUT=$?
if [ ${countChecksum} -eq 5 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "Failed to get checksum for ${5}"
echo "Retrying..."
sleep 5
countChecksum=$(expr ${countChecksum} + 1)
if [ ${countChecksum} -eq 5 ] ; then
correct=1
fi
else
checksumLocal=$(md5sum ${2})
echo "Local checksum: ${checksumLocal}"
echo "Server checksum: ${checksumServer}"
correct=1 correct=1
fi fi
else done
checksumLocal=$(md5sum ${2}) fi
echo "Local checksum: $checksumLocal"
echo "Server checksum: $checksumServer"
correct=1
fi
done
} }
# Function to show config # Function to show config

View File

@ -20,7 +20,10 @@ ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
cygwin="yes"
source "/usr/bin/cygwin-alias.sh" source "/usr/bin/cygwin-alias.sh"
else
cygwin="no"
fi fi
# Function to remove spaces and symbols # Function to remove spaces and symbols
@ -57,7 +60,7 @@ function listArchives() {
formatFiles="" formatFiles=""
videoFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ts" videoFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ts"
formatFiles="${formatFiles} ${videoFiles}" formatFiles="${formatFiles} ${videoFiles}"
audioFiles="mp3 wma ogg wav flac midi acc oga opus mp2 ra m4a mka" audioFiles="mp3 wma ogg wav flac midi acc oga opus mp2 ra m4a mka ac3"
formatFiles="${formatFiles} ${audioFiles}" formatFiles="${formatFiles} ${audioFiles}"
compressFiles="zip rar 7z bz2 gz xz tar bzip2 gzip" compressFiles="zip rar 7z bz2 gz xz tar bzip2 gzip"
formatFiles="${formatFiles} ${compressFiles}" formatFiles="${formatFiles} ${compressFiles}"
@ -156,17 +159,22 @@ function sendFile() {
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null ${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 sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ "${cygwin}" == "yes" ] ; then
echo "Failure to send ${2}" echo "retry_disabled" > /dev/null
echo "Retrying..." correct=1
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null else
sleep 5 if [ ${OUTPUT} -ne 0 ] ; then
countSend=$(expr ${countSend} + 1) echo "Failure to send ${2}"
if [ ${countSend} -eq 5 ] ; then echo "Retrying..."
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
sleep 5
countSend=$(expr ${countSend} + 1)
if [ ${countSend} -eq 5 ] ; then
correct=1
fi
else
correct=1 correct=1
fi fi
else
correct=1
fi fi
done done
} }
@ -178,24 +186,30 @@ function checkChecksum() {
countChecksum=0 countChecksum=0
echo -n "Checking checksum... " && sleep 4 echo -n "Checking checksum... " && sleep 4
echo "" echo ""
while [ ${correct} -eq 0 ] ; do if [ "${cygwin}" == "yes" ] ; then
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null) checksumLocal=$(md5sum ${2})
OUTPUT=$? echo "Local checksum: ${checksumLocal}"
if [ ${OUTPUT} -ne 0 ] ; then echo "Server checksum: checksum_disabled"
echo "Failed to get checksum for ${5}" else
echo "Retrying..." while [ ${correct} -eq 0 ] ; do
sleep 5 checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
countChecksum=$(expr ${countChecksum} + 1) OUTPUT=$?
if [ ${countChecksum} -eq 5 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "Failed to get checksum for ${5}"
echo "Retrying..."
sleep 5
countChecksum=$(expr ${countChecksum} + 1)
if [ ${countChecksum} -eq 5 ] ; then
correct=1
fi
else
checksumLocal=$(md5sum ${2})
echo "Local checksum: ${checksumLocal}"
echo "Server checksum: ${checksumServer}"
correct=1 correct=1
fi fi
else done
checksumLocal=$(md5sum ${2}) fi
echo "Local checksum: $checksumLocal"
echo "Server checksum: $checksumServer"
correct=1
fi
done
} }
# Function to show config # Function to show config

View File

@ -20,7 +20,10 @@ ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
cygwin="yes"
source "/usr/bin/cygwin-alias.sh" source "/usr/bin/cygwin-alias.sh"
else
cygwin="no"
fi fi
# Function to remove spaces and symbols # Function to remove spaces and symbols
@ -138,17 +141,22 @@ function sendFile() {
${comandOne} "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" ${comandTwo} 2> /dev/null ${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 sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ "${cygwin}" == "yes" ] ; then
echo "Failure to send ${2}" echo "retry_disabled" > /dev/null
echo "Retrying..." correct=1
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null else
sleep 5 if [ ${OUTPUT} -ne 0 ] ; then
countSend=$(expr ${countSend} + 1) echo "Failure to send ${2}"
if [ ${countSend} -eq 5 ] ; then echo "Retrying..."
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
sleep 5
countSend=$(expr ${countSend} + 1)
if [ ${countSend} -eq 5 ] ; then
correct=1
fi
else
correct=1 correct=1
fi fi
else
correct=1
fi fi
done done
} }
@ -160,24 +168,30 @@ function checkChecksum() {
countChecksum=0 countChecksum=0
echo -n "Checking checksum... " && sleep 4 echo -n "Checking checksum... " && sleep 4
echo "" echo ""
while [ ${correct} -eq 0 ] ; do if [ "${cygwin}" == "yes" ] ; then
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null) checksumLocal=$(md5sum ${2})
OUTPUT=$? echo "Local checksum: ${checksumLocal}"
if [ ${OUTPUT} -ne 0 ] ; then echo "Server checksum: checksum_disabled"
echo "Failed to get checksum for ${5}" else
echo "Retrying..." while [ ${correct} -eq 0 ] ; do
sleep 5 checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
countChecksum=$(expr ${countChecksum} + 1) OUTPUT=$?
if [ ${countChecksum} -eq 5 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "Failed to get checksum for ${5}"
echo "Retrying..."
sleep 5
countChecksum=$(expr ${countChecksum} + 1)
if [ ${countChecksum} -eq 5 ] ; then
correct=1
fi
else
checksumLocal=$(md5sum ${2})
echo "Local checksum: ${checksumLocal}"
echo "Server checksum: ${checksumServer}"
correct=1 correct=1
fi fi
else done
checksumLocal=$(md5sum ${2}) fi
echo "Local checksum: $checksumLocal"
echo "Server checksum: $checksumServer"
correct=1
fi
done
} }
# Function to show config # Function to show config