将所有调用文件的菜单文件名替换

This commit is contained in:
lsy 2024-09-23 16:53:13 +08:00
parent 55e856934f
commit de69bb307a
3 changed files with 8 additions and 8 deletions

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
declare file_name=$(basename $0 .sh)
declare path_script=$1 declare path_script=$1
declare pick declare pick
echo "========Automation========" echo "========Automation========"
declare print_number=0 declare print_number=0
declare -a print_array 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_number=$((print_number + 1))
print_array[$print_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)") print_array[$print_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
echo "${print_number}.${print_array[$print_number]}" echo "${print_number}.${print_array[$print_number]}"
@ -49,11 +49,11 @@ if [[ "$cron" == '* * * * * ' ]];then
exit exit
fi 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 "该路径文件已经存在" echo "该路径文件已经存在"
fi 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" chmod +x "${path}/${print_array[pick]}.sh"
declare cron_job="${cron} ${path}/${print_array[pick]}.sh" declare cron_job="${cron} ${path}/${print_array[pick]}.sh"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
declare path_script=$1 declare path_script=$1
declare file_name=$(basename $0 .sh)
if ! command -v docker &> /dev/null; then if ! command -v docker &> /dev/null; then
echo "docker未安装" echo "docker未安装"
exit exit
@ -15,7 +15,7 @@ echo "========Docker========"
echo "1.换源" echo "1.换源"
echo "2.清除所有未使用镜像" echo "2.清除所有未使用镜像"
echo "-----一键搭建软件-----" echo "-----一键搭建软件-----"
for i in "${path_script}/Config/Docker"/*;do for i in "${path_script}/Config/${file_name}"/*;do
pick_number=$((pick_number + 1)) pick_number=$((pick_number + 1))
pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)") pick_array[$pick_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
echo "${pick_number}.${pick_array[$pick_number]}" echo "${pick_number}.${pick_array[$pick_number]}"
@ -91,7 +91,7 @@ elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le "
exit exit
fi 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}" echo "${pick_array[${pick}]}安装完成,访问端口${port}"
fi fi

View File

@ -1,5 +1,5 @@
declare path_script=$1 declare path_script=$1
declare file_name=$(basename $0) declare file_name=$(basename $0 .sh)
echo "========Other========" echo "========Other========"
declare print_number=0 declare print_number=0
declare -a print_arr declare -a print_arr