From 7e07cae7fe1bd484f1631be01faebbf1054f6605 Mon Sep 17 00:00:00 2001 From: q3aql Date: Tue, 4 Jan 2022 12:10:33 +0100 Subject: [PATCH] Ask for confirmation before deleting the configuration --- src/ks-upa | 46 ++++++++++++++++++++++++++++++++-------------- src/ks-upf | 34 ++++++++++++++++++++++++++-------- src/ks-upr | 34 ++++++++++++++++++++++++++-------- src/ks-upv | 34 ++++++++++++++++++++++++++-------- 4 files changed, 110 insertions(+), 38 deletions(-) diff --git a/src/ks-upa b/src/ks-upa index 8e86910..65ce82b 100755 --- a/src/ks-upa +++ b/src/ks-upa @@ -532,31 +532,49 @@ else fi # Delete the existing configuration. -if [ "$1" == "-r" ] ; then - rm -rf ${dirConfig}/ks-upload-user - rm -rf ${dirConfig}/ks-upload-pass - rm -rf ${dirConfig}/ks-upload-server - rm -rf ${dirConfig}/ks-upload-dirserver - rm -rf ${dirConfig}/ks-upload-dirlocal - exit +if [ "${1}" == "-r" ] ; then + echo "" + echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo -n "* [Default: n] Are you sure you want to delete the configuration? (y/n): " ; read confirm + if [ "${confirm}" == "y" ] ; then + echo "" + echo "+ Removing USER file configuration..." + rm -rf ${dirConfig}/ks-upload-user + echo "+ Removing PASSWORD file configuration..." + rm -rf ${dirConfig}/ks-upload-pass + echo "+ Removing SERVER file configuration..." + rm -rf ${dirConfig}/ks-upload-server + echo "+ Removing SERVER PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirserver + echo "+ Removing LOCAL PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirlocal + echo "* Removed all configuration" + echo "" + exit + else + echo "" + echo "+ Remove configuration canceled" + echo "" + exit + fi fi - # Show configuration file -if [ "$1" == "-c" ] ; then +if [ "${1}" == "-c" ] ; then showConfig # Show configuration file -elif [ "$1" == "-e" ] ; then +elif [ "${1}" == "-e" ] ; then editConfig # Show the version -elif [ "$1" == "-v" ] ; then +elif [ "${1}" == "-v" ] ; then showVersion # Show the help -elif [ "$1" == "-h" ] ; then +elif [ "${1}" == "-h" ] ; then showHelp -elif [ "$1" == "-g" ] ; then +elif [ "${1}" == "-g" ] ; then createConfig # Init -elif [ "$1" == "-i" ] ; then +elif [ "${1}" == "-i" ] ; then # Start script createConfig user=$(cat ${dirConfig}/ks-upload-user) diff --git a/src/ks-upf b/src/ks-upf index 4baf24f..14aeaed 100755 --- a/src/ks-upf +++ b/src/ks-upf @@ -550,15 +550,33 @@ else fi # Delete the existing configuration. -if [ "$1" == "-r" ] ; then - rm -rf ${dirConfig}/ks-upload-user - rm -rf ${dirConfig}/ks-upload-pass - rm -rf ${dirConfig}/ks-upload-server - rm -rf ${dirConfig}/ks-upload-dirserver - rm -rf ${dirConfig}/ks-upload-dirlocal - exit +if [ "${1}" == "-r" ] ; then + echo "" + echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo -n "* [Default: n] Are you sure you want to delete the configuration? (y/n): " ; read confirm + if [ "${confirm}" == "y" ] ; then + echo "" + echo "+ Removing USER file configuration..." + rm -rf ${dirConfig}/ks-upload-user + echo "+ Removing PASSWORD file configuration..." + rm -rf ${dirConfig}/ks-upload-pass + echo "+ Removing SERVER file configuration..." + rm -rf ${dirConfig}/ks-upload-server + echo "+ Removing SERVER PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirserver + echo "+ Removing LOCAL PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirlocal + echo "* Removed all configuration" + echo "" + exit + else + echo "" + echo "+ Remove configuration canceled" + echo "" + exit + fi fi - # Show configuration file if [ "$1" == "-c" ] ; then showConfig diff --git a/src/ks-upr b/src/ks-upr index e193179..690e618 100755 --- a/src/ks-upr +++ b/src/ks-upr @@ -492,15 +492,33 @@ else fi # Delete the existing configuration. -if [ "$1" == "-r" ] ; then - rm -rf ${dirConfig}/ks-upload-user - rm -rf ${dirConfig}/ks-upload-pass - rm -rf ${dirConfig}/ks-upload-server - rm -rf ${dirConfig}/ks-upload-dirserver - rm -rf ${dirConfig}/ks-upload-dirlocal - exit +if [ "${1}" == "-r" ] ; then + echo "" + echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo -n "* [Default: n] Are you sure you want to delete the configuration? (y/n): " ; read confirm + if [ "${confirm}" == "y" ] ; then + echo "" + echo "+ Removing USER file configuration..." + rm -rf ${dirConfig}/ks-upload-user + echo "+ Removing PASSWORD file configuration..." + rm -rf ${dirConfig}/ks-upload-pass + echo "+ Removing SERVER file configuration..." + rm -rf ${dirConfig}/ks-upload-server + echo "+ Removing SERVER PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirserver + echo "+ Removing LOCAL PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirlocal + echo "* Removed all configuration" + echo "" + exit + else + echo "" + echo "+ Remove configuration canceled" + echo "" + exit + fi fi - # Show configuration file if [ "$1" == "-c" ] ; then showConfig diff --git a/src/ks-upv b/src/ks-upv index 58e5fed..b77398e 100755 --- a/src/ks-upv +++ b/src/ks-upv @@ -533,15 +533,33 @@ else fi # Delete the existing configuration. -if [ "$1" == "-r" ] ; then - rm -rf ${dirConfig}/ks-upload-user - rm -rf ${dirConfig}/ks-upload-pass - rm -rf ${dirConfig}/ks-upload-server - rm -rf ${dirConfig}/ks-upload-dirserver - rm -rf ${dirConfig}/ks-upload-dirlocal - exit +if [ "${1}" == "-r" ] ; then + echo "" + echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo -n "* [Default: n] Are you sure you want to delete the configuration? (y/n): " ; read confirm + if [ "${confirm}" == "y" ] ; then + echo "" + echo "+ Removing USER file configuration..." + rm -rf ${dirConfig}/ks-upload-user + echo "+ Removing PASSWORD file configuration..." + rm -rf ${dirConfig}/ks-upload-pass + echo "+ Removing SERVER file configuration..." + rm -rf ${dirConfig}/ks-upload-server + echo "+ Removing SERVER PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirserver + echo "+ Removing LOCAL PATH file configuration..." + rm -rf ${dirConfig}/ks-upload-dirlocal + echo "* Removed all configuration" + echo "" + exit + else + echo "" + echo "+ Remove configuration canceled" + echo "" + exit + fi fi - # Show configuration file if [ "$1" == "-c" ] ; then showConfig