2024-07-23 20:50:16 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-09-23 17:59:28 +08:00
|
|
|
if [[ $UID != 0 ]]; then
|
|
|
|
echo "请以root权限执行该脚本"
|
|
|
|
exit
|
2024-07-23 20:50:16 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
declare -a pick_array
|
2024-07-24 00:56:26 +08:00
|
|
|
declare pick_number
|
2024-07-23 20:50:16 +08:00
|
|
|
declare pick
|
2024-09-21 16:25:44 +08:00
|
|
|
declare path_script=$(dirname $0)
|
2024-09-26 08:55:44 +08:00
|
|
|
path_script="${path_script}/Config"
|
|
|
|
declare path_local=$path_script
|
|
|
|
declare file_name
|
2024-07-24 00:56:26 +08:00
|
|
|
|
|
|
|
while true
|
|
|
|
do
|
2024-09-26 08:55:44 +08:00
|
|
|
if [[ -e "${path_local}/test.sh" ]]; then
|
|
|
|
bash "${path_local}/test.sh"
|
2024-09-26 09:48:31 +08:00
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
path_local=$path_script
|
|
|
|
fi
|
2024-09-26 08:55:44 +08:00
|
|
|
fi
|
2024-09-26 09:18:37 +08:00
|
|
|
if [[ -e "${path_local}/menu.sh" ]]; then
|
2024-09-26 09:48:31 +08:00
|
|
|
clear
|
2024-09-26 09:18:37 +08:00
|
|
|
bash "${path_local}/menu.sh" "$path_local"
|
|
|
|
path_local=$path_script
|
|
|
|
fi
|
2024-07-24 00:56:26 +08:00
|
|
|
pick_number=0
|
2024-09-26 10:53:51 +08:00
|
|
|
pick_array=()
|
2024-09-26 09:18:37 +08:00
|
|
|
echo "======$(basename $path_local .sh)======"
|
2024-09-26 08:55:44 +08:00
|
|
|
for i in "${path_local}"/*
|
2024-07-23 20:50:16 +08:00
|
|
|
do
|
2024-09-26 08:55:44 +08:00
|
|
|
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
|
|
|
if [[ $file_name == "test" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
2024-07-23 20:50:16 +08:00
|
|
|
pick_number=$((pick_number + 1))
|
2024-09-26 08:55:44 +08:00
|
|
|
pick_array[$pick_number]=$file_name
|
2024-07-23 20:50:16 +08:00
|
|
|
echo "${pick_number}.${pick_array[$pick_number]}"
|
|
|
|
done
|
2024-09-26 08:58:55 +08:00
|
|
|
|
|
|
|
if [[ $path_local != $path_script ]]; then
|
|
|
|
echo "输入任意返回主页"
|
|
|
|
fi
|
|
|
|
|
2024-07-23 20:50:16 +08:00
|
|
|
read -p "请输入要使用的功能:" pick
|
2024-09-25 15:10:40 +08:00
|
|
|
if [[ "${pick}" =~ [1-${#pick_array[*]}] ]];then
|
2024-07-23 20:50:16 +08:00
|
|
|
clear
|
2024-09-26 08:55:44 +08:00
|
|
|
if [[ -d "${path_local}/${pick_array[$pick]}" ]]; then
|
|
|
|
path_local="${path_local}/${pick_array[$pick]}"
|
|
|
|
elif [[ -e "${path_script}/${pick_array[$pick]}.sh" ]]; then
|
|
|
|
bash "${path_script}/${pick_array[$pick]}.sh"
|
|
|
|
path_local=$path_script
|
|
|
|
fi
|
2024-07-23 20:50:16 +08:00
|
|
|
else
|
2024-09-26 08:58:55 +08:00
|
|
|
if [[ $path_local == $path_script ]]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
path_local=$path_script
|
2024-07-24 00:56:26 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
done
|