Change CLI interface on ks-up* tools

This commit is contained in:
q3aql 2021-03-08 01:37:15 +01:00
parent 692c443802
commit 7b28d0166a
4 changed files with 199 additions and 199 deletions

View File

@ -74,13 +74,13 @@ function listArchives() {
echo "null" > /dev/null echo "null" > /dev/null
else else
find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp} find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp}
echo "Audio file(s) in .${format} found!" echo "+ Audio file(s) in .${format} found!"
cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp} cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp}
fail=0 fail=0
fi fi
done done
if [ ${fail} -eq 1 ] ; then if [ ${fail} -eq 1 ] ; then
echo "No audio file(s) found!" echo "+ No audio file(s) found!"
echo "" echo ""
exit exit
else else
@ -178,35 +178,35 @@ function checkChecksum() {
function showConfig() { function showConfig() {
configAvailable=0 configAvailable=0
echo "" echo ""
echo "ks-upa (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
if [ -f ${dirConfig}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
showUser=$(cat ${dirConfig}/USER) showUser=$(cat ${dirConfig}/USER)
echo "Server User: ${showUser}" echo "- Server User: ${showUser}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
showPassword=$(cat ${dirConfig}/PASS) showPassword=$(cat ${dirConfig}/PASS)
echo "Server Password: ${showPassword}" echo "- Server Password: ${showPassword}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
showServer=$(cat ${dirConfig}/SERVER) showServer=$(cat ${dirConfig}/SERVER)
echo "URL (or IP) Server: ${showServer}" echo "- URL (or IP) Server: ${showServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
showDirServer=$(cat ${dirConfig}/DIR_SERVER) showDirServer=$(cat ${dirConfig}/DIR_SERVER)
echo "Destination Path (Server): ${showDirServer}" echo "- Destination Path (Server): ${showDirServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
showDirLocal=$(cat ${dirConfig}/DIR) showDirLocal=$(cat ${dirConfig}/DIR)
echo "Scan Path (Local): ${showDirLocal}" echo "- Scan Path (Local): ${showDirLocal}"
configAvailable=1 configAvailable=1
fi 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
echo "" echo ""
exit exit
@ -223,43 +223,43 @@ function editConfig() {
editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null) editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null)
editDirLocal=$(cat ${dirConfig}/DIR 2> /dev/null) editDirLocal=$(cat ${dirConfig}/DIR 2> /dev/null)
echo "" echo ""
echo "ks-upa (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
echo "" 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 "" echo ""
echo "6 - Exit" echo " 6 - Exit"
echo "" echo ""
echo -n "Choose an option: " ; read EDIT echo -n "* Choose an option: " ; read EDIT
echo "" echo ""
if [ "${EDIT}" == "1" ] ; then if [ "${EDIT}" == "1" ] ; then
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
elif [ "${EDIT}" == "2" ] ; then elif [ "${EDIT}" == "2" ] ; then
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
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}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
elif [ "${EDIT}" == "4" ] ; then elif [ "${EDIT}" == "4" ] ; then
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
elif [ "${EDIT}" == "5" ] ; then elif [ "${EDIT}" == "5" ] ; then
echo -n "Enter the local path to scan: " ; read DIR echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR} dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
elif [ "${EDIT}" == "6" ] ; then elif [ "${EDIT}" == "6" ] ; then
editConfig=1 editConfig=1
else else
echo "Invalid option!" echo "+ Invalid option!"
echo -n "Press ENTER to continue " ; read CONTINUE echo -n "- Press ENTER to continue " ; read CONTINUE
fi fi
done done
exit exit
@ -268,7 +268,7 @@ function editConfig() {
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
echo "ks-upa (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
exit exit
} }
@ -276,18 +276,18 @@ function showVersion() {
# Function to show help # Function to show help
function showHelp() { function showHelp() {
echo "" echo ""
echo "ks-upa (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
echo "Upload audio file(s) to server with rsync+ssh" echo "- Upload audio file(s) to server with rsync+ssh"
echo "" echo ""
echo "Sintax:" echo "+ Sintax:"
echo "" echo ""
echo "ks-upa -i - Start upload" echo " $ ks-upa -i - Start upload"
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-upa -v - Show version" echo " $ ks-upa -v - Show version"
echo "ks-upa -h - Show help" echo " $ ks-upa -h - Show help"
echo "" echo ""
exit exit
} }
@ -296,40 +296,40 @@ function showHelp() {
# for the execution are installed. # for the execution are installed.
function checkDependencies() { function checkDependencies() {
dependence=0 dependence=0
echo -n "Checking necessary tools... " echo -n "* Checking necessary tools... "
sleep 3 && echo "" sleep 3 && echo ""
sshpass -h &> /dev/null sshpass -h &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'sshpass' tool is not installed!" echo "* The 'sshpass' tool is not installed!"
dependence=1 dependence=1
fi fi
md5sum --help &> /dev/null md5sum --help &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'md5sum' tool is not installed!" echo "* The 'md5sum' tool is not installed!"
dependence=1 dependence=1
fi fi
rsync --version &> /dev/null rsync --version &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'rsync' tool is not installed!" echo "* The 'rsync' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/scp ] ; then if [ -f /usr/bin/scp ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'scp' tool is not installed!" echo "* The 'scp' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/ssh ] ; then if [ -f /usr/bin/ssh ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'ssh' tool is not installed!" echo "* The 'ssh' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ ${dependence} -eq 0 ] ; then if [ ${dependence} -eq 0 ] ; then
echo "Necessary tools installed!" echo "* Necessary tools installed!"
echo "" echo ""
else else
echo "" echo ""
@ -371,14 +371,14 @@ elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear clear
echo "" echo ""
echo "ks-upa (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upa (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}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
user=$(cat ${dirConfig}/USER) user=$(cat ${dirConfig}/USER)
else else
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
fi fi
@ -386,7 +386,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
password=$(cat ${dirConfig}/PASS) password=$(cat ${dirConfig}/PASS)
else else
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
fi fi
@ -394,7 +394,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
server=$(cat ${dirConfig}/SERVER) server=$(cat ${dirConfig}/SERVER)
else else
echo -n "Enter the server URL: " ; read SERVER echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER} server=${SERVER}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
fi fi
@ -402,7 +402,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
dirServer=$(cat ${dirConfig}/DIR_SERVER) dirServer=$(cat ${dirConfig}/DIR_SERVER)
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
fi fi
@ -410,19 +410,19 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
dirLocal=$(cat ${dirConfig}/DIR) dirLocal=$(cat ${dirConfig}/DIR)
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}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
fi fi
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
echo -n "Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
if [ -d ${dirLocal} ] ; then if [ -d ${dirLocal} ] ; then
listArchives "${dirLocal}" listArchives "${dirLocal}"
totalFiles=$(countArchives) totalFiles=$(countArchives)
count=1 count=1
echo "${totalFiles} audio file(s) found!" echo "+ ${totalFiles} audio file(s) found!"
echo "" echo ""
while [ ${count} -le ${totalFiles} ] ; do while [ ${count} -le ${totalFiles} ] ; do
fullNameFile=$(showFile ${count}) fullNameFile=$(showFile ${count})
@ -434,7 +434,7 @@ elif [ "$1" == "-i" ] ; then
count=$(expr ${count} + 1) count=$(expr ${count} + 1)
done done
else else
echo "Directory ${dirLocal} does not exist!" echo "* Directory ${dirLocal} does not exist!"
echo "" echo ""
exit exit
fi fi

View File

@ -92,13 +92,13 @@ function listArchives() {
echo "null" > /dev/null echo "null" > /dev/null
else else
find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp} find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp}
echo "File(s) in .${format} format found!" echo "+ File(s) in .${format} format found!"
cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp} cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp}
fail=0 fail=0
fi fi
done done
if [ ${fail} -eq 1 ] ; then if [ ${fail} -eq 1 ] ; then
echo "No common file(s) found!" echo "+ No common file(s) found!"
echo "" echo ""
exit exit
else else
@ -196,35 +196,35 @@ function checkChecksum() {
function showConfig() { function showConfig() {
configAvailable=0 configAvailable=0
echo "" echo ""
echo "ks-upf (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
if [ -f ${dirConfig}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
showUser=$(cat ${dirConfig}/USER) showUser=$(cat ${dirConfig}/USER)
echo "Server User: ${showUser}" echo "- Server User: ${showUser}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
showPassword=$(cat ${dirConfig}/PASS) showPassword=$(cat ${dirConfig}/PASS)
echo "Server Password: ${showPassword}" echo "- Server Password: ${showPassword}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
showServer=$(cat ${dirConfig}/SERVER) showServer=$(cat ${dirConfig}/SERVER)
echo "URL (or IP) Server: ${showServer}" echo "- URL (or IP) Server: ${showServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
showDirServer=$(cat ${dirConfig}/DIR_SERVER) showDirServer=$(cat ${dirConfig}/DIR_SERVER)
echo "Destination Path (Server): ${showDirServer}" echo "- Destination Path (Server): ${showDirServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
showDirLocal=$(cat ${dirConfig}/DIR) showDirLocal=$(cat ${dirConfig}/DIR)
echo "Scan Path (Local): ${showDirLocal}" echo "- Scan Path (Local): ${showDirLocal}"
configAvailable=1 configAvailable=1
fi 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
echo "" echo ""
exit exit
@ -241,43 +241,43 @@ function editConfig() {
editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null) editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null)
editDirLocal=$(cat ${dirConfig}/DIR 2> /dev/null) editDirLocal=$(cat ${dirConfig}/DIR 2> /dev/null)
echo "" echo ""
echo "ks-upf (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
echo "" 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 "" echo ""
echo "6 - Exit" echo " 6 - Exit"
echo "" echo ""
echo -n "Choose an option: " ; read EDIT echo -n "* Choose an option: " ; read EDIT
echo "" echo ""
if [ "${EDIT}" == "1" ] ; then if [ "${EDIT}" == "1" ] ; then
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
elif [ "${EDIT}" == "2" ] ; then elif [ "${EDIT}" == "2" ] ; then
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
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}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
elif [ "${EDIT}" == "4" ] ; then elif [ "${EDIT}" == "4" ] ; then
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
elif [ "${EDIT}" == "5" ] ; then elif [ "${EDIT}" == "5" ] ; then
echo -n "Enter the local path to scan: " ; read DIR echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR} dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
elif [ "${EDIT}" == "6" ] ; then elif [ "${EDIT}" == "6" ] ; then
editConfig=1 editConfig=1
else else
echo "Invalid option!" echo "+ Invalid option!"
echo -n "Press ENTER to continue " ; read CONTINUE echo -n "- Press ENTER to continue " ; read CONTINUE
fi fi
done done
exit exit
@ -286,7 +286,7 @@ function editConfig() {
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
echo "ks-upf (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
exit exit
} }
@ -294,18 +294,18 @@ function showVersion() {
# Function to show help # Function to show help
function showHelp() { function showHelp() {
echo "" echo ""
echo "ks-upf (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
echo "Upload common file(s) to server with rsync+ssh" echo "- Upload common file(s) to server with rsync+ssh"
echo "" echo ""
echo "Sintax:" echo "+ Sintax:"
echo "" echo ""
echo "ks-upf -i - Start upload" echo " $ ks-upf -i - Start upload"
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-upf -v - Show version" echo " $ ks-upf -v - Show version"
echo "ks-upf -h - Show help" echo " $ ks-upf -h - Show help"
echo "" echo ""
exit exit
} }
@ -314,40 +314,40 @@ function showHelp() {
# for the execution are installed. # for the execution are installed.
function checkDependencies() { function checkDependencies() {
dependence=0 dependence=0
echo -n "Checking necessary tools... " echo -n "* Checking necessary tools... "
sleep 3 && echo "" sleep 3 && echo ""
sshpass -h &> /dev/null sshpass -h &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'sshpass' tool is not installed!" echo "* The 'sshpass' tool is not installed!"
dependence=1 dependence=1
fi fi
md5sum --help &> /dev/null md5sum --help &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'md5sum' tool is not installed!" echo "* The 'md5sum' tool is not installed!"
dependence=1 dependence=1
fi fi
rsync --version &> /dev/null rsync --version &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'rsync' tool is not installed!" echo "* The 'rsync' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/scp ] ; then if [ -f /usr/bin/scp ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'scp' tool is not installed!" echo "* The 'scp' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/ssh ] ; then if [ -f /usr/bin/ssh ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'ssh' tool is not installed!" echo "* The 'ssh' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ ${dependence} -eq 0 ] ; then if [ ${dependence} -eq 0 ] ; then
echo "Necessary tools installed!" echo "* Necessary tools installed!"
echo "" echo ""
else else
echo "" echo ""
@ -389,14 +389,14 @@ elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear clear
echo "" echo ""
echo "ks-upf (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upf (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}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
user=$(cat ${dirConfig}/USER) user=$(cat ${dirConfig}/USER)
else else
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
fi fi
@ -404,7 +404,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
password=$(cat ${dirConfig}/PASS) password=$(cat ${dirConfig}/PASS)
else else
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
fi fi
@ -412,7 +412,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
server=$(cat ${dirConfig}/SERVER) server=$(cat ${dirConfig}/SERVER)
else else
echo -n "Enter the server URL: " ; read SERVER echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER} server=${SERVER}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
fi fi
@ -420,7 +420,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
dirServer=$(cat ${dirConfig}/DIR_SERVER) dirServer=$(cat ${dirConfig}/DIR_SERVER)
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
fi fi
@ -428,19 +428,19 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
dirLocal=$(cat ${dirConfig}/DIR) dirLocal=$(cat ${dirConfig}/DIR)
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}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
fi fi
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
echo -n "Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
if [ -d ${dirLocal} ] ; then if [ -d ${dirLocal} ] ; then
listArchives "${dirLocal}" listArchives "${dirLocal}"
totalFiles=$(countArchives) totalFiles=$(countArchives)
count=1 count=1
echo "${totalFiles} common file(s) found!" echo "+ ${totalFiles} common file(s) found!"
echo "" echo ""
while [ ${count} -le ${totalFiles} ] ; do while [ ${count} -le ${totalFiles} ] ; do
fullNameFile=$(showFile ${count}) fullNameFile=$(showFile ${count})
@ -452,7 +452,7 @@ elif [ "$1" == "-i" ] ; then
count=$(expr ${count} + 1) count=$(expr ${count} + 1)
done done
else else
echo "Directory ${dirLocal} does not exist!" echo "* Directory ${dirLocal} does not exist!"
echo "" echo ""
exit exit
fi fi

View File

@ -92,13 +92,13 @@ function listArchives() {
echo "null" > /dev/null echo "null" > /dev/null
else else
find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp} find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp}
echo "File(s) in .${format} format found!" echo "+ File(s) in .${format} format found!"
cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp} cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp}
fail=0 fail=0
fi fi
done done
if [ ${fail} -eq 1 ] ; then if [ ${fail} -eq 1 ] ; then
echo "No common file(s) found!" echo "+ No common file(s) found!"
echo "" echo ""
exit exit
else else
@ -152,35 +152,35 @@ function sendFile() {
function showConfig() { function showConfig() {
configAvailable=0 configAvailable=0
echo "" echo ""
echo "ks-upr (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
if [ -f ${dirConfig}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
showUser=$(cat ${dirConfig}/USER) showUser=$(cat ${dirConfig}/USER)
echo "Server User: ${showUser}" echo "- Server User: ${showUser}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
showPassword=$(cat ${dirConfig}/PASS) showPassword=$(cat ${dirConfig}/PASS)
echo "Server Password: ${showPassword}" echo "- Server Password: ${showPassword}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
showServer=$(cat ${dirConfig}/SERVER) showServer=$(cat ${dirConfig}/SERVER)
echo "URL (or IP) Server: ${showServer}" echo "- URL (or IP) Server: ${showServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
showDirServer=$(cat ${dirConfig}/DIR_SERVER) showDirServer=$(cat ${dirConfig}/DIR_SERVER)
echo "Destination Path (Server): ${showDirServer}" echo "- Destination Path (Server): ${showDirServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
showDirLocal=$(cat ${dirConfig}/DIR) showDirLocal=$(cat ${dirConfig}/DIR)
echo "Scan Path (Local): ${showDirLocal}" echo "- Scan Path (Local): ${showDirLocal}"
configAvailable=1 configAvailable=1
fi 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
echo "" echo ""
exit exit
@ -197,43 +197,43 @@ function editConfig() {
editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null) editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null)
editDirLocal=$(cat ${dirConfig}/DIR 2> /dev/null) editDirLocal=$(cat ${dirConfig}/DIR 2> /dev/null)
echo "" echo ""
echo "ks-upr (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
echo "" 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 "" echo ""
echo "6 - Exit" echo " 6 - Exit"
echo "" echo ""
echo -n "Choose an option: " ; read EDIT echo -n "* Choose an option: " ; read EDIT
echo "" echo ""
if [ "${EDIT}" == "1" ] ; then if [ "${EDIT}" == "1" ] ; then
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
elif [ "${EDIT}" == "2" ] ; then elif [ "${EDIT}" == "2" ] ; then
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
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}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
elif [ "${EDIT}" == "4" ] ; then elif [ "${EDIT}" == "4" ] ; then
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
elif [ "${EDIT}" == "5" ] ; then elif [ "${EDIT}" == "5" ] ; then
echo -n "Enter the local path to scan: " ; read DIR echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR} dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
elif [ "${EDIT}" == "6" ] ; then elif [ "${EDIT}" == "6" ] ; then
editConfig=1 editConfig=1
else else
echo "Invalid option!" echo "+ Invalid option!"
echo -n "Press ENTER to continue " ; read CONTINUE echo -n "- Press ENTER to continue " ; read CONTINUE
fi fi
done done
exit exit
@ -242,7 +242,7 @@ function editConfig() {
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
echo "ks-upr (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
exit exit
} }
@ -250,18 +250,18 @@ function showVersion() {
# Function to show help # Function to show help
function showHelp() { function showHelp() {
echo "" echo ""
echo "ks-upr (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
echo "Upload recursively file(s) to server with rsync+ssh" echo "- Upload recursively file(s) to server with rsync+ssh"
echo "" echo ""
echo "Sintax:" echo "+ Sintax:"
echo "" echo ""
echo "ks-upf -i - Start upload" echo " $ ks-upf -i - Start upload"
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-upf -v - Show version" echo " $ ks-upf -v - Show version"
echo "ks-upf -h - Show help" echo " $ ks-upf -h - Show help"
echo "" echo ""
exit exit
} }
@ -270,40 +270,40 @@ function showHelp() {
# for the execution are installed. # for the execution are installed.
function checkDependencies() { function checkDependencies() {
dependence=0 dependence=0
echo -n "Checking necessary tools... " echo -n "* Checking necessary tools... "
sleep 3 && echo "" sleep 3 && echo ""
sshpass -h &> /dev/null sshpass -h &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'sshpass' tool is not installed!" echo "* The 'sshpass' tool is not installed!"
dependence=1 dependence=1
fi fi
md5sum --help &> /dev/null md5sum --help &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'md5sum' tool is not installed!" echo "* The 'md5sum' tool is not installed!"
dependence=1 dependence=1
fi fi
rsync --version &> /dev/null rsync --version &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'rsync' tool is not installed!" echo "* The 'rsync' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/scp ] ; then if [ -f /usr/bin/scp ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'scp' tool is not installed!" echo "* The 'scp' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/ssh ] ; then if [ -f /usr/bin/ssh ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'ssh' tool is not installed!" echo "* The 'ssh' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ ${dependence} -eq 0 ] ; then if [ ${dependence} -eq 0 ] ; then
echo "Necessary tools installed!" echo "* Necessary tools installed!"
echo "" echo ""
else else
echo "" echo ""
@ -345,14 +345,14 @@ elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear clear
echo "" echo ""
echo "ks-upr (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upr (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}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
user=$(cat ${dirConfig}/USER) user=$(cat ${dirConfig}/USER)
else else
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
fi fi
@ -360,7 +360,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
password=$(cat ${dirConfig}/PASS) password=$(cat ${dirConfig}/PASS)
else else
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
fi fi
@ -368,7 +368,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
server=$(cat ${dirConfig}/SERVER) server=$(cat ${dirConfig}/SERVER)
else else
echo -n "Enter the server URL: " ; read SERVER echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER} server=${SERVER}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
fi fi
@ -376,7 +376,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
dirServer=$(cat ${dirConfig}/DIR_SERVER) dirServer=$(cat ${dirConfig}/DIR_SERVER)
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
fi fi
@ -384,20 +384,20 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
dirLocal=$(cat ${dirConfig}/DIR) dirLocal=$(cat ${dirConfig}/DIR)
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}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
fi fi
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
echo -n "Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
if [ -d ${dirLocal} ] ; then if [ -d ${dirLocal} ] ; then
sendFile ${password} "${dirLocal}" ${user} ${server} ${dirServer} sendFile ${password} "${dirLocal}" ${user} ${server} ${dirServer}
echo "" echo ""
count=$(expr ${count} + 1) count=$(expr ${count} + 1)
else else
echo "Directory ${dirLocal} does not exist!" echo "* Directory ${dirLocal} does not exist!"
echo "" echo ""
exit exit
fi fi

View File

@ -74,13 +74,13 @@ function listArchives() {
echo "null" > /dev/null echo "null" > /dev/null
else else
find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp} find "${1}"/*.${format} &>> ${dirTemp}/${listCompTemp}
echo "Video file(s) in .${format} found!" echo "+ Video file(s) in .${format} found!"
cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp} cd "${1}" && ls -1 *.${format} &>> ${dirTemp}/${listTemp}
fail=0 fail=0
fi fi
done done
if [ ${fail} -eq 1 ] ; then if [ ${fail} -eq 1 ] ; then
echo "No video file(s) found!" echo "+ No video file(s) found!"
echo "" echo ""
exit exit
else else
@ -178,35 +178,35 @@ function checkChecksum() {
function showConfig() { function showConfig() {
configAvailable=0 configAvailable=0
echo "" echo ""
echo "ks-upv (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
if [ -f ${dirConfig}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
showUser=$(cat ${dirConfig}/USER) showUser=$(cat ${dirConfig}/USER)
echo "Server User: ${showUser}" echo "- Server User: ${showUser}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
showPassword=$(cat ${dirConfig}/PASS) showPassword=$(cat ${dirConfig}/PASS)
echo "Server Password: ${showPassword}" echo "- Server Password: ${showPassword}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
showServer=$(cat ${dirConfig}/SERVER) showServer=$(cat ${dirConfig}/SERVER)
echo "URL (or IP) Server: ${showServer}" echo "- URL (or IP) Server: ${showServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
showDirServer=$(cat ${dirConfig}/DIR_SERVER) showDirServer=$(cat ${dirConfig}/DIR_SERVER)
echo "Destination Path (Server): ${showDirServer}" echo "- Destination Path (Server): ${showDirServer}"
configAvailable=1 configAvailable=1
fi fi
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
showDirLocal=$(cat ${dirConfig}/DIR) showDirLocal=$(cat ${dirConfig}/DIR)
echo "Scan Path (Local): ${showDirLocal}" echo "- Scan Path (Local): ${showDirLocal}"
configAvailable=1 configAvailable=1
fi 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
echo "" echo ""
exit exit
@ -223,43 +223,43 @@ function editConfig() {
editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null) editDirServer=$(cat ${dirConfig}/DIR_SERVER 2> /dev/null)
editDirLocal=$(cat ${dirConfig}/DIR 2> /dev/null) editDirLocal=$(cat ${dirConfig}/DIR 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 "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 "" echo ""
echo "6 - Exit" echo " 6 - Exit"
echo "" echo ""
echo -n "Choose an option: " ; read EDIT echo -n "* Choose an option: " ; read EDIT
echo "" echo ""
if [ "${EDIT}" == "1" ] ; then if [ "${EDIT}" == "1" ] ; then
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
elif [ "${EDIT}" == "2" ] ; then elif [ "${EDIT}" == "2" ] ; then
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
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}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
elif [ "${EDIT}" == "4" ] ; then elif [ "${EDIT}" == "4" ] ; then
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
elif [ "${EDIT}" == "5" ] ; then elif [ "${EDIT}" == "5" ] ; then
echo -n "Enter the local path to scan: " ; read DIR echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR} dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
elif [ "${EDIT}" == "6" ] ; then elif [ "${EDIT}" == "6" ] ; then
editConfig=1 editConfig=1
else else
echo "Invalid option!" echo "+ Invalid option!"
echo -n "Press ENTER to continue " ; read CONTINUE echo -n "- Press ENTER to continue " ; read CONTINUE
fi fi
done done
exit exit
@ -268,7 +268,7 @@ function editConfig() {
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
echo "ks-upv (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
exit exit
} }
@ -276,18 +276,18 @@ function showVersion() {
# Function to show help # Function to show help
function showHelp() { function showHelp() {
echo "" echo ""
echo "ks-upv (ks-tools) v${VERSION} (${M_DATE})" echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
echo "" echo ""
echo "Upload videos file(s) to server with rynsc+ssh" echo "- Upload videos file(s) to server with rynsc+ssh"
echo "" echo ""
echo "Sintax:" echo "+ Sintax:"
echo "" echo ""
echo "ks-upv -i - Start upload" echo " $ ks-upv -i - Start upload"
echo "ks-upv -r - Remove configuration" echo " $ ks-upv -r - Remove configuration"
echo "ks-upv -c - Show configuration" echo " $ ks-upv -c - Show configuration"
echo "ks-upv -e - Edit configuration" echo " $ ks-upv -e - Edit configuration"
echo "ks-upv -v - Show version" echo " $ ks-upv -v - Show version"
echo "ks-upv -h - Show help" echo " $ ks-upv -h - Show help"
echo "" echo ""
exit exit
} }
@ -296,40 +296,40 @@ function showHelp() {
# for the execution are installed. # for the execution are installed.
function checkDependencies() { function checkDependencies() {
dependence=0 dependence=0
echo -n "Checking necessary tools... " echo -n "* Checking necessary tools... "
sleep 3 && echo "" sleep 3 && echo ""
sshpass -h &> /dev/null sshpass -h &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'sshpass' tool is not installed!" echo "* The 'sshpass' tool is not installed!"
dependence=1 dependence=1
fi fi
md5sum --help &> /dev/null md5sum --help &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'md5sum' tool is not installed!" echo "* The 'md5sum' tool is not installed!"
dependence=1 dependence=1
fi fi
rsync --version &> /dev/null rsync --version &> /dev/null
OUTPUT=$? OUTPUT=$?
if [ ${OUTPUT} -ne 0 ] ; then if [ ${OUTPUT} -ne 0 ] ; then
echo "The 'rsync' tool is not installed!" echo "* The 'rsync' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/scp ] ; then if [ -f /usr/bin/scp ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'scp' tool is not installed!" echo "* The 'scp' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ -f /usr/bin/ssh ] ; then if [ -f /usr/bin/ssh ] ; then
echo "OK" > /dev/null echo "OK" > /dev/null
else else
echo "The 'ssh' tool is not installed!" echo "* The 'ssh' tool is not installed!"
dependence=1 dependence=1
fi fi
if [ ${dependence} -eq 0 ] ; then if [ ${dependence} -eq 0 ] ; then
echo "Necessary tools installed!" echo "* Necessary tools installed!"
echo "" echo ""
else else
echo "" echo ""
@ -371,14 +371,14 @@ elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear clear
echo "" echo ""
echo "ks-upv (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}/USER ] ; then if [ -f ${dirConfig}/USER ] ; then
user=$(cat ${dirConfig}/USER) user=$(cat ${dirConfig}/USER)
else else
echo -n "Enter the server user: " ; read USER echo -n "* Enter the server user: " ; read USER
user=${USER} user=${USER}
echo ${user} > ${dirConfig}/USER echo ${user} > ${dirConfig}/USER
fi fi
@ -386,7 +386,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/PASS ] ; then if [ -f ${dirConfig}/PASS ] ; then
password=$(cat ${dirConfig}/PASS) password=$(cat ${dirConfig}/PASS)
else else
echo -n "Enter the server key: " ; read PASS echo -n "* Enter the server key: " ; read PASS
password=${PASS} password=${PASS}
echo ${password} > ${dirConfig}/PASS echo ${password} > ${dirConfig}/PASS
fi fi
@ -394,7 +394,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/SERVER ] ; then if [ -f ${dirConfig}/SERVER ] ; then
server=$(cat ${dirConfig}/SERVER) server=$(cat ${dirConfig}/SERVER)
else else
echo -n "Enter the server URL: " ; read SERVER echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER} server=${SERVER}
echo ${server} > ${dirConfig}/SERVER echo ${server} > ${dirConfig}/SERVER
fi fi
@ -402,7 +402,7 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR_SERVER ] ; then if [ -f ${dirConfig}/DIR_SERVER ] ; then
dirServer=$(cat ${dirConfig}/DIR_SERVER) dirServer=$(cat ${dirConfig}/DIR_SERVER)
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}
echo ${dirServer} > ${dirConfig}/DIR_SERVER echo ${dirServer} > ${dirConfig}/DIR_SERVER
fi fi
@ -410,19 +410,19 @@ elif [ "$1" == "-i" ] ; then
if [ -f ${dirConfig}/DIR ] ; then if [ -f ${dirConfig}/DIR ] ; then
dirLocal=$(cat ${dirConfig}/DIR) dirLocal=$(cat ${dirConfig}/DIR)
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}
echo ${dirLocal} > ${dirConfig}/DIR echo ${dirLocal} > ${dirConfig}/DIR
fi fi
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
echo -n "Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
if [ -d ${dirLocal} ] ; then if [ -d ${dirLocal} ] ; then
listArchives "${dirLocal}" listArchives "${dirLocal}"
totalFiles=$(countArchives) totalFiles=$(countArchives)
count=1 count=1
echo "${totalFiles} video file(s) found!" echo "+ ${totalFiles} video file(s) found!"
echo "" echo ""
while [ ${count} -le ${totalFiles} ] ; do while [ ${count} -le ${totalFiles} ] ; do
fullNameFile=$(showFile ${count}) fullNameFile=$(showFile ${count})
@ -434,7 +434,7 @@ elif [ "$1" == "-i" ] ; then
count=$(expr ${count} + 1) count=$(expr ${count} + 1)
done done
else else
echo "Directory ${dirLocal} does not exist!" echo "* Directory ${dirLocal} does not exist!"
echo "" echo ""
exit exit
fi fi