diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index b40b94aa7b..a0a1c235c0 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -162,9 +162,9 @@ remove_service_of() { remove_tools_of() { _tool=$1 kill_service_of ${_tool} - [ -e "${bin_link_dir}/${_tool}" ] && ${csudo}rm -rf ${bin_link_dir}/${_tool} || : + [ -L "${bin_link_dir}/${_tool}" ] && ${csudo}rm -rf ${bin_link_dir}/${_tool} || : [ -e "${installDir}/bin/${_tool}" ] && ${csudo}rm -rf ${installDir}/bin/${_tool} || : - [ -e "${local_bin_link_dir}/${_tool}" ] && ${csudo}rm -rf ${local_bin_link_dir}/${_tool} || : + [ -L "${local_bin_link_dir}/${_tool}" ] && ${csudo}rm -rf ${local_bin_link_dir}/${_tool} || : } remove_bin() { @@ -236,21 +236,56 @@ function remove_data_and_config() { [ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir} } -echo -echo "Do you want to remove all the data, log and configuration files? [y/n]" -read answer -remove_flag=false -if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then - confirmMsg="I confirm that I would like to delete all data, log and configuration files" - echo "Please enter '${confirmMsg}' to continue" +function usage() { + echo -e "\nUsage: $(basename $0) [-e ]" + echo "-e: silent mode, specify whether to remove all the data, log and configuration files." + echo " yes: remove the data, log, and configuration files." + echo " no: don't remove the data, log, and configuration files." +} + +# main +interactive_remove="yes" +remove_flag="false" + +while getopts "e:h" opt; do + case $opt in + e) + interactive_remove="no" + + if [ "$OPTARG" == "yes" ]; then + remove_flag="true" + echo "Remove all the data, log, and configuration files." + elif [ "$OPTARG" == "no" ]; then + remove_flag="false" + echo "Do not remove the data, log, and configuration files." + else + echo "Invalid option for -e: $OPTARG" + usage + exit 1 + fi + ;; + h | *) + usage + exit 1 + ;; + esac +done + +if [ "$interactive_remove" == "yes" ]; then + echo -e "\nDo you want to remove all the data, log and configuration files? [y/n]" read answer - if [ X"$answer" == X"${confirmMsg}" ]; then - remove_flag=true - else - echo "answer doesn't match, skip this step" + if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then + confirmMsg="I confirm that I would like to delete all data, log and configuration files" + echo "Please enter '${confirmMsg}' to continue" + read answer + if [ X"$answer" == X"${confirmMsg}" ]; then + remove_flag="true" + else + echo "answer doesn't match, skip this step" + fi fi + echo fi -echo if [ -e ${install_main_dir}/uninstall_${PREFIX}x.sh ]; then if [ X$remove_flag == X"true" ]; then diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh index 33454d7512..a7eb225704 100755 --- a/packaging/tools/remove_client.sh +++ b/packaging/tools/remove_client.sh @@ -57,7 +57,7 @@ function clean_bin() { ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : ${csudo}rm -f ${bin_link_dir}/set_core || : - [ -f ${bin_link_dir}/${inspect_name} ] && ${csudo}rm -f ${bin_link_dir}/${inspect_name} || : + [ -L ${bin_link_dir}/${inspect_name} ] && ${csudo}rm -f ${bin_link_dir}/${inspect_name} || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then ${csudo}rm -f ${bin_link_dir}/${clientName2} || : @@ -65,7 +65,7 @@ function clean_bin() { ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : - [ -f ${bin_link_dir}/${inspect_name} ] && ${csudo}rm -f ${bin_link_dir}/${inspect_name} || : + [ -L ${bin_link_dir}/${inspect_name} ] && ${csudo}rm -f ${bin_link_dir}/${inspect_name} || : fi }