Add support for connect using pem certificate (ks-upv/upa/upf/upr)
This commit is contained in:
parent
f84e808df3
commit
85845c59c7
95
src/ks-upa
95
src/ks-upa
|
@ -191,6 +191,13 @@ EOF
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
|
/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
/usr/bin/scp -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
@ -248,6 +255,13 @@ EOF
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
rsync --progress -azL --rsh="ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
|
ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
scp -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
@ -280,9 +294,19 @@ function checkChecksum() {
|
||||||
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
|
||||||
|
if [ "${selectedTool}" == "rsync-pem" ] ; then
|
||||||
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
|
checksumServer=$(/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${selectedTool}" == "scp-pem" ] ; then
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
else
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
fi
|
||||||
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
OUTPUT=0
|
OUTPUT=0
|
||||||
|
@ -296,13 +320,25 @@ function checkChecksum() {
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
|
if [ "${selectedTool}" == "rsync-pem" ] ; then
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${selectedTool}" == "scp-pem" ] ; then
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
else
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
fi
|
||||||
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
|
OUTPUT=0
|
||||||
elif [ "${selectedTool}" == "scp-e" ] ; then
|
elif [ "${selectedTool}" == "scp-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
|
OUTPUT=0
|
||||||
else
|
else
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
@ -498,12 +534,12 @@ function editConfig() {
|
||||||
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)
|
editUpvPort=$(cat ${dirConfig}/ks-upload-port 2> /dev/null)
|
||||||
echo ""
|
echo ""
|
||||||
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Config: ${dirConfig}/ks-upload-*"
|
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/PEM (${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})"
|
||||||
|
@ -519,10 +555,23 @@ function editConfig() {
|
||||||
user=${USER}
|
user=${USER}
|
||||||
echo ${user} > ${dirConfig}/ks-upload-user
|
echo ${user} > ${dirConfig}/ks-upload-user
|
||||||
elif [ "${EDIT}" == "2" ] ; then
|
elif [ "${EDIT}" == "2" ] ; then
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
fi
|
||||||
elif [ "${EDIT}" == "3" ] ; then
|
elif [ "${EDIT}" == "3" ] ; then
|
||||||
echo -n "* Enter the server URL: " ; read SERVER
|
echo -n "* Enter the server URL: " ; read SERVER
|
||||||
server=${SERVER}
|
server=${SERVER}
|
||||||
|
@ -545,10 +594,13 @@ function editConfig() {
|
||||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||||
echo "- scp-e"
|
echo "- scp-e"
|
||||||
echo "- rsync-e"
|
echo "- rsync-e"
|
||||||
|
echo "- scp-pem"
|
||||||
|
echo "- rsync-pem"
|
||||||
echo ""
|
echo ""
|
||||||
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
||||||
|
echo "* Note: 'scp-pem' and 'rsync-pem' use ~/.ks-tools/connect.pem."
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa/scp-e/rsync-e): " ; read TOOL
|
echo -n "* [Default: scp] Type upload tool (Example: rsync-e): " ; read TOOL
|
||||||
if [ -z "${TOOL}" ] ; then
|
if [ -z "${TOOL}" ] ; then
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
elif [ "${TOOL}" == "rsync" ] ; then
|
elif [ "${TOOL}" == "rsync" ] ; then
|
||||||
|
@ -561,6 +613,10 @@ function editConfig() {
|
||||||
upvTool="scp-e"
|
upvTool="scp-e"
|
||||||
elif [ "${TOOL}" == "rsync-e" ] ; then
|
elif [ "${TOOL}" == "rsync-e" ] ; then
|
||||||
upvTool="rsync-e"
|
upvTool="rsync-e"
|
||||||
|
elif [ "${TOOL}" == "scp-pem" ] ; then
|
||||||
|
upvTool="scp-pem"
|
||||||
|
elif [ "${TOOL}" == "rsync-pem" ] ; then
|
||||||
|
upvTool="rsync-pem"
|
||||||
else
|
else
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
fi
|
fi
|
||||||
|
@ -601,12 +657,25 @@ function createConfig() {
|
||||||
fi
|
fi
|
||||||
# Ask the password and if it exists, read it from the config.
|
# Ask the password and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
||||||
echo "+ The PASSWORD configuration already exists (Use: 'ks-upa -e' for edit)"
|
echo "+ The PASSWORD/PEM configuration already exists (Use: 'ks-upa -e' for edit)"
|
||||||
else
|
else
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Ask the server URL and if it exists, read it from the config.
|
# Ask the server URL and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
||||||
|
@ -673,7 +742,7 @@ function showHelp() {
|
||||||
echo " $ ks-upa -r - Remove configuration"
|
echo " $ ks-upa -r - Remove configuration"
|
||||||
echo " $ ks-upa -c - Show configuration"
|
echo " $ ks-upa -c - Show configuration"
|
||||||
echo " $ ks-upa -e - Edit configuration"
|
echo " $ ks-upa -e - Edit configuration"
|
||||||
echo " $ ks-upv -p - Generate certificate"
|
echo " $ ks-upa -p - Generate certificate"
|
||||||
echo " $ ks-upa -v - Show version"
|
echo " $ ks-upa -v - Show version"
|
||||||
echo " $ ks-upa -h - Show help"
|
echo " $ ks-upa -h - Show help"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -684,7 +753,7 @@ function showHelp() {
|
||||||
# for the execution are installed.
|
# for the execution are installed.
|
||||||
function checkDependencies() {
|
function checkDependencies() {
|
||||||
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
||||||
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan"
|
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan ssh-keygen"
|
||||||
dependencies_found=""
|
dependencies_found=""
|
||||||
dependencies_not_found=""
|
dependencies_not_found=""
|
||||||
for checkPath in ${path_check} ; do
|
for checkPath in ${path_check} ; do
|
||||||
|
@ -765,8 +834,9 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Removing USER file configuration..."
|
echo "+ Removing USER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-user
|
rm -rf ${dirConfig}/ks-upload-user
|
||||||
echo "+ Removing PASSWORD file configuration..."
|
echo "+ Removing PASSWORD/PEM file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-pass
|
rm -rf ${dirConfig}/ks-upload-pass
|
||||||
|
rm -rf ${dirConfig}/connect.pem
|
||||||
echo "+ Removing SERVER file configuration..."
|
echo "+ Removing SERVER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-server
|
rm -rf ${dirConfig}/ks-upload-server
|
||||||
echo "+ Removing SERVER PATH file configuration..."
|
echo "+ Removing SERVER PATH file configuration..."
|
||||||
|
@ -785,7 +855,7 @@ if [ "${1}" == "-r" ] ; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Show configuration file
|
# Show configuration file
|
||||||
if [ "${1}" == "-c" ] ; then
|
if [ "${1}" == "-c" ] ; then
|
||||||
showConfig
|
showConfig
|
||||||
# Edit configuration file
|
# Edit configuration file
|
||||||
|
@ -800,6 +870,7 @@ elif [ "${1}" == "-p" ] ; then
|
||||||
# Show the help
|
# Show the help
|
||||||
elif [ "${1}" == "-h" ] ; then
|
elif [ "${1}" == "-h" ] ; then
|
||||||
showHelp
|
showHelp
|
||||||
|
# Create config
|
||||||
elif [ "${1}" == "-g" ] ; then
|
elif [ "${1}" == "-g" ] ; then
|
||||||
createConfig
|
createConfig
|
||||||
# Init
|
# Init
|
||||||
|
@ -819,7 +890,7 @@ elif [ "${1}" == "-i" ] ; then
|
||||||
listArchives "${dirLocal}"
|
listArchives "${dirLocal}"
|
||||||
totalFiles=$(countArchives)
|
totalFiles=$(countArchives)
|
||||||
count=1
|
count=1
|
||||||
echo "+ ${totalFiles} audio file(s) found!"
|
echo "+ ${totalFiles} video file(s) found!"
|
||||||
echo ""
|
echo ""
|
||||||
current_tool=$(cat ${dirConfig}/ks-upload-tool)
|
current_tool=$(cat ${dirConfig}/ks-upload-tool)
|
||||||
if [ "${current_tool}" == "scp" ] ; then
|
if [ "${current_tool}" == "scp" ] ; then
|
||||||
|
|
95
src/ks-upf
95
src/ks-upf
|
@ -218,6 +218,13 @@ EOF
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
|
/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
/usr/bin/scp -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
@ -275,6 +282,13 @@ EOF
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
rsync --progress -azL --rsh="ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
|
ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
scp -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
@ -307,9 +321,19 @@ function checkChecksum() {
|
||||||
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
|
||||||
|
if [ "${selectedTool}" == "rsync-pem" ] ; then
|
||||||
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
|
checksumServer=$(/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${selectedTool}" == "scp-pem" ] ; then
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
else
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
fi
|
||||||
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
OUTPUT=0
|
OUTPUT=0
|
||||||
|
@ -323,13 +347,25 @@ function checkChecksum() {
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
|
if [ "${selectedTool}" == "rsync-pem" ] ; then
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${selectedTool}" == "scp-pem" ] ; then
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
else
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
fi
|
||||||
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
|
OUTPUT=0
|
||||||
elif [ "${selectedTool}" == "scp-e" ] ; then
|
elif [ "${selectedTool}" == "scp-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
|
OUTPUT=0
|
||||||
else
|
else
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
@ -525,12 +561,12 @@ function editConfig() {
|
||||||
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)
|
editUpvPort=$(cat ${dirConfig}/ks-upload-port 2> /dev/null)
|
||||||
echo ""
|
echo ""
|
||||||
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Config: ${dirConfig}/ks-upload-*"
|
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/PEM (${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})"
|
||||||
|
@ -546,10 +582,23 @@ function editConfig() {
|
||||||
user=${USER}
|
user=${USER}
|
||||||
echo ${user} > ${dirConfig}/ks-upload-user
|
echo ${user} > ${dirConfig}/ks-upload-user
|
||||||
elif [ "${EDIT}" == "2" ] ; then
|
elif [ "${EDIT}" == "2" ] ; then
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
fi
|
||||||
elif [ "${EDIT}" == "3" ] ; then
|
elif [ "${EDIT}" == "3" ] ; then
|
||||||
echo -n "* Enter the server URL: " ; read SERVER
|
echo -n "* Enter the server URL: " ; read SERVER
|
||||||
server=${SERVER}
|
server=${SERVER}
|
||||||
|
@ -572,10 +621,13 @@ function editConfig() {
|
||||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||||
echo "- scp-e"
|
echo "- scp-e"
|
||||||
echo "- rsync-e"
|
echo "- rsync-e"
|
||||||
|
echo "- scp-pem"
|
||||||
|
echo "- rsync-pem"
|
||||||
echo ""
|
echo ""
|
||||||
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
||||||
|
echo "* Note: 'scp-pem' and 'rsync-pem' use ~/.ks-tools/connect.pem."
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa/scp-e/rsync-e): " ; read TOOL
|
echo -n "* [Default: scp] Type upload tool (Example: rsync-e): " ; read TOOL
|
||||||
if [ -z "${TOOL}" ] ; then
|
if [ -z "${TOOL}" ] ; then
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
elif [ "${TOOL}" == "rsync" ] ; then
|
elif [ "${TOOL}" == "rsync" ] ; then
|
||||||
|
@ -588,6 +640,10 @@ function editConfig() {
|
||||||
upvTool="scp-e"
|
upvTool="scp-e"
|
||||||
elif [ "${TOOL}" == "rsync-e" ] ; then
|
elif [ "${TOOL}" == "rsync-e" ] ; then
|
||||||
upvTool="rsync-e"
|
upvTool="rsync-e"
|
||||||
|
elif [ "${TOOL}" == "scp-pem" ] ; then
|
||||||
|
upvTool="scp-pem"
|
||||||
|
elif [ "${TOOL}" == "rsync-pem" ] ; then
|
||||||
|
upvTool="rsync-pem"
|
||||||
else
|
else
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
fi
|
fi
|
||||||
|
@ -628,12 +684,25 @@ function createConfig() {
|
||||||
fi
|
fi
|
||||||
# Ask the password and if it exists, read it from the config.
|
# Ask the password and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
||||||
echo "+ The PASSWORD configuration already exists (Use: 'ks-upf -e' for edit)"
|
echo "+ The PASSWORD/PEM configuration already exists (Use: 'ks-upf -e' for edit)"
|
||||||
else
|
else
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Ask the server URL and if it exists, read it from the config.
|
# Ask the server URL and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
||||||
|
@ -700,7 +769,7 @@ function showHelp() {
|
||||||
echo " $ ks-upf -r - Remove configuration"
|
echo " $ ks-upf -r - Remove configuration"
|
||||||
echo " $ ks-upf -c - Show configuration"
|
echo " $ ks-upf -c - Show configuration"
|
||||||
echo " $ ks-upf -e - Edit configuration"
|
echo " $ ks-upf -e - Edit configuration"
|
||||||
echo " $ ks-upv -p - Generate certificate"
|
echo " $ ks-upf -p - Generate certificate"
|
||||||
echo " $ ks-upf -v - Show version"
|
echo " $ ks-upf -v - Show version"
|
||||||
echo " $ ks-upf -h - Show help"
|
echo " $ ks-upf -h - Show help"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -711,7 +780,7 @@ function showHelp() {
|
||||||
# for the execution are installed.
|
# for the execution are installed.
|
||||||
function checkDependencies() {
|
function checkDependencies() {
|
||||||
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
||||||
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan"
|
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan ssh-keygen"
|
||||||
dependencies_found=""
|
dependencies_found=""
|
||||||
dependencies_not_found=""
|
dependencies_not_found=""
|
||||||
for checkPath in ${path_check} ; do
|
for checkPath in ${path_check} ; do
|
||||||
|
@ -792,8 +861,9 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Removing USER file configuration..."
|
echo "+ Removing USER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-user
|
rm -rf ${dirConfig}/ks-upload-user
|
||||||
echo "+ Removing PASSWORD file configuration..."
|
echo "+ Removing PASSWORD/PEM file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-pass
|
rm -rf ${dirConfig}/ks-upload-pass
|
||||||
|
rm -rf ${dirConfig}/connect.pem
|
||||||
echo "+ Removing SERVER file configuration..."
|
echo "+ Removing SERVER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-server
|
rm -rf ${dirConfig}/ks-upload-server
|
||||||
echo "+ Removing SERVER PATH file configuration..."
|
echo "+ Removing SERVER PATH file configuration..."
|
||||||
|
@ -812,7 +882,7 @@ if [ "${1}" == "-r" ] ; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Show configuration file
|
# Show configuration file
|
||||||
if [ "${1}" == "-c" ] ; then
|
if [ "${1}" == "-c" ] ; then
|
||||||
showConfig
|
showConfig
|
||||||
# Edit configuration file
|
# Edit configuration file
|
||||||
|
@ -827,6 +897,7 @@ elif [ "${1}" == "-p" ] ; then
|
||||||
# Show the help
|
# Show the help
|
||||||
elif [ "${1}" == "-h" ] ; then
|
elif [ "${1}" == "-h" ] ; then
|
||||||
showHelp
|
showHelp
|
||||||
|
# Create config
|
||||||
elif [ "${1}" == "-g" ] ; then
|
elif [ "${1}" == "-g" ] ; then
|
||||||
createConfig
|
createConfig
|
||||||
# Init
|
# Init
|
||||||
|
@ -846,7 +917,7 @@ elif [ "${1}" == "-i" ] ; then
|
||||||
listArchives "${dirLocal}"
|
listArchives "${dirLocal}"
|
||||||
totalFiles=$(countArchives)
|
totalFiles=$(countArchives)
|
||||||
count=1
|
count=1
|
||||||
echo "+ ${totalFiles} common file(s) found!"
|
echo "+ ${totalFiles} video file(s) found!"
|
||||||
echo ""
|
echo ""
|
||||||
current_tool=$(cat ${dirConfig}/ks-upload-tool)
|
current_tool=$(cat ${dirConfig}/ks-upload-tool)
|
||||||
if [ "${current_tool}" == "scp" ] ; then
|
if [ "${current_tool}" == "scp" ] ; then
|
||||||
|
|
80
src/ks-upr
80
src/ks-upr
|
@ -184,6 +184,15 @@ EOF
|
||||||
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 -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
echo ""
|
||||||
|
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||||
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/ssh -i ${dirConfig}/connect.pem -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||||
|
/usr/bin/ssh -i ${dirConfig}/connect.pem -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
echo ""
|
||||||
|
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||||
|
scp -i ${dirConfig}/connect.pem -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -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})"
|
||||||
|
@ -229,6 +238,15 @@ EOF
|
||||||
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 -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
echo ""
|
||||||
|
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||||
|
rsync --progress -azL --rsh="ssh -i ${dirConfig}/connect.pem -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||||
|
ssh -i ${dirConfig}/connect.pem -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
echo ""
|
||||||
|
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||||
|
scp -i ${dirConfig}/connect.pem -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -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})"
|
||||||
|
@ -407,7 +425,7 @@ function editConfig() {
|
||||||
echo "+ Config: ${dirConfig}/ks-upload-*"
|
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/PEM (${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})"
|
||||||
|
@ -423,10 +441,23 @@ function editConfig() {
|
||||||
user=${USER}
|
user=${USER}
|
||||||
echo ${user} > ${dirConfig}/ks-upload-user
|
echo ${user} > ${dirConfig}/ks-upload-user
|
||||||
elif [ "${EDIT}" == "2" ] ; then
|
elif [ "${EDIT}" == "2" ] ; then
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
fi
|
||||||
elif [ "${EDIT}" == "3" ] ; then
|
elif [ "${EDIT}" == "3" ] ; then
|
||||||
echo -n "* Enter the server URL: " ; read SERVER
|
echo -n "* Enter the server URL: " ; read SERVER
|
||||||
server=${SERVER}
|
server=${SERVER}
|
||||||
|
@ -449,10 +480,13 @@ function editConfig() {
|
||||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||||
echo "- scp-e"
|
echo "- scp-e"
|
||||||
echo "- rsync-e"
|
echo "- rsync-e"
|
||||||
|
echo "- scp-pem"
|
||||||
|
echo "- rsync-pem"
|
||||||
echo ""
|
echo ""
|
||||||
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
||||||
|
echo "* Note: 'scp-pem' and 'rsync-pem' use ~/.ks-tools/connect.pem."
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa/scp-e/rsync-e): " ; read TOOL
|
echo -n "* [Default: scp] Type upload tool (Example: rsync-e): " ; read TOOL
|
||||||
if [ -z "${TOOL}" ] ; then
|
if [ -z "${TOOL}" ] ; then
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
elif [ "${TOOL}" == "rsync" ] ; then
|
elif [ "${TOOL}" == "rsync" ] ; then
|
||||||
|
@ -465,6 +499,10 @@ function editConfig() {
|
||||||
upvTool="scp-e"
|
upvTool="scp-e"
|
||||||
elif [ "${TOOL}" == "rsync-e" ] ; then
|
elif [ "${TOOL}" == "rsync-e" ] ; then
|
||||||
upvTool="rsync-e"
|
upvTool="rsync-e"
|
||||||
|
elif [ "${TOOL}" == "scp-pem" ] ; then
|
||||||
|
upvTool="scp-pem"
|
||||||
|
elif [ "${TOOL}" == "rsync-pem" ] ; then
|
||||||
|
upvTool="rsync-pem"
|
||||||
else
|
else
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
fi
|
fi
|
||||||
|
@ -492,12 +530,12 @@ function createConfig() {
|
||||||
# Start script
|
# Start script
|
||||||
clear
|
clear
|
||||||
echo ""
|
echo ""
|
||||||
echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
|
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
||||||
echo ""
|
echo ""
|
||||||
checkDependencies
|
checkDependencies
|
||||||
# Ask the user and if it exists, read it from the config.
|
# Ask the user and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-user ] ; then
|
if [ -f ${dirConfig}/ks-upload-user ] ; then
|
||||||
echo "+ The USER configuration already exists (Use: 'ks-upr -e' for edit)"
|
echo "+ The USER configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
echo -n "* Enter the server user: " ; read USER
|
echo -n "* Enter the server user: " ; read USER
|
||||||
user=${USER}
|
user=${USER}
|
||||||
|
@ -505,16 +543,29 @@ function createConfig() {
|
||||||
fi
|
fi
|
||||||
# Ask the password and if it exists, read it from the config.
|
# Ask the password and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
||||||
echo "+ The PASSWORD configuration already exists (Use: 'ks-upr -e' for edit)"
|
echo "+ The PASSWORD/PEM configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
|
else
|
||||||
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
# Ask the server URL and if it exists, read it from the config.
|
# Ask the server URL and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
||||||
echo "+ The SERVER configuration already exists (Use: 'ks-upr -e' for edit)"
|
echo "+ The SERVER configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
echo -n "* Enter the server URL: " ; read SERVER
|
echo -n "* Enter the server URL: " ; read SERVER
|
||||||
server=${SERVER}
|
server=${SERVER}
|
||||||
|
@ -522,7 +573,7 @@ function createConfig() {
|
||||||
fi
|
fi
|
||||||
# Ask the path on the server and if it exists, read it from the config.
|
# Ask the path on the server and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
|
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
|
||||||
echo "+ The SERVER PATH configuration already exists (Use: 'ks-upr -e' for edit)"
|
echo "+ The SERVER PATH configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
echo -n "* Enter the path on the server: " ; read DIR_SERVER
|
echo -n "* Enter the path on the server: " ; read DIR_SERVER
|
||||||
dirServer=${DIR_SERVER}
|
dirServer=${DIR_SERVER}
|
||||||
|
@ -530,7 +581,7 @@ function createConfig() {
|
||||||
fi
|
fi
|
||||||
# Ask the local path and if it exists, read it from the config.
|
# Ask the local path and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
|
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
|
||||||
echo "+ The LOCAL PATH configuration already exists (Use: 'ks-upr -e' for edit)"
|
echo "+ The LOCAL PATH configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
echo -n "* Enter the local path to scan: " ; read DIR
|
echo -n "* Enter the local path to scan: " ; read DIR
|
||||||
dirLocal=${DIR}
|
dirLocal=${DIR}
|
||||||
|
@ -538,14 +589,14 @@ function createConfig() {
|
||||||
fi
|
fi
|
||||||
# Configure upload tool by default
|
# Configure upload tool by default
|
||||||
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-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
echo "* Setting 'scp' as the default tool"
|
echo "* Setting 'scp' as the default tool"
|
||||||
echo "scp" > ${dirConfig}/ks-upload-tool
|
echo "scp" > ${dirConfig}/ks-upload-tool
|
||||||
fi
|
fi
|
||||||
# Configure port by default
|
# Configure port by default
|
||||||
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
if [ -f ${dirConfig}/ks-upload-port ] ; then
|
||||||
echo "+ The PORT configuration already exists (Use: 'ks-upr -e' for edit)"
|
echo "+ The PORT configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
echo "* Setting port 22 as the default port"
|
echo "* Setting port 22 as the default port"
|
||||||
echo "22" > ${dirConfig}/ks-upload-port
|
echo "22" > ${dirConfig}/ks-upload-port
|
||||||
|
@ -588,7 +639,7 @@ function showHelp() {
|
||||||
# for the execution are installed.
|
# for the execution are installed.
|
||||||
function checkDependencies() {
|
function checkDependencies() {
|
||||||
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
||||||
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan"
|
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan ssh-keygen"
|
||||||
dependencies_found=""
|
dependencies_found=""
|
||||||
dependencies_not_found=""
|
dependencies_not_found=""
|
||||||
for checkPath in ${path_check} ; do
|
for checkPath in ${path_check} ; do
|
||||||
|
@ -669,8 +720,9 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Removing USER file configuration..."
|
echo "+ Removing USER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-user
|
rm -rf ${dirConfig}/ks-upload-user
|
||||||
echo "+ Removing PASSWORD file configuration..."
|
echo "+ Removing PASSWORD/PEM file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-pass
|
rm -rf ${dirConfig}/ks-upload-pass
|
||||||
|
rm -rf ${dirConfig}/connect.pem
|
||||||
echo "+ Removing SERVER file configuration..."
|
echo "+ Removing SERVER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-server
|
rm -rf ${dirConfig}/ks-upload-server
|
||||||
echo "+ Removing SERVER PATH file configuration..."
|
echo "+ Removing SERVER PATH file configuration..."
|
||||||
|
|
86
src/ks-upv
86
src/ks-upv
|
@ -191,6 +191,13 @@ EOF
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
/usr/bin/rsync --progress -azL --rsh="/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
|
/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
/usr/bin/scp -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
/usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
@ -248,6 +255,13 @@ EOF
|
||||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "rsync-pem" ] ; then
|
||||||
|
rsync --progress -azL --rsh="ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||||
|
ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${toolSelected}" == "scp-pem" ] ; then
|
||||||
|
scp -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
|
OUTPUT=$?
|
||||||
else
|
else
|
||||||
sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
@ -280,9 +294,19 @@ function checkChecksum() {
|
||||||
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
|
||||||
|
if [ "${selectedTool}" == "rsync-pem" ] ; then
|
||||||
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
|
checksumServer=$(/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
elif [ "${selectedTool}" == "scp-pem" ] ; then
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(/usr/bin/ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
else
|
||||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
fi
|
||||||
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
OUTPUT=0
|
OUTPUT=0
|
||||||
|
@ -296,13 +320,25 @@ function checkChecksum() {
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${toolSelected}" ] ; then
|
if [ -z "${toolSelected}" ] ; then
|
||||||
|
if [ "${selectedTool}" == "rsync-pem" ] ; then
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
OUTPUT=$?
|
OUTPUT=$?
|
||||||
|
elif [ "${selectedTool}" == "scp-pem" ] ; then
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(ssh -i ${dirConfig}/connect.pem -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
else
|
||||||
|
checksumLocal=$(md5sum ${2})
|
||||||
|
checksumServer=$(sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
OUTPUT=$?
|
||||||
|
fi
|
||||||
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
elif [ "${selectedTool}" == "rsync-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
|
OUTPUT=0
|
||||||
elif [ "${selectedTool}" == "scp-e" ] ; then
|
elif [ "${selectedTool}" == "scp-e" ] ; then
|
||||||
echo > /dev/null
|
echo > /dev/null
|
||||||
|
OUTPUT=0
|
||||||
else
|
else
|
||||||
checksumLocal=$(md5sum ${2})
|
checksumLocal=$(md5sum ${2})
|
||||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||||
|
@ -503,7 +539,7 @@ function editConfig() {
|
||||||
echo "+ Config: ${dirConfig}/ks-upload-*"
|
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/PEM (${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})"
|
||||||
|
@ -519,10 +555,23 @@ function editConfig() {
|
||||||
user=${USER}
|
user=${USER}
|
||||||
echo ${user} > ${dirConfig}/ks-upload-user
|
echo ${user} > ${dirConfig}/ks-upload-user
|
||||||
elif [ "${EDIT}" == "2" ] ; then
|
elif [ "${EDIT}" == "2" ] ; then
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
fi
|
||||||
elif [ "${EDIT}" == "3" ] ; then
|
elif [ "${EDIT}" == "3" ] ; then
|
||||||
echo -n "* Enter the server URL: " ; read SERVER
|
echo -n "* Enter the server URL: " ; read SERVER
|
||||||
server=${SERVER}
|
server=${SERVER}
|
||||||
|
@ -545,10 +594,13 @@ function editConfig() {
|
||||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||||
echo "- scp-e"
|
echo "- scp-e"
|
||||||
echo "- rsync-e"
|
echo "- rsync-e"
|
||||||
|
echo "- scp-pem"
|
||||||
|
echo "- rsync-pem"
|
||||||
echo ""
|
echo ""
|
||||||
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
echo "* Note: 'scp-e' and 'rsync-e' use 'expect' instead of 'sshpass'."
|
||||||
|
echo "* Note: 'scp-pem' and 'rsync-pem' use ~/.ks-tools/connect.pem."
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa/scp-e/rsync-e): " ; read TOOL
|
echo -n "* [Default: scp] Type upload tool (Example: rsync-e): " ; read TOOL
|
||||||
if [ -z "${TOOL}" ] ; then
|
if [ -z "${TOOL}" ] ; then
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
elif [ "${TOOL}" == "rsync" ] ; then
|
elif [ "${TOOL}" == "rsync" ] ; then
|
||||||
|
@ -561,6 +613,10 @@ function editConfig() {
|
||||||
upvTool="scp-e"
|
upvTool="scp-e"
|
||||||
elif [ "${TOOL}" == "rsync-e" ] ; then
|
elif [ "${TOOL}" == "rsync-e" ] ; then
|
||||||
upvTool="rsync-e"
|
upvTool="rsync-e"
|
||||||
|
elif [ "${TOOL}" == "scp-pem" ] ; then
|
||||||
|
upvTool="scp-pem"
|
||||||
|
elif [ "${TOOL}" == "rsync-pem" ] ; then
|
||||||
|
upvTool="rsync-pem"
|
||||||
else
|
else
|
||||||
upvTool="scp"
|
upvTool="scp"
|
||||||
fi
|
fi
|
||||||
|
@ -601,12 +657,25 @@ function createConfig() {
|
||||||
fi
|
fi
|
||||||
# Ask the password and if it exists, read it from the config.
|
# Ask the password and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
if [ -f ${dirConfig}/ks-upload-pass ] ; then
|
||||||
echo "+ The PASSWORD configuration already exists (Use: 'ks-upv -e' for edit)"
|
echo "+ The PASSWORD/PEM configuration already exists (Use: 'ks-upv -e' for edit)"
|
||||||
else
|
else
|
||||||
echo -n "* Enter the server password: " ; read PASS
|
echo -n "* Enter the server password (type 'pem' for use pem certificate): " ; read PASS
|
||||||
|
if [ "${PASS}" == "pem" ] ; then
|
||||||
|
echo -n "+ Type the absolute path to the .pem file: " ; read pem_path
|
||||||
|
if [ -f "${pem_path}" ] ; then
|
||||||
raw_password_enter=${PASS}
|
raw_password_enter=${PASS}
|
||||||
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
cp -rf "${pem_path}" ${dirConfig}/connect.pem
|
||||||
|
echo "* PEM file copied to ${dirConfig}/connect.pem"
|
||||||
|
else
|
||||||
|
echo "+ File ${pem_path} does not exist"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
raw_password_enter=${PASS}
|
||||||
|
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
|
||||||
|
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Ask the server URL and if it exists, read it from the config.
|
# Ask the server URL and if it exists, read it from the config.
|
||||||
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
if [ -f ${dirConfig}/ks-upload-server ] ; then
|
||||||
|
@ -684,7 +753,7 @@ function showHelp() {
|
||||||
# for the execution are installed.
|
# for the execution are installed.
|
||||||
function checkDependencies() {
|
function checkDependencies() {
|
||||||
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
path_check="/usr/bin /bin /usr/local/bin ${HOME}/.local/bin"
|
||||||
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan"
|
dependencies="sshpass expect rsync md5sum scp ssh find grep sed cut head tail cat ssh-keyscan ssh-keygen"
|
||||||
dependencies_found=""
|
dependencies_found=""
|
||||||
dependencies_not_found=""
|
dependencies_not_found=""
|
||||||
for checkPath in ${path_check} ; do
|
for checkPath in ${path_check} ; do
|
||||||
|
@ -765,8 +834,9 @@ if [ "${1}" == "-r" ] ; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "+ Removing USER file configuration..."
|
echo "+ Removing USER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-user
|
rm -rf ${dirConfig}/ks-upload-user
|
||||||
echo "+ Removing PASSWORD file configuration..."
|
echo "+ Removing PASSWORD/PEM file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-pass
|
rm -rf ${dirConfig}/ks-upload-pass
|
||||||
|
rm -rf ${dirConfig}/connect.pem
|
||||||
echo "+ Removing SERVER file configuration..."
|
echo "+ Removing SERVER file configuration..."
|
||||||
rm -rf ${dirConfig}/ks-upload-server
|
rm -rf ${dirConfig}/ks-upload-server
|
||||||
echo "+ Removing SERVER PATH file configuration..."
|
echo "+ Removing SERVER PATH file configuration..."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user