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,6 +141,10 @@ 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 [ "${cygwin}" == "yes" ] ; then
echo "retry_disabled" > /dev/null
correct=1
else
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "Failure to send ${2}" echo "Failure to send ${2}"
echo "Retrying..." echo "Retrying..."
@ -150,6 +157,7 @@ function sendFile() {
else else
correct=1 correct=1
fi fi
fi
done done
} }
@ -160,6 +168,11 @@ function checkChecksum() {
countChecksum=0 countChecksum=0
echo -n "Checking checksum... " && sleep 4 echo -n "Checking checksum... " && sleep 4
echo "" 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
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
@ -173,11 +186,12 @@ function checkChecksum() {
fi fi
else else
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
echo "Local checksum: $checksumLocal" echo "Local checksum: ${checksumLocal}"
echo "Server checksum: $checksumServer" echo "Server checksum: ${checksumServer}"
correct=1 correct=1
fi fi
done done
fi
} }
# 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,6 +159,10 @@ 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 [ "${cygwin}" == "yes" ] ; then
echo "retry_disabled" > /dev/null
correct=1
else
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "Failure to send ${2}" echo "Failure to send ${2}"
echo "Retrying..." echo "Retrying..."
@ -168,6 +175,7 @@ function sendFile() {
else else
correct=1 correct=1
fi fi
fi
done done
} }
@ -178,6 +186,11 @@ function checkChecksum() {
countChecksum=0 countChecksum=0
echo -n "Checking checksum... " && sleep 4 echo -n "Checking checksum... " && sleep 4
echo "" 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
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
@ -191,11 +204,12 @@ function checkChecksum() {
fi fi
else else
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
echo "Local checksum: $checksumLocal" echo "Local checksum: ${checksumLocal}"
echo "Server checksum: $checksumServer" echo "Server checksum: ${checksumServer}"
correct=1 correct=1
fi fi
done done
fi
} }
# 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,6 +141,10 @@ 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 [ "${cygwin}" == "yes" ] ; then
echo "retry_disabled" > /dev/null
correct=1
else
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "Failure to send ${2}" echo "Failure to send ${2}"
echo "Retrying..." echo "Retrying..."
@ -150,6 +157,7 @@ function sendFile() {
else else
correct=1 correct=1
fi fi
fi
done done
} }
@ -160,6 +168,11 @@ function checkChecksum() {
countChecksum=0 countChecksum=0
echo -n "Checking checksum... " && sleep 4 echo -n "Checking checksum... " && sleep 4
echo "" 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
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
@ -173,11 +186,12 @@ function checkChecksum() {
fi fi
else else
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
echo "Local checksum: $checksumLocal" echo "Local checksum: ${checksumLocal}"
echo "Server checksum: $checksumServer" echo "Server checksum: ${checksumServer}"
correct=1 correct=1
fi fi
done done
fi
} }
# Function to show config # Function to show config