2023-12-21 16:09:03 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DE_BASE=/opt
|
|
|
|
|
2024-02-05 16:29:28 +08:00
|
|
|
echo "如需备份 DataEase 数据,请执行 dectl backup 进行备份。如您的 dectl 命令不支持 backup 命令,请升级版本。"
|
2023-12-21 16:09:03 +08:00
|
|
|
read -r -p "即将卸载 DataEase 服务,包括删除运行目录、数据及相关镜像,是否继续? [Y/n] " input
|
|
|
|
|
|
|
|
case $input in
|
|
|
|
[yY][eE][sS]|[yY])
|
|
|
|
echo "Yes"
|
|
|
|
;;
|
|
|
|
[nN][oO]|[nN])
|
|
|
|
echo "No"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "无效输入..."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-01-30 18:30:17 +08:00
|
|
|
echo "停止 DataEase 服务"
|
2024-02-07 14:38:18 +08:00
|
|
|
service dataease stop >/dev/null 2>&1
|
2024-01-30 18:30:17 +08:00
|
|
|
|
|
|
|
echo "移除 DataEase 服务"
|
2024-02-07 14:38:18 +08:00
|
|
|
if which chkconfig >/dev/null 2>&1;then
|
|
|
|
chkconfig dataease >/dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
chkconfig --del dataease >/dev/null 2>&1
|
|
|
|
fi
|
2024-01-30 18:30:17 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /etc/systemd/system/dataease.service ];then
|
2024-02-07 14:38:18 +08:00
|
|
|
systemctl disable dataease >/dev/null 2>&1
|
2024-01-30 18:30:17 +08:00
|
|
|
rm -f /etc/systemd/system/dataease.service
|
|
|
|
systemctl daemon-reload
|
|
|
|
elif [[ -f /etc/init.d/dataease ]];then
|
|
|
|
rm -f /etc/init.d/dataease
|
|
|
|
fi
|
|
|
|
|
2023-12-21 16:09:03 +08:00
|
|
|
if [ -f /usr/bin/dectl ]; then
|
|
|
|
# 获取已安装的 DataEase 的运行目录
|
|
|
|
DE_BASE=$(grep "^DE_BASE=" /usr/bin/dectl | cut -d'=' -f2)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 清理 DataEase 相关镜像
|
|
|
|
if test ! -z "$(docker images -f dangling=true -q)"; then
|
|
|
|
echo "清理虚悬镜像"
|
|
|
|
docker rmi $(docker images -f dangling=true -q)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$(docker images | grep 'registry.cn-qingdao.aliyuncs.com/dataease')"; then
|
|
|
|
echo "清理 DataEase 镜像"
|
|
|
|
docker rmi $(docker images | grep "registry.cn-qingdao.aliyuncs.com/dataease" | awk -F' ' '{print $1":"$2}')
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 清理 DataEase 运行目录及命令行工具 dectl
|
2024-02-07 14:38:18 +08:00
|
|
|
rm -rf ${DE_BASE}/dataease2.0 /usr/bin/dectl
|
|
|
|
|
|
|
|
echo "DataEase 服务卸载完成"
|