更新软件结构

This commit is contained in:
lsy 2024-09-26 09:18:37 +08:00
parent 1e0df6eaed
commit 8b5d304ec4
4 changed files with 17 additions and 10 deletions

View File

@ -1,17 +1,20 @@
#!/bin/bash #!/bin/bash
declare file_name=$(basename $0 .sh) declare path_local=$1
declare path_script=$1
declare pick declare pick
echo "========Automation========" declare file_name
echo "========$(basename $0 .sh)========"
declare print_number=0 declare print_number=0
declare -a print_array declare -a print_array
for i in "${path_script}/Config/${file_name}"/*;do for i in "${path_local}"/*;do
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
if [[ $file_name == "test" ]]; then
continue
fi
print_number=$((print_number + 1)) print_number=$((print_number + 1))
print_array[$print_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)") print_array[$print_number]=$file_name
echo "${print_number}.${print_array[$print_number]}" echo "${print_number}.${file_name}"
done done
echo "输入其他任意返回主页" echo "输入其他任意返回主页"
echo "========Automation========"
read -p "请输入:" pick read -p "请输入:" pick
if [[ ! ${pick} =~ [1-$print_number] ]];then if [[ ! ${pick} =~ [1-$print_number] ]];then
@ -49,11 +52,11 @@ if [[ "$cron" == '* * * * * ' ]];then
exit exit
fi fi
if [[ -f "${path_script}/Config/${file_name}/${print_array[pick]}.sh" ]];then if [[ -f "${path_local}/${print_array[pick]}.sh" ]];then
echo "该路径文件已经存在" echo "该路径文件已经存在"
fi fi
bash "${path_script}/Config/${file_name}/${print_array[pick]}.sh" "$path" bash "${path_local}/${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"

6
Run.sh
View File

@ -18,8 +18,12 @@ do
if [[ -e "${path_local}/test.sh" ]]; then if [[ -e "${path_local}/test.sh" ]]; then
bash "${path_local}/test.sh" bash "${path_local}/test.sh"
fi fi
if [[ -e "${path_local}/menu.sh" ]]; then
bash "${path_local}/menu.sh" "$path_local"
path_local=$path_script
fi
pick_number=0 pick_number=0
echo "======$(basename $0 .sh)======" echo "======$(basename $path_local .sh)======"
for i in "${path_local}"/* for i in "${path_local}"/*
do do
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)") file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")