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