feat: enhance removal script with command-line options for data retention
This commit is contained in:
parent
3bc6635de3
commit
e8cc3fcc9c
|
@ -236,21 +236,55 @@ function remove_data_and_config() {
|
||||||
[ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir}
|
[ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
# 解析命令行参数
|
||||||
echo "Do you want to remove all the data, log and configuration files? [y/n]"
|
interactive_remove="yes"
|
||||||
read answer
|
while getopts "e:h" opt; do
|
||||||
remove_flag=false
|
case $opt in
|
||||||
if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
e)
|
||||||
confirmMsg="I confirm that I would like to delete all data, log and configuration files"
|
if [ "$OPTARG" == "yes" ]; then
|
||||||
echo "Please enter '${confirmMsg}' to continue"
|
interactive_remove="no"
|
||||||
|
remove_flag=false
|
||||||
|
echo "It will remove only the binary files and keep all the data, log, and configuration files."
|
||||||
|
elif [ "$OPTARG" == "no" ]; then
|
||||||
|
interactive_remove="no"
|
||||||
|
remove_flag=true
|
||||||
|
echo "It will remove the binary files and all the data, log, and configuration files."
|
||||||
|
else
|
||||||
|
echo "Invalid option for -e: $OPTARG"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
echo "Usage: $(basename $0) -e [yes | no] "
|
||||||
|
echo " select 'yes' to skip prompt and remove only the binary files and keep all the data, log, and configuration files."
|
||||||
|
echo " select 'no' to skip prompt and remove the binary files and all the data, log, and configuration files"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid option: -$opt"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$interactive_remove" == "yes" ]; then
|
||||||
|
echo
|
||||||
|
echo "Do you want to remove all the data, log and configuration files? [y/n]"
|
||||||
read answer
|
read answer
|
||||||
if [ X"$answer" == X"${confirmMsg}" ]; then
|
remove_flag=false
|
||||||
remove_flag=true
|
if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
||||||
else
|
confirmMsg="I confirm that I would like to delete all data, log and configuration files"
|
||||||
echo "answer doesn't match, skip this step"
|
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
|
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
|
||||||
|
@ -260,7 +294,6 @@ if [ -e ${install_main_dir}/uninstall_${PREFIX}x.sh ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$osType" = "Darwin" ]; then
|
if [ "$osType" = "Darwin" ]; then
|
||||||
clean_service_on_launchctl
|
clean_service_on_launchctl
|
||||||
${csudo}rm -rf /Applications/TDengine.app
|
${csudo}rm -rf /Applications/TDengine.app
|
||||||
|
@ -299,8 +332,7 @@ elif echo $osinfo | grep -qwi "centos"; then
|
||||||
${csudo}rpm -e --noscripts tdengine >/dev/null 2>&1 || :
|
${csudo}rpm -e --noscripts tdengine >/dev/null 2>&1 || :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
command -v systemctl >/dev/null 2>&1 && ${csudo}systemctl daemon-reload >/dev/null 2>&1 || true
|
command -v systemctl >/dev/null 2>&1 && ${csudo}systemctl daemon-reload >/dev/null 2>&1 || true
|
||||||
echo
|
echo
|
||||||
echo "${productName} is removed successfully!"
|
echo "${productName} is removed successfully!"
|
||||||
echo
|
echo
|
Loading…
Reference in New Issue