Files
2024-06-13 20:19:57 +08:00

32 lines
732 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -eu
read -rp "请输入服务部署目录(默认/opt/xiaoya): " install_path
install_path=${install_path:=/opt/xiaoya}
if [ ! -d "$install_path" ]; then
echo "目录不存在,退出卸载"
exit 1
fi
DOCKER_COMPOSE="docker compose"
if ! docker compose &> /dev/null; then
DOCKER_COMPOSE="docker-compose"
fi
docker_params=""
read -rp "是否删除数据卷?(y/n): " delete_volume
if [ "$delete_volume" = "y" ]; then
docker_params="--volumes"
fi
echo "停止服务..."
$DOCKER_COMPOSE -f "$install_path/docker-compose.yml" down $docker_params
if [ "$delete_volume" = "y" ]; then
rm -rf "${install_path:?}"/*
else
find "${install_path:?}" -type f -not -path "${install_path}/data/*" -delete
fi