From d116655891e923883058cdc4d823169689d91d0f Mon Sep 17 00:00:00 2001 From: lsy Date: Fri, 27 Sep 2024 13:11:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Automation/manage.sh | 52 ++++++++++++++++++++++++ Config/Docker/{software.sh => manage.sh} | 4 ++ Config/User/{user.sh => manage.sh} | 0 3 files changed, 56 insertions(+) create mode 100644 Config/Automation/manage.sh rename Config/Docker/{software.sh => manage.sh} (92%) rename Config/User/{user.sh => manage.sh} (100%) diff --git a/Config/Automation/manage.sh b/Config/Automation/manage.sh new file mode 100644 index 0000000..2b8aefd --- /dev/null +++ b/Config/Automation/manage.sh @@ -0,0 +1,52 @@ +#!/bin/bash +echo "1.查看已经安装的脚本" +echo "2.删除脚本" + +declare pick +read -p "请输入:" pick + +declare path="/var/script" +echo "请输入脚本安装地址,默认${path}" +read -p "请输入:" path + +if [[ -z $path ]]; then + path="/var/script" +elif ! [[ -d $path ]]; then + echo "该地址不存在目录" +fi + +case $pick in +'1') + for i in "$path"/* ; do + if [[ $i == "${path}/*" ]];then + echo "该地址不存在脚本" + fi + echo $i + done + ;; +'2') + declare -a script_arr + declare script_name + declare script_number=0 + for i in "$path"/* ; do + if [[ $i == "${path}/*" ]];then + echo "该地址不存在脚本" + exit + fi + script_number=$(( script_number+1 )) + script_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)") + echo "${script_number}.${script_name}" + script_arr[$script_number]=$script_name + done + read -p "请输入要删除的序号,多个用 空格 隔开:" script_name + for i in $script_name ; do + if [[ $i =~ [1-${#script_arr[*]}] ]]; then + echo "开始删除 ${script_arr[$i]}" + (crontab -l 2>/dev/null | grep -v "${script_arr[$i]}") | crontab - && echo "已经删除脚本的自动任务" + rm -rf "$path/${script_arr[$i]}" &> /dev/null + echo "删除完成" + fi + done + echo "删除完成" + ;; +esac \ No newline at end of file diff --git a/Config/Docker/software.sh b/Config/Docker/manage.sh similarity index 92% rename from Config/Docker/software.sh rename to Config/Docker/manage.sh index 3769239..cc35bfd 100644 --- a/Config/Docker/software.sh +++ b/Config/Docker/manage.sh @@ -30,6 +30,10 @@ case $pick in declare site_name declare site_number=0 for i in "$path"/* ; do + if [[ $i == "${path}/*" ]];then + echo "该地址不存在站点" + exit + fi site_number=$(( site_number+1 )) site_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)") echo "${site_number}.${site_name}" diff --git a/Config/User/user.sh b/Config/User/manage.sh similarity index 100% rename from Config/User/user.sh rename to Config/User/manage.sh