2024-09-26 19:31:17 +08:00
|
|
|
#!/bin/bash
|
|
|
|
echo "1.查看已经安装的站点"
|
|
|
|
echo "2.删除软件"
|
|
|
|
|
|
|
|
declare pick
|
2024-09-26 19:46:58 +08:00
|
|
|
read -p "请输入:" pick
|
2024-09-26 19:31:17 +08:00
|
|
|
|
|
|
|
declare path="/var/www"
|
|
|
|
echo "请输入站点安装地址,默认${path}"
|
2024-09-26 19:46:58 +08:00
|
|
|
read -p "请输入:" path
|
2024-09-26 19:31:17 +08:00
|
|
|
|
|
|
|
if [[ -z $path ]]; then
|
|
|
|
path="/var/www"
|
|
|
|
elif ! [[ -d $path ]]; then
|
|
|
|
echo "该地址不存在目录"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
case $pick in
|
|
|
|
'1')
|
|
|
|
for i in "$path"/* ; do
|
2024-09-26 19:46:58 +08:00
|
|
|
if [[ $i == "${path}/*" ]];then
|
|
|
|
echo "该地址不存在站点"
|
|
|
|
fi
|
2024-09-26 19:31:17 +08:00
|
|
|
echo $i
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
'2')
|
|
|
|
declare -a site_arr
|
|
|
|
declare site_name
|
|
|
|
declare site_number=0
|
|
|
|
for i in "$path"/* ; do
|
2024-09-27 13:11:37 +08:00
|
|
|
if [[ $i == "${path}/*" ]];then
|
|
|
|
echo "该地址不存在站点"
|
|
|
|
exit
|
|
|
|
fi
|
2024-09-26 19:31:17 +08:00
|
|
|
site_number=$(( site_number+1 ))
|
|
|
|
site_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
|
|
|
echo "${site_number}.${site_name}"
|
|
|
|
site_arr[$site_number]=$site_name
|
|
|
|
done
|
|
|
|
read -p "请输入要删除的序号,多个用 空格 隔开:" site_name
|
|
|
|
for i in $site_name ; do
|
|
|
|
if [[ $i =~ [1-${#site_arr[*]}] ]]; then
|
2024-09-26 19:46:58 +08:00
|
|
|
echo "开始删除 ${site_arr[$i]}"
|
2024-09-26 19:31:17 +08:00
|
|
|
cd "$path/${site_arr[$i]}"
|
2024-09-26 19:46:58 +08:00
|
|
|
docker compose down &> /dev/null && echo "站点已经停止运行"
|
|
|
|
rm -rf "$path/${site_arr[$i]}" &> /dev/null
|
|
|
|
echo "删除完成"
|
2024-09-26 19:31:17 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "删除完成"
|
|
|
|
;;
|
|
|
|
esac
|