enh: supports silent uninstallation of the tar package using the -e parameter
This commit is contained in:
parent
3c30345625
commit
f4a1db9f6f
|
@ -162,9 +162,9 @@ remove_service_of() {
|
||||||
remove_tools_of() {
|
remove_tools_of() {
|
||||||
_tool=$1
|
_tool=$1
|
||||||
kill_service_of ${_tool}
|
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 "${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() {
|
remove_bin() {
|
||||||
|
@ -236,21 +236,56 @@ function remove_data_and_config() {
|
||||||
[ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir}
|
[ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
function usage() {
|
||||||
echo "Do you want to remove all the data, log and configuration files? [y/n]"
|
echo -e "\nUsage: $(basename $0) [-e <yes|no>]"
|
||||||
read answer
|
echo "-e: silent mode, specify whether to remove all the data, log and configuration files."
|
||||||
remove_flag=false
|
echo " yes: remove the data, log, and configuration files."
|
||||||
if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
echo " no: don't remove the data, log, and configuration files."
|
||||||
confirmMsg="I confirm that I would like to delete all data, log and configuration files"
|
}
|
||||||
echo "Please enter '${confirmMsg}' to continue"
|
|
||||||
|
# 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
|
read answer
|
||||||
if [ X"$answer" == X"${confirmMsg}" ]; then
|
if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
||||||
remove_flag=true
|
confirmMsg="I confirm that I would like to delete all data, log and configuration files"
|
||||||
else
|
echo "Please enter '${confirmMsg}' to continue"
|
||||||
echo "answer doesn't match, skip this step"
|
read answer
|
||||||
|
if [ X"$answer" == X"${confirmMsg}" ]; then
|
||||||
|
remove_flag="true"
|
||||||
|
else
|
||||||
|
echo "answer doesn't match, skip this step"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
echo
|
|
||||||
|
|
||||||
if [ -e ${install_main_dir}/uninstall_${PREFIX}x.sh ]; then
|
if [ -e ${install_main_dir}/uninstall_${PREFIX}x.sh ]; then
|
||||||
if [ X$remove_flag == X"true" ]; then
|
if [ X$remove_flag == X"true" ]; then
|
||||||
|
|
|
@ -57,7 +57,7 @@ function clean_bin() {
|
||||||
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
||||||
${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || :
|
${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || :
|
||||||
${csudo}rm -f ${bin_link_dir}/set_core || :
|
${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
|
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||||
${csudo}rm -f ${bin_link_dir}/${clientName2} || :
|
${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}/${benchmarkName2} || :
|
||||||
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
||||||
${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || :
|
${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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue