Add option for set port connection
This commit is contained in:
parent
36535837e2
commit
8de980a6fc
BIN
src/.ks-mp4.swp
Normal file
BIN
src/.ks-mp4.swp
Normal file
Binary file not shown.
77
src/ks-upa
77
src/ks-upa
|
@ -135,6 +135,7 @@ function showPathFile() {
|
||||||
function check_fingerprint() {
|
function check_fingerprint() {
|
||||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
if [ -z "${fingerprint_host}" ] ; then
|
if [ -z "${fingerprint_host}" ] ; then
|
||||||
# Run command for upload on Windows (Cygwin)
|
# Run command for upload on Windows (Cygwin)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
|
@ -142,13 +143,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -166,13 +167,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -194,39 +195,40 @@ function sendFile() {
|
||||||
correct=0
|
correct=0
|
||||||
countSend=0
|
countSend=0
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
while [ ${correct} -eq 0 ] ; do
|
while [ ${correct} -eq 0 ] ; do
|
||||||
# Run command for upload on Windows (Cygwin)
|
# Run command for upload on Windows (Cygwin)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
# Run command for upload on Unix systems
|
# Run command for upload on Unix systems
|
||||||
else
|
else
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -252,25 +254,26 @@ function checkChecksum() {
|
||||||
echo -n "Checking checksum... " && sleep 4
|
echo -n "Checking checksum... " && sleep 4
|
||||||
echo ""
|
echo ""
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
while [ ${correct} -eq 0 ] ; do
|
while [ ${correct} -eq 0 ] ; do
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -398,6 +401,11 @@ function showConfig() {
|
||||||
echo "- Upload Tool: ${showUpvTool}"
|
echo "- Upload Tool: ${showUpvTool}"
|
||||||
configAvailable=1
|
configAvailable=1
|
||||||
fi
|
fi
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
showUpvPort=$(cat ${dirConfig}/ks-upload-port)
|
||||||
|
echo "- Port Connection: ${showUpvPort}"
|
||||||
|
configAvailable=1
|
||||||
|
fi
|
||||||
if [ ${configAvailable} -eq 0 ] ; then
|
if [ ${configAvailable} -eq 0 ] ; then
|
||||||
echo "* The configuration file does not exist!"
|
echo "* The configuration file does not exist!"
|
||||||
fi
|
fi
|
||||||
|
@ -424,8 +432,11 @@ function editConfig() {
|
||||||
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
||||||
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
||||||
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
||||||
|
editUpvPort=$(cat ${dirConfig}/ks-upload-port 2> /dev/null)
|
||||||
echo ""
|
echo ""
|
||||||
echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
|
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
||||||
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 1 - Edit User (${editUser})"
|
echo " 1 - Edit User (${editUser})"
|
||||||
echo " 2 - Edit Password (${editPassword})"
|
echo " 2 - Edit Password (${editPassword})"
|
||||||
|
@ -433,8 +444,9 @@ function editConfig() {
|
||||||
echo " 4 - Edit Dest. Path (${editDirServer})"
|
echo " 4 - Edit Dest. Path (${editDirServer})"
|
||||||
echo " 5 - Edit Local Path (${editDirLocal})"
|
echo " 5 - Edit Local Path (${editDirLocal})"
|
||||||
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
||||||
|
echo " 7 - Edit Port Connection (${editUpvPort})"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 7 - Exit"
|
echo " 8 - Exit"
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* Choose an option: " ; read EDIT
|
echo -n "* Choose an option: " ; read EDIT
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -482,6 +494,14 @@ function editConfig() {
|
||||||
fi
|
fi
|
||||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||||
elif [ "${EDIT}" == "7" ] ; then
|
elif [ "${EDIT}" == "7" ] ; then
|
||||||
|
echo -n "* [Default: 22] Type port connection: " ; read PORT
|
||||||
|
if [ -z "${PORT}" ] ; then
|
||||||
|
upvPort="22"
|
||||||
|
else
|
||||||
|
upvPort="${PORT}"
|
||||||
|
fi
|
||||||
|
echo ${upvPort} > ${dirConfig}/ks-upload-port
|
||||||
|
elif [ "${EDIT}" == "8" ] ; then
|
||||||
editConfig=1
|
editConfig=1
|
||||||
else
|
else
|
||||||
echo "+ Invalid option!"
|
echo "+ Invalid option!"
|
||||||
|
@ -544,7 +564,15 @@ function createConfig() {
|
||||||
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
||||||
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upa -e' for edit)"
|
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upa -e' for edit)"
|
||||||
else
|
else
|
||||||
|
echo "* Setting 'scp' as the default tool"
|
||||||
echo "scp" > ${dirConfig}/ks-upload-tool
|
echo "scp" > ${dirConfig}/ks-upload-tool
|
||||||
|
fi
|
||||||
|
# Configure port by default
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
echo "+ The PORT configuration already exists (Use: 'ks-upa -e' for edit)"
|
||||||
|
else
|
||||||
|
echo "* Setting port 22 as the default port"
|
||||||
|
echo "22" > ${dirConfig}/ks-upload-port
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
@ -564,6 +592,8 @@ function showHelp() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "- Upload audio file(s) to server with scp or rsync"
|
echo "- Upload audio file(s) to server with scp or rsync"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
|
echo ""
|
||||||
echo "+ Syntax:"
|
echo "+ Syntax:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " $ ks-upa -i - Start upload"
|
echo " $ ks-upa -i - Start upload"
|
||||||
|
@ -681,7 +711,8 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo "+ Removing LOCAL PATH file configuration..."
|
echo "+ Removing LOCAL PATH file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||||
echo "* Removed all configuration"
|
echo "* Removed all configuration"
|
||||||
rm -f ${dirConfig}/ks-upload-tool
|
rm -rf ${dirConfig}/ks-upload-tool
|
||||||
|
rm -rf ${dirConfig}/ks-upload-port
|
||||||
echo ""
|
echo ""
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
|
|
77
src/ks-upf
77
src/ks-upf
|
@ -162,6 +162,7 @@ function showPathFile() {
|
||||||
function check_fingerprint() {
|
function check_fingerprint() {
|
||||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
if [ -z "${fingerprint_host}" ] ; then
|
if [ -z "${fingerprint_host}" ] ; then
|
||||||
# Run command for upload on Windows (Cygwin)
|
# Run command for upload on Windows (Cygwin)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
|
@ -169,13 +170,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -193,13 +194,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -221,39 +222,40 @@ function sendFile() {
|
||||||
correct=0
|
correct=0
|
||||||
countSend=0
|
countSend=0
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
while [ ${correct} -eq 0 ] ; do
|
while [ ${correct} -eq 0 ] ; do
|
||||||
# Run command for upload on Windows (Cygwin)
|
# Run command for upload on Windows (Cygwin)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
# Run command for upload on Unix systems
|
# Run command for upload on Unix systems
|
||||||
else
|
else
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -279,25 +281,26 @@ function checkChecksum() {
|
||||||
echo -n "Checking checksum... " && sleep 4
|
echo -n "Checking checksum... " && sleep 4
|
||||||
echo ""
|
echo ""
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
while [ ${correct} -eq 0 ] ; do
|
while [ ${correct} -eq 0 ] ; do
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -428,6 +431,11 @@ function showConfig() {
|
||||||
if [ ${configAvailable} -eq 0 ] ; then
|
if [ ${configAvailable} -eq 0 ] ; then
|
||||||
echo "* The configuration file does not exist!"
|
echo "* The configuration file does not exist!"
|
||||||
fi
|
fi
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
showUpvPort=$(cat ${dirConfig}/ks-upload-port)
|
||||||
|
echo "- Port Connection: ${showUpvPort}"
|
||||||
|
configAvailable=1
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
@ -451,8 +459,11 @@ function editConfig() {
|
||||||
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
||||||
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
||||||
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
||||||
|
editUpvPort=$(cat ${dirConfig}/ks-upload-port 2> /dev/null)
|
||||||
echo ""
|
echo ""
|
||||||
echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
|
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
||||||
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 1 - Edit User (${editUser})"
|
echo " 1 - Edit User (${editUser})"
|
||||||
echo " 2 - Edit Password (${editPassword})"
|
echo " 2 - Edit Password (${editPassword})"
|
||||||
|
@ -460,8 +471,9 @@ function editConfig() {
|
||||||
echo " 4 - Edit Dest. Path (${editDirServer})"
|
echo " 4 - Edit Dest. Path (${editDirServer})"
|
||||||
echo " 5 - Edit Local Path (${editDirLocal})"
|
echo " 5 - Edit Local Path (${editDirLocal})"
|
||||||
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
||||||
|
echo " 7 - Edit Port Connection (${editUpvPort})"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 7 - Exit"
|
echo " 8 - Exit"
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* Choose an option: " ; read EDIT
|
echo -n "* Choose an option: " ; read EDIT
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -509,6 +521,14 @@ function editConfig() {
|
||||||
fi
|
fi
|
||||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||||
elif [ "${EDIT}" == "7" ] ; then
|
elif [ "${EDIT}" == "7" ] ; then
|
||||||
|
echo -n "* [Default: 22] Type port connection: " ; read PORT
|
||||||
|
if [ -z "${PORT}" ] ; then
|
||||||
|
upvPort="22"
|
||||||
|
else
|
||||||
|
upvPort="${PORT}"
|
||||||
|
fi
|
||||||
|
echo ${upvPort} > ${dirConfig}/ks-upload-port
|
||||||
|
elif [ "${EDIT}" == "8" ] ; then
|
||||||
editConfig=1
|
editConfig=1
|
||||||
else
|
else
|
||||||
echo "+ Invalid option!"
|
echo "+ Invalid option!"
|
||||||
|
@ -571,7 +591,15 @@ function createConfig() {
|
||||||
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
||||||
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upf -e' for edit)"
|
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upf -e' for edit)"
|
||||||
else
|
else
|
||||||
|
echo "* Setting 'scp' as the default tool"
|
||||||
echo "scp" > ${dirConfig}/ks-upload-tool
|
echo "scp" > ${dirConfig}/ks-upload-tool
|
||||||
|
fi
|
||||||
|
# Configure port by default
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
echo "+ The PORT configuration already exists (Use: 'ks-upf -e' for edit)"
|
||||||
|
else
|
||||||
|
echo "* Setting port 22 as the default port"
|
||||||
|
echo "22" > ${dirConfig}/ks-upload-port
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
@ -591,6 +619,8 @@ function showHelp() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "- Upload common file(s) to server with scp or rsync"
|
echo "- Upload common file(s) to server with scp or rsync"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
|
echo ""
|
||||||
echo "+ Syntax:"
|
echo "+ Syntax:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " $ ks-upf -i - Start upload"
|
echo " $ ks-upf -i - Start upload"
|
||||||
|
@ -708,7 +738,8 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo "+ Removing LOCAL PATH file configuration..."
|
echo "+ Removing LOCAL PATH file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||||
echo "* Removed all configuration"
|
echo "* Removed all configuration"
|
||||||
rm -f ${dirConfig}/ks-upload-tool
|
rm -rf ${dirConfig}/ks-upload-tool
|
||||||
|
rm -rf ${dirConfig}/ks-upload-port
|
||||||
echo ""
|
echo ""
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
|
|
68
src/ks-upr
68
src/ks-upr
|
@ -145,6 +145,7 @@ function showFile() {
|
||||||
function check_fingerprint() {
|
function check_fingerprint() {
|
||||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
if [ -z "${fingerprint_host}" ] ; then
|
if [ -z "${fingerprint_host}" ] ; then
|
||||||
# Run command for upload on Windows (Cygwin)
|
# Run command for upload on Windows (Cygwin)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
|
@ -152,13 +153,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -176,13 +177,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -202,46 +203,47 @@ function check_fingerprint() {
|
||||||
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
|
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
|
||||||
function sendFile() {
|
function sendFile() {
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||||
fi
|
fi
|
||||||
# Run command for upload on Unix systems
|
# Run command for upload on Unix systems
|
||||||
else
|
else
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||||
sshpass -p ${1} scp -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
sshpass -p ${1} scp -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -354,6 +356,11 @@ function showConfig() {
|
||||||
echo "- Upload Tool: ${showUpvTool}"
|
echo "- Upload Tool: ${showUpvTool}"
|
||||||
configAvailable=1
|
configAvailable=1
|
||||||
fi
|
fi
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
showUpvPort=$(cat ${dirConfig}/ks-upload-port)
|
||||||
|
echo "- Port Connection: ${showUpvPort}"
|
||||||
|
configAvailable=1
|
||||||
|
fi
|
||||||
if [ ${configAvailable} -eq 0 ] ; then
|
if [ ${configAvailable} -eq 0 ] ; then
|
||||||
echo "* The configuration file does not exist!"
|
echo "* The configuration file does not exist!"
|
||||||
fi
|
fi
|
||||||
|
@ -380,8 +387,11 @@ function editConfig() {
|
||||||
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
||||||
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
||||||
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
||||||
|
editUpvPort=$(cat ${dirConfig}/ks-upload-port 2> /dev/null)
|
||||||
echo ""
|
echo ""
|
||||||
echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
|
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
||||||
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 1 - Edit User (${editUser})"
|
echo " 1 - Edit User (${editUser})"
|
||||||
echo " 2 - Edit Password (${editPassword})"
|
echo " 2 - Edit Password (${editPassword})"
|
||||||
|
@ -389,8 +399,9 @@ function editConfig() {
|
||||||
echo " 4 - Edit Dest. Path (${editDirServer})"
|
echo " 4 - Edit Dest. Path (${editDirServer})"
|
||||||
echo " 5 - Edit Local Path (${editDirLocal})"
|
echo " 5 - Edit Local Path (${editDirLocal})"
|
||||||
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
||||||
|
echo " 7 - Edit Port Connection (${editUpvPort})"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 7 - Exit"
|
echo " 8 - Exit"
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* Choose an option: " ; read EDIT
|
echo -n "* Choose an option: " ; read EDIT
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -438,6 +449,14 @@ function editConfig() {
|
||||||
fi
|
fi
|
||||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||||
elif [ "${EDIT}" == "7" ] ; then
|
elif [ "${EDIT}" == "7" ] ; then
|
||||||
|
echo -n "* [Default: 22] Type port connection: " ; read PORT
|
||||||
|
if [ -z "${PORT}" ] ; then
|
||||||
|
upvPort="22"
|
||||||
|
else
|
||||||
|
upvPort="${PORT}"
|
||||||
|
fi
|
||||||
|
echo ${upvPort} > ${dirConfig}/ks-upload-port
|
||||||
|
elif [ "${EDIT}" == "8" ] ; then
|
||||||
editConfig=1
|
editConfig=1
|
||||||
else
|
else
|
||||||
echo "+ Invalid option!"
|
echo "+ Invalid option!"
|
||||||
|
@ -500,7 +519,15 @@ function createConfig() {
|
||||||
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
||||||
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upr -e' for edit)"
|
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upr -e' for edit)"
|
||||||
else
|
else
|
||||||
|
echo "* Setting 'scp' as the default tool"
|
||||||
echo "scp" > ${dirConfig}/ks-upload-tool
|
echo "scp" > ${dirConfig}/ks-upload-tool
|
||||||
|
fi
|
||||||
|
# Configure port by default
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
echo "+ The PORT configuration already exists (Use: 'ks-upr -e' for edit)"
|
||||||
|
else
|
||||||
|
echo "* Setting port 22 as the default port"
|
||||||
|
echo "22" > ${dirConfig}/ks-upload-port
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
@ -520,6 +547,8 @@ function showHelp() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "- Upload recursively file(s) to server with scp or rsync"
|
echo "- Upload recursively file(s) to server with scp or rsync"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
|
echo ""
|
||||||
echo "+ Syntax:"
|
echo "+ Syntax:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " $ ks-upr -i - Start upload"
|
echo " $ ks-upr -i - Start upload"
|
||||||
|
@ -637,7 +666,8 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo "+ Removing LOCAL PATH file configuration..."
|
echo "+ Removing LOCAL PATH file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||||
echo "* Removed all configuration"
|
echo "* Removed all configuration"
|
||||||
rm -f ${dirConfig}/ks-upload-tool
|
rm -rf ${dirConfig}/ks-upload-tool
|
||||||
|
rm -rf ${dirConfig}/ks-upload-port
|
||||||
echo ""
|
echo ""
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
|
|
75
src/ks-upv
75
src/ks-upv
|
@ -135,6 +135,7 @@ function showPathFile() {
|
||||||
function check_fingerprint() {
|
function check_fingerprint() {
|
||||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
if [ -z "${fingerprint_host}" ] ; then
|
if [ -z "${fingerprint_host}" ] ; then
|
||||||
# Run command for upload on Windows (Cygwin)
|
# Run command for upload on Windows (Cygwin)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
|
@ -142,13 +143,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -166,13 +167,13 @@ function check_fingerprint() {
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||||
echo "* INFO: Only the first time you will have to enter the password."
|
echo "* INFO: Only the first time you will have to enter the password."
|
||||||
echo ""
|
echo ""
|
||||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
if [ ${OUTPUT} -ne 0 ] ; then
|
if [ ${OUTPUT} -ne 0 ] ; then
|
||||||
|
@ -194,39 +195,40 @@ function sendFile() {
|
||||||
correct=0
|
correct=0
|
||||||
countSend=0
|
countSend=0
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool)
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
while [ ${correct} -eq 0 ] ; do
|
while [ ${correct} -eq 0 ] ; do
|
||||||
# Run command for upload on Windows (Cygwin)
|
# Run command for upload on Windows (Cygwin)
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
# Run command for upload on Unix systems
|
# Run command for upload on Unix systems
|
||||||
else
|
else
|
||||||
if [ "${toolSelected}" == "rsync" ] ; then
|
if [ "${toolSelected}" == "rsync" ] ; then
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -252,25 +254,26 @@ function checkChecksum() {
|
||||||
echo -n "Checking checksum... " && sleep 4
|
echo -n "Checking checksum... " && sleep 4
|
||||||
echo ""
|
echo ""
|
||||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||||
|
portSelected=$(cat ${dirConfig}/ks-upload-port)
|
||||||
while [ ${correct} -eq 0 ] ; do
|
while [ ${correct} -eq 0 ] ; do
|
||||||
if [ "${cygwin}" == "yes" ] ; then
|
if [ "${cygwin}" == "yes" ] ; then
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -398,6 +401,11 @@ function showConfig() {
|
||||||
echo "- Upload Tool: ${showUpvTool}"
|
echo "- Upload Tool: ${showUpvTool}"
|
||||||
configAvailable=1
|
configAvailable=1
|
||||||
fi
|
fi
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
showUpvPort=$(cat ${dirConfig}/ks-upload-port)
|
||||||
|
echo "- Port Connection: ${showUpvPort}"
|
||||||
|
configAvailable=1
|
||||||
|
fi
|
||||||
if [ ${configAvailable} -eq 0 ] ; then
|
if [ ${configAvailable} -eq 0 ] ; then
|
||||||
echo "* The configuration file does not exist!"
|
echo "* The configuration file does not exist!"
|
||||||
fi
|
fi
|
||||||
|
@ -424,17 +432,21 @@ function editConfig() {
|
||||||
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
editDirServer=$(cat ${dirConfig}/ks-upload-dirserver 2> /dev/null)
|
||||||
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
editDirLocal=$(cat ${dirConfig}/ks-upload-dirlocal 2> /dev/null)
|
||||||
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
editUpvTool=$(cat ${dirConfig}/ks-upload-tool 2> /dev/null)
|
||||||
|
editUpvPort=$(cat ${dirConfig}/ks-upload-port 2> /dev/null)
|
||||||
echo ""
|
echo ""
|
||||||
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
|
echo ""
|
||||||
echo " 1 - Edit User (${editUser})"
|
echo " 1 - Edit User (${editUser})"
|
||||||
echo " 2 - Edit Password (${editPassword})"
|
echo " 2 - Edit Password (${editPassword})"
|
||||||
echo " 3 - Edit Server (${editServer})"
|
echo " 3 - Edit Server (${editServer})"
|
||||||
echo " 4 - Edit Dest. Path (${editDirServer})"
|
echo " 4 - Edit Dest. Path (${editDirServer})"
|
||||||
echo " 5 - Edit Local Path (${editDirLocal})"
|
echo " 5 - Edit Local Path (${editDirLocal})"
|
||||||
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
echo " 6 - Edit Upload Tool (${editUpvTool})"
|
||||||
|
echo " 7 - Edit Port Connection (${editUpvPort})"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 7 - Exit"
|
echo " 8 - Exit"
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* Choose an option: " ; read EDIT
|
echo -n "* Choose an option: " ; read EDIT
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -482,6 +494,14 @@ function editConfig() {
|
||||||
fi
|
fi
|
||||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||||
elif [ "${EDIT}" == "7" ] ; then
|
elif [ "${EDIT}" == "7" ] ; then
|
||||||
|
echo -n "* [Default: 22] Type port connection: " ; read PORT
|
||||||
|
if [ -z "${PORT}" ] ; then
|
||||||
|
upvPort="22"
|
||||||
|
else
|
||||||
|
upvPort="${PORT}"
|
||||||
|
fi
|
||||||
|
echo ${upvPort} > ${dirConfig}/ks-upload-port
|
||||||
|
elif [ "${EDIT}" == "8" ] ; then
|
||||||
editConfig=1
|
editConfig=1
|
||||||
else
|
else
|
||||||
echo "+ Invalid option!"
|
echo "+ Invalid option!"
|
||||||
|
@ -544,7 +564,15 @@ function createConfig() {
|
||||||
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
if [ -f ${dirConfig}/ks-upload-tool ] ; then
|
||||||
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upv -e' for edit)"
|
echo "+ The UPLOAD TOOL configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
|
echo "* Setting 'scp' as the default tool"
|
||||||
echo "scp" > ${dirConfig}/ks-upload-tool
|
echo "scp" > ${dirConfig}/ks-upload-tool
|
||||||
|
fi
|
||||||
|
# Configure port by default
|
||||||
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
|
echo "+ The PORT configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
|
else
|
||||||
|
echo "* Setting port 22 as the default port"
|
||||||
|
echo "22" > ${dirConfig}/ks-upload-port
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
@ -564,6 +592,8 @@ function showHelp() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "- Upload videos file(s) to server with scp or rsync"
|
echo "- Upload videos file(s) to server with scp or rsync"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "+ Config: ${dirConfig}/ks-upload-*"
|
||||||
|
echo ""
|
||||||
echo "+ Syntax:"
|
echo "+ Syntax:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " $ ks-upv -i - Start upload"
|
echo " $ ks-upv -i - Start upload"
|
||||||
|
@ -681,7 +711,8 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo "+ Removing LOCAL PATH file configuration..."
|
echo "+ Removing LOCAL PATH file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-dirlocal
|
rm -rf ${dirConfig}/ks-upload-dirlocal
|
||||||
echo "* Removed all configuration"
|
echo "* Removed all configuration"
|
||||||
rm -f ${dirConfig}/ks-upload-tool
|
rm -rf ${dirConfig}/ks-upload-tool
|
||||||
|
rm -rf ${dirConfig}/ks-upload-port
|
||||||
echo ""
|
echo ""
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user