From de69bb307af1d53207a4553420ca5f7c74ba64cd Mon Sep 17 00:00:00 2001 From: lsy Date: Mon, 23 Sep 2024 16:53:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=89=80=E6=9C=89=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E8=8F=9C=E5=8D=95=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Menus/Automation.sh | 8 ++++---- Menus/Docker.sh | 6 +++--- Menus/Other.sh | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Menus/Automation.sh b/Menus/Automation.sh index 2893ef3..dc2da5b 100644 --- a/Menus/Automation.sh +++ b/Menus/Automation.sh @@ -1,11 +1,11 @@ #!/bin/bash - +declare file_name=$(basename $0 .sh) declare path_script=$1 declare pick echo "========Automation========" declare print_number=0 declare -a print_array -for i in "${path_script}/Config/Automation"/*;do +for i in "${path_script}/Config/${file_name}"/*;do print_number=$((print_number + 1)) print_array[$print_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)") echo "${print_number}.${print_array[$print_number]}" @@ -49,11 +49,11 @@ if [[ "$cron" == '* * * * * ' ]];then exit fi -if [[ -f "${path_script}/Config/Automation/${print_array[pick]}.sh" ]];then +if [[ -f "${path_script}/Config/${file_name}/${print_array[pick]}.sh" ]];then echo "该路径文件已经存在" fi -bash "${path_script}/Config/Automation/${print_array[pick]}.sh" "$path" +bash "${path_script}/Config/${file_name}/${print_array[pick]}.sh" "$path" chmod +x "${path}/${print_array[pick]}.sh" declare cron_job="${cron} ${path}/${print_array[pick]}.sh" diff --git a/Menus/Docker.sh b/Menus/Docker.sh index 1c7f551..cbd34cb 100644 --- a/Menus/Docker.sh +++ b/Menus/Docker.sh @@ -1,7 +1,7 @@ #!/bin/bash declare path_script=$1 - +declare file_name=$(basename $0 .sh) if ! command -v docker &> /dev/null; then echo "docker未安装" exit @@ -15,7 +15,7 @@ echo "========Docker========" echo "1.换源" echo "2.清除所有未使用镜像" echo "-----一键搭建软件-----" -for i in "${path_script}/Config/Docker"/*;do +for i in "${path_script}/Config/${file_name}"/*;do pick_number=$((pick_number + 1)) pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)") echo "${pick_number}.${pick_array[$pick_number]}" @@ -91,7 +91,7 @@ elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le " exit fi - bash "${path_script}/Config/Docker/${pick_array[${pick}]}.sh" "$file_path" "$port" + bash "${path_script}/Config/${file_name}/${pick_array[${pick}]}.sh" "$file_path" "$port" echo "${pick_array[${pick}]}安装完成,访问端口${port}" fi diff --git a/Menus/Other.sh b/Menus/Other.sh index 0e68a93..eb59b88 100644 --- a/Menus/Other.sh +++ b/Menus/Other.sh @@ -1,5 +1,5 @@ declare path_script=$1 -declare file_name=$(basename $0) +declare file_name=$(basename $0 .sh) echo "========Other========" declare print_number=0 declare -a print_arr