Add option for create configuration without upload directly

This commit is contained in:
q3aql 2022-01-04 11:58:24 +01:00
parent 90c373df23
commit 7910ba6dc9
4 changed files with 255 additions and 198 deletions

View File

@ -366,6 +366,58 @@ function editConfig() {
exit exit
} }
# Function to create initial config file.
function createConfig() {
# Start script
clear
echo ""
echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
echo ""
checkDependencies
# Ask the user and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-user ] ; then
echo "+ The USER configuration already exists (Use: 'ks-upa -e' for edit)"
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
echo "+ The PASSWORD configuration already exists (Use: 'ks-upa -e' for edit)"
else
echo -n "* Enter the server password: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
echo "+ The SERVER configuration already exists (Use: 'ks-upa -e' for edit)"
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
echo "+ The SERVER PATH configuration already exists (Use: 'ks-upa -e' for edit)"
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
echo "+ The LOCAL PATH configuration already exists (Use: 'ks-upa -e' for edit)"
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
fi
echo ""
}
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
@ -384,6 +436,7 @@ function showHelp() {
echo "+ Syntax:" echo "+ Syntax:"
echo "" echo ""
echo " $ ks-upa -i - Start upload" echo " $ ks-upa -i - Start upload"
echo " $ ks-upa -g - Create configuration"
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"
@ -500,57 +553,18 @@ elif [ "$1" == "-v" ] ; then
# Show the help # Show the help
elif [ "$1" == "-h" ] ; then elif [ "$1" == "-h" ] ; then
showHelp showHelp
elif [ "$1" == "-g" ] ; then
createConfig
# Init # Init
elif [ "$1" == "-i" ] ; then elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear createConfig
echo "" user=$(cat ${dirConfig}/ks-upload-user)
echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})" raw_password=$(cat ${dirConfig}/ks-upload-pass)
echo "" password=$(decrypt_kstools "${raw_password}")
checkDependencies server=$(cat ${dirConfig}/ks-upload-server)
# Ask the user and if it exists, read it from the config. dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
if [ -f ${dirConfig}/ks-upload-user ] ; then dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
user=$(cat ${dirConfig}/ks-upload-user)
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
raw_password=$(cat ${dirConfig}/ks-upload-pass)
password=$(decrypt_kstools "${raw_password}")
else
echo -n "* Enter the server key: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
server=$(cat ${dirConfig}/ks-upload-server)
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
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 ""

View File

@ -384,6 +384,58 @@ function editConfig() {
exit exit
} }
# Function to create initial config file.
function createConfig() {
# Start script
clear
echo ""
echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
echo ""
checkDependencies
# Ask the user and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-user ] ; then
echo "+ The USER configuration already exists (Use: 'ks-upf -e' for edit)"
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
echo "+ The PASSWORD configuration already exists (Use: 'ks-upf -e' for edit)"
else
echo -n "* Enter the server password: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
echo "+ The SERVER configuration already exists (Use: 'ks-upf -e' for edit)"
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
echo "+ The SERVER PATH configuration already exists (Use: 'ks-upf -e' for edit)"
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
echo "+ The LOCAL PATH configuration already exists (Use: 'ks-upf -e' for edit)"
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
fi
echo ""
}
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
@ -402,6 +454,7 @@ function showHelp() {
echo "+ Syntax:" echo "+ Syntax:"
echo "" echo ""
echo " $ ks-upf -i - Start upload" echo " $ ks-upf -i - Start upload"
echo " $ ks-upf -g - Create configuration"
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"
@ -518,57 +571,18 @@ elif [ "$1" == "-v" ] ; then
# Show the help # Show the help
elif [ "$1" == "-h" ] ; then elif [ "$1" == "-h" ] ; then
showHelp showHelp
elif [ "$1" == "-g" ] ; then
createConfig
# Init # Init
elif [ "$1" == "-i" ] ; then elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear createConfig
echo "" user=$(cat ${dirConfig}/ks-upload-user)
echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})" raw_password=$(cat ${dirConfig}/ks-upload-pass)
echo "" password=$(decrypt_kstools "${raw_password}")
checkDependencies server=$(cat ${dirConfig}/ks-upload-server)
# Ask the user and if it exists, read it from the config. dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
if [ -f ${dirConfig}/ks-upload-user ] ; then dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
user=$(cat ${dirConfig}/ks-upload-user)
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
raw_password=$(cat ${dirConfig}/ks-upload-pass)
password=$(decrypt_kstools "${raw_password}")
else
echo -n "* Enter the server key: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
server=$(cat ${dirConfig}/ks-upload-server)
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
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 ""

View File

