From 778fb6ec593f2609c9d83571597bcb3455971e70 Mon Sep 17 00:00:00 2001 From: lsy Date: Fri, 27 Sep 2024 14:45:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E6=9F=A5=E8=AF=A2=E5=92=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A2=9E=E5=8A=A0=E7=A9=BA=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Automation/manage.sh | 39 ++++++++++++++++++++++++++----------- Config/Web/acme/manage.sh | 4 ++++ Config/Web/nginx/manage.sh | 8 ++++++++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Config/Automation/manage.sh b/Config/Automation/manage.sh index 5f52300..029fe8d 100644 --- a/Config/Automation/manage.sh +++ b/Config/Automation/manage.sh @@ -17,22 +17,13 @@ fi case $pick in '1') - echo "该系统安装了以下脚本" - for i in "$path"/* ; do - if [[ $i == "${path}/*" ]];then - echo "该地址不存在脚本" - fi - basename $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 + exit fi script_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)") if [[ $script_name == "linuxtool" ]]; then @@ -42,9 +33,35 @@ case $pick in echo "${script_number}.${script_name}" script_arr[$script_number]=$script_name done + if [ ${#script_arr[@]} == 0 ]; then + echo "该地址不存在脚本" + exit + fi + ;; +'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_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)") + if [[ $script_name == "linuxtool" ]]; then + continue + fi + script_number=$(( script_number+1 )) + echo "${script_number}.${script_name}" + script_arr[$script_number]=$script_name + done + if [ ${#script_arr[@]} == 0 ]; then + echo "该地址不存在脚本" + exit + fi read -p "请输入要删除的序号,多个用 空格 隔开:" script_name for i in $script_name ; do - if [[ $i =~ [1-${#script_arr[*]}] ]]; then + 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 diff --git a/Config/Web/acme/manage.sh b/Config/Web/acme/manage.sh index e49046d..0e6593c 100644 --- a/Config/Web/acme/manage.sh +++ b/Config/Web/acme/manage.sh @@ -20,6 +20,10 @@ case $pick in print_arr[$print_number]=$print_name echo "${print_number}.${print_name}" done + if [ ${#print_arr[@]} == 0 ]; then + echo "暂时没有安装证书" + exit + fi read -p "请输入要查看证书详细信息的序号:" pick if [[ $pick =~ [1-${#print_arr[@]}] ]]; then bash "${HOME}/.acme.sh/acme.sh -info -d ${print_arr[$pick]}" diff --git a/Config/Web/nginx/manage.sh b/Config/Web/nginx/manage.sh index 9977770..ba53450 100644 --- a/Config/Web/nginx/manage.sh +++ b/Config/Web/nginx/manage.sh @@ -19,6 +19,10 @@ case $pick in echo "${site_number}.${site_name}" site_arr[$site_number]=$site_name done + if [ ${#site_arr[@]} == 0 ]; then + echo "暂时没有配置文件" + exit + fi ;; '2') declare -a site_arr @@ -34,6 +38,10 @@ case $pick in echo "${site_number}.${site_name}" site_arr[$site_number]=$site_name done + if [ ${#site_arr[@]} == 0 ]; then + echo "暂时没有配置文件" + exit + fi read -p "请输入要删除的序号,多个用 空格 隔开:" site_name for i in $site_name ; do if [[ $i =~ [1-${#site_arr[*]}] ]]; then