From 3c1196195176e84c6f506632b8979cea6ee3a05b Mon Sep 17 00:00:00 2001 From: q3aql Date: Mon, 3 Jan 2022 19:31:11 +0100 Subject: [PATCH] Check and migrate old configuration --- src/ks-upa | 35 ++++++++++++++++++++++++++++++++++- src/ks-upf | 35 ++++++++++++++++++++++++++++++++++- src/ks-upr | 35 ++++++++++++++++++++++++++++++++++- src/ks-upv | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 3 deletions(-) diff --git a/src/ks-upa b/src/ks-upa index 59681ce..b2e6acf 100755 --- a/src/ks-upa +++ b/src/ks-upa @@ -14,7 +14,7 @@ dirTemp="/tmp" listCompTemp="ks-tools.list-full" listCompTempTest="ks-tools.list-full.test" listTemp="ks-tools.list" -dirConfig="$HOME/.ks-tools" +dirConfig="${HOME}/.ks-tools" ksToolsTempFolder="/tmp/ks-tools" # Check cygwin alias (for Windows) @@ -438,6 +438,39 @@ function checkDependencies() { fi } +# Function to migrate old configuration. +if [ -f ${dirConfig}/USER ] ; then + cat ${dirConfig}/USER > ${dirConfig}/ks-upload-user + echo "* Migrating ${dirConfig}/USER > ${dirConfig}/ks-upload-user" + rm -rf ${dirConfig}/USER + sleep 1 +fi +if [ -f ${dirConfig}/PASS ] ; then + echo "* Migrating ${dirConfig}/PASS > ${dirConfig}/ks-upload-pass" + current_pass=$(cat ${dirConfig}/PASS) + encrypt_kstools "${current_pass}" > ${dirConfig}/ks-upload-pass + rm -rf ${dirConfig}/PASS + sleep 1 +fi +if [ -f ${dirConfig}/SERVER ] ; then + cat ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server + echo "* Migrating ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server" + rm -rf ${dirConfig}/SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR_SERVER ] ; then + cat ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver + echo "* Migrating ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver" + rm -rf ${dirConfig}/DIR_SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR ] ; then + cat ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal + echo "* Migrating ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal" + rm -rf ${dirConfig}/DIR + sleep 1 +fi + # Check if the configuration directory exists. if [ -d ${dirConfig} ] ; then echo ${dirConfig} > /dev/null diff --git a/src/ks-upf b/src/ks-upf index 6c52f6e..5b9cd69 100755 --- a/src/ks-upf +++ b/src/ks-upf @@ -14,7 +14,7 @@ dirTemp="/tmp" listCompTemp="ks-tools.list-full" listCompTempTest="ks-tools.list-full.test" listTemp="ks-tools.list" -dirConfig="$HOME/.ks-tools" +dirConfig="${HOME}/.ks-tools" ksToolsTempFolder="/tmp/ks-tools" # Check cygwin alias (for Windows) @@ -456,6 +456,39 @@ function checkDependencies() { fi } +# Function to migrate old configuration. +if [ -f ${dirConfig}/USER ] ; then + cat ${dirConfig}/USER > ${dirConfig}/ks-upload-user + echo "* Migrating ${dirConfig}/USER > ${dirConfig}/ks-upload-user" + rm -rf ${dirConfig}/USER + sleep 1 +fi +if [ -f ${dirConfig}/PASS ] ; then + echo "* Migrating ${dirConfig}/PASS > ${dirConfig}/ks-upload-pass" + current_pass=$(cat ${dirConfig}/PASS) + encrypt_kstools "${current_pass}" > ${dirConfig}/ks-upload-pass + rm -rf ${dirConfig}/PASS + sleep 1 +fi +if [ -f ${dirConfig}/SERVER ] ; then + cat ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server + echo "* Migrating ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server" + rm -rf ${dirConfig}/SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR_SERVER ] ; then + cat ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver + echo "* Migrating ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver" + rm -rf ${dirConfig}/DIR_SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR ] ; then + cat ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal + echo "* Migrating ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal" + rm -rf ${dirConfig}/DIR + sleep 1 +fi + # Check if the configuration directory exists. if [ -d ${dirConfig} ] ; then echo ${dirConfig} > /dev/null diff --git a/src/ks-upr b/src/ks-upr index 9ac3663..6ca988c 100755 --- a/src/ks-upr +++ b/src/ks-upr @@ -14,7 +14,7 @@ dirTemp="/tmp" listCompTemp="ks-tools.list-full" listCompTempTest="ks-tools.list-full.test" listTemp="ks-tools.list" -dirConfig="$HOME/.ks-tools" +dirConfig="${HOME}/.ks-tools" ksToolsTempFolder="/tmp/ks-tools" # Check cygwin alias (for Windows) @@ -398,6 +398,39 @@ function checkDependencies() { fi } +# Function to migrate old configuration. +if [ -f ${dirConfig}/USER ] ; then + cat ${dirConfig}/USER > ${dirConfig}/ks-upload-user + echo "* Migrating ${dirConfig}/USER > ${dirConfig}/ks-upload-user" + rm -rf ${dirConfig}/USER + sleep 1 +fi +if [ -f ${dirConfig}/PASS ] ; then + echo "* Migrating ${dirConfig}/PASS > ${dirConfig}/ks-upload-pass" + current_pass=$(cat ${dirConfig}/PASS) + encrypt_kstools "${current_pass}" > ${dirConfig}/ks-upload-pass + rm -rf ${dirConfig}/PASS + sleep 1 +fi +if [ -f ${dirConfig}/SERVER ] ; then + cat ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server + echo "* Migrating ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server" + rm -rf ${dirConfig}/SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR_SERVER ] ; then + cat ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver + echo "* Migrating ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver" + rm -rf ${dirConfig}/DIR_SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR ] ; then + cat ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal + echo "* Migrating ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal" + rm -rf ${dirConfig}/DIR + sleep 1 +fi + # Check if the configuration directory exists. if [ -d ${dirConfig} ] ; then echo ${dirConfig} > /dev/null diff --git a/src/ks-upv b/src/ks-upv index c64e883..5aafa87 100755 --- a/src/ks-upv +++ b/src/ks-upv @@ -439,6 +439,39 @@ function checkDependencies() { fi } +# Function to migrate old configuration. +if [ -f ${dirConfig}/USER ] ; then + cat ${dirConfig}/USER > ${dirConfig}/ks-upload-user + echo "* Migrating ${dirConfig}/USER > ${dirConfig}/ks-upload-user" + rm -rf ${dirConfig}/USER + sleep 1 +fi +if [ -f ${dirConfig}/PASS ] ; then + echo "* Migrating ${dirConfig}/PASS > ${dirConfig}/ks-upload-pass" + current_pass=$(cat ${dirConfig}/PASS) + encrypt_kstools "${current_pass}" > ${dirConfig}/ks-upload-pass + rm -rf ${dirConfig}/PASS + sleep 1 +fi +if [ -f ${dirConfig}/SERVER ] ; then + cat ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server + echo "* Migrating ${dirConfig}/SERVER > ${dirConfig}/ks-upload-server" + rm -rf ${dirConfig}/SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR_SERVER ] ; then + cat ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver + echo "* Migrating ${dirConfig}/DIR_SERVER > ${dirConfig}/ks-upload-dirserver" + rm -rf ${dirConfig}/DIR_SERVER + sleep 1 +fi +if [ -f ${dirConfig}/DIR ] ; then + cat ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal + echo "* Migrating ${dirConfig}/DIR > ${dirConfig}/ks-upload-dirlocal" + rm -rf ${dirConfig}/DIR + sleep 1 +fi + # Check if the configuration directory exists. if [ -d ${dirConfig} ] ; then echo ${dirConfig} > /dev/null