@ -326,6 +326,58 @@ function editConfig() {
exit exit
} }
# Function to create initial config file.
function createConfig() {
# Start script
clear
echo ""
echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
echo ""
checkDependencies
# Ask the user and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-user ] ; then
echo "+ The USER configuration already exists (Use: 'ks-upr -e' for edit)"
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
echo "+ The PASSWORD configuration already exists (Use: 'ks-upr -e' for edit)"
else
echo -n "* Enter the server password: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
echo "+ The SERVER configuration already exists (Use: 'ks-upr -e' for edit)"
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
echo "+ The SERVER PATH configuration already exists (Use: 'ks-upr -e' for edit)"
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
echo "+ The LOCAL PATH configuration already exists (Use: 'ks-upr -e' for edit)"
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
fi
echo ""
}
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
@ -343,12 +395,13 @@ function showHelp() {
echo "" echo ""
echo "+ Syntax:" echo "+ Syntax:"
echo "" echo ""
echo " $ ks-upf -i - Start upload" echo " $ ks-upr -i - Start upload"
echo " $ ks-upf -r - Remove configuration" echo " $ ks-upr -g - Create configuration"
echo " $ ks-upf -c - Show configuration" echo " $ ks-upr -r - Remove configuration"
echo " $ ks-upf -e - Edit configuration" echo " $ ks-upr -c - Show configuration"
echo " $ ks-upf -v - Show version" echo " $ ks-upr -e - Edit configuration"
echo " $ ks-upf -h - Show help" echo " $ ks-upr -v - Show version"
echo " $ ks-upr -h - Show help"
echo "" echo ""
exit exit
} }
@ -460,57 +513,18 @@ elif [ "$1" == "-v" ] ; then
# Show the help # Show the help
elif [ "$1" == "-h" ] ; then elif [ "$1" == "-h" ] ; then
showHelp showHelp
elif [ "$1" == "-g" ] ; then
createConfig
# Init # Init
elif [ "$1" == "-i" ] ; then elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear createConfig
echo "" user=$(cat ${dirConfig}/ks-upload-user)
echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})" raw_password=$(cat ${dirConfig}/ks-upload-pass)
echo "" password=$(decrypt_kstools "${raw_password}")
checkDependencies server=$(cat ${dirConfig}/ks-upload-server)
# Ask the user and if it exists, read it from the config. dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
if [ -f ${dirConfig}/ks-upload-user ] ; then dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
user=$(cat ${dirConfig}/ks-upload-user)
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
raw_password=$(cat ${dirConfig}/ks-upload-pass)
password=$(decrypt_kstools "${raw_password}")
else
echo -n "* Enter the server key: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
server=$(cat ${dirConfig}/ks-upload-server)
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
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 ""

View File

@ -367,6 +367,58 @@ function editConfig() {
exit exit
} }
# Function to create initial config file.
function createConfig() {
# Start script
clear
echo ""
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
echo ""
checkDependencies
# Ask the user and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-user ] ; then
echo "+ The USER configuration already exists (Use: 'ks-upv -e' for edit)"
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
echo "+ The PASSWORD configuration already exists (Use: 'ks-upv -e' for edit)"
else
echo -n "* Enter the server password: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
echo "+ The SERVER configuration already exists (Use: 'ks-upv -e' for edit)"
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
echo "+ The SERVER PATH configuration already exists (Use: 'ks-upv -e' for edit)"
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
echo "+ The LOCAL PATH configuration already exists (Use: 'ks-upv -e' for edit)"
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
fi
echo ""
}
# Function to show version # Function to show version
function showVersion() { function showVersion() {
echo "" echo ""
@ -385,6 +437,7 @@ function showHelp() {
echo "+ Syntax:" echo "+ Syntax:"
echo "" echo ""
echo " $ ks-upv -i - Start upload" echo " $ ks-upv -i - Start upload"
echo " $ ks-upv -g - Create configuration"
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"
@ -501,57 +554,19 @@ elif [ "$1" == "-v" ] ; then
# Show the help # Show the help
elif [ "$1" == "-h" ] ; then elif [ "$1" == "-h" ] ; then
showHelp showHelp
# Create config
elif [ "$1" == "-g" ] ; then
createConfig
# Init # Init
elif [ "$1" == "-i" ] ; then elif [ "$1" == "-i" ] ; then
# Start script # Start script
clear createConfig
echo "" user=$(cat ${dirConfig}/ks-upload-user)
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})" raw_password=$(cat ${dirConfig}/ks-upload-pass)
echo "" password=$(decrypt_kstools "${raw_password}")
checkDependencies server=$(cat ${dirConfig}/ks-upload-server)
# Ask the user and if it exists, read it from the config. dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
if [ -f ${dirConfig}/ks-upload-user ] ; then dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
user=$(cat ${dirConfig}/ks-upload-user)
else
echo -n "* Enter the server user: " ; read USER
user=${USER}
echo ${user} > ${dirConfig}/ks-upload-user
fi
# Ask the password and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-pass ] ; then
raw_password=$(cat ${dirConfig}/ks-upload-pass)
password=$(decrypt_kstools "${raw_password}")
else
echo -n "* Enter the server key: " ; read PASS
raw_password_enter=${PASS}
encrypt_password_enter=$(encrypt_kstools "${raw_password_enter}")
echo ${encrypt_password_enter} > ${dirConfig}/ks-upload-pass
fi
# Ask the server URL and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-server ] ; then
server=$(cat ${dirConfig}/ks-upload-server)
else
echo -n "* Enter the server URL: " ; read SERVER
server=${SERVER}
echo ${server} > ${dirConfig}/ks-upload-server
fi
# Ask the path on the server and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirserver ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
else
echo -n "* Enter the path on the server: " ; read DIR_SERVER
dirServer=${DIR_SERVER}
echo ${dirServer} > ${dirConfig}/ks-upload-dirserver
fi
# Ask the local path and if it exists, read it from the config.
if [ -f ${dirConfig}/ks-upload-dirlocal ] ; then
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
else
echo -n "* Enter the local path to scan: " ; read DIR
dirLocal=${DIR}
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
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 ""