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)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
cygwin="yes"
source "/usr/bin/cygwin-alias.sh"
else
cygwin="no"
fi
# Function to remove spaces and symbols
@ -54,7 +57,7 @@ function convertText() {
# Syntax: listArchives <directory>
function listArchives() {
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
cd "${1}"
mkdir -p ${ksToolsTempFolder}
@ -138,6 +141,10 @@ function sendFile() {
${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=$?
if [ "${cygwin}" == "yes" ] ; then
echo "retry_disabled" > /dev/null
correct=1
else
if [ ${OUTPUT} -ne 0 ] ; then
echo "Failure to send ${2}"
echo "Retrying..."
@ -150,6 +157,7 @@ function sendFile() {
else
correct=1
fi
fi
done
}
@ -160,6 +168,11 @@ 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
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$?
@ -173,11 +186,12 @@ function checkChecksum() {
fi
else
checksumLocal=$(md5sum ${2})
echo "Local checksum: $checksumLocal"
echo "Server checksum: $checksumServer"
echo "Local checksum: ${checksumLocal}"
echo "Server checksum: ${checksumServer}"
correct=1
fi
done
fi
}
# Function to show config

View File

@ -20,7 +20,10 @@ ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
cygwin="yes"
source "/usr/bin/cygwin-alias.sh"
else
cygwin="no"
fi
# Function to remove spaces and symbols
@ -57,7 +60,7 @@ function listArchives() {
formatFiles=""
videoFiles="mp4 avi mpg mpeg mov wmv mkv ogv webm rm flv vob ts"
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}"
compressFiles="zip rar 7z bz2 gz xz tar bzip2 gzip"
formatFiles="${formatFiles} ${compressFiles}"
@ -156,6 +159,10 @@ function sendFile() {
${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=$?
if [ "${cygwin}" == "yes" ] ; then
echo "retry_disabled" > /dev/null
correct=1
else
if [ ${OUTPUT} -ne 0 ] ; then
echo "Failure to send ${2}"
echo "Retrying..."
@ -168,6 +175,7 @@ function sendFile() {
else
correct=1
fi
fi
done
}
@ -178,6 +186,11 @@ 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
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$?
@ -191,11 +204,12 @@ function checkChecksum() {
fi
else
checksumLocal=$(md5sum ${2})
echo "Local checksum: $checksumLocal"
echo "Server checksum: $checksumServer"
echo "Local checksum: ${checksumLocal}"
echo "Server checksum: ${checksumServer}"
correct=1
fi
done
fi
}
# Function to show config

View File

@ -20,7 +20,10 @@ ksToolsTempFolder="/tmp/ks-tools"
# Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases
cygwin="yes"
source "/usr/bin/cygwin-alias.sh"
else
cygwin="no"
fi
# 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
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$?
if [ "${cygwin}" == "yes" ] ; then
echo "retry_disabled" > /dev/null
correct=1
else
if [ ${OUTPUT} -ne 0 ] ; then
echo "Failure to send ${2}"
echo "Retrying..."
@ -150,6 +157,7 @@ function sendFile() {
else
correct=1
fi
fi
done
}
@ -160,6 +168,11 @@ 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
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$?
@ -173,11 +186,12 @@ function checkChecksum() {
fi
else
checksumLocal=$(md5sum ${2})
echo "Local checksum: $checksumLocal"
echo "Server checksum: $checksumServer"
echo "Local checksum: ${checksumLocal}"
echo "Server checksum: ${checksumServer}"
correct=1
fi
done
fi
}
# Function to show config