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