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
|
|
|
|
|
2024-11-18 23:12:52 +08:00
|
|
|
declare -a function_array
|
|
|
|
declare selected_function
|
|
|
|
declare script_path=$(dirname $0)
|
|
|
|
script_path="${script_path}/Config"
|
|
|
|
declare local_path=$script_path
|
|
|
|
declare script_name
|
2024-07-24 00:56:26 +08:00
|
|
|
|
|
|
|
while true
|
|
|
|
do
|
2024-11-18 23:12:52 +08:00
|
|
|
if [[ -e "${local_path}/test.sh" ]]; then
|
|
|
|
bash "${local_path}/test.sh"
|
2024-09-26 09:48:31 +08:00
|
|
|
if [[ $? -eq 1 ]]; then
|
2024-11-18 23:12:52 +08:00
|
|
|
local_path=$script_path
|
2024-09-26 09:48:31 +08:00
|
|
|
fi
|
2024-09-26 08:55:44 +08:00
|
|
|
fi
|
2024-11-18 23:12:52 +08:00
|
|
|
if [[ -e "${local_path}/menu.sh" ]]; then
|
2024-09-26 09:48:31 +08:00
|
|
|
clear
|
2024-11-18 23:12:52 +08:00
|
|
|
bash "${local_path}/menu.sh" "$local_path"
|
|
|
|
local_path=$script_path
|
2024-09-26 09:18:37 +08:00
|
|
|
fi
|
2024-11-18 23:12:52 +08:00
|
|
|
selected_function=0
|
|
|
|
function_array=()
|
|
|
|
echo "======$(basename $local_path .sh)======"
|
|
|
|
for i in "${local_path}"/*
|
2024-07-23 20:50:16 +08:00
|
|
|
do
|
2024-11-18 23:12:52 +08:00
|
|
|
script_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
|
|
|
if [[ $script_name == "test" ]]; then
|
2024-09-26 08:55:44 +08:00
|
|
|
continue
|
|
|
|
fi
|
2024-11-18 23:12:52 +08:00
|
|
|
selected_function=$((selected_function + 1))
|
|
|
|
function_array[$selected_function]=$script_name
|
|
|
|
echo "${selected_function}.${function_array[$selected_function]}"
|
2024-07-23 20:50:16 +08:00
|
|
|
done
|
2024-09-26 08:58:55 +08:00
|
|
|
|
2024-11-18 23:12:52 +08:00
|
|
|
if [[ $local_path != $script_path ]]; then
|
2024-09-26 08:58:55 +08:00
|
|
|
echo "输入任意返回主页"
|
|
|
|
fi
|
|
|
|
|
2024-11-18 23:12:52 +08:00
|
|
|
read -p "请输入要使用的功能:" user_choice
|
|
|
|
if [[ "${user_choice}" =~ [1-${#function_array[*]}] ]];then
|
2024-07-23 20:50:16 +08:00
|
|
|
clear
|
2024-11-18 23:12:52 +08:00
|
|
|
if [[ -d "${local_path}/${function_array[$user_choice]}" ]]; then
|
|
|
|
local_path="${local_path}/${function_array[$user_choice]}"
|
|
|
|
elif [[ -e "${local_path}/${function_array[$user_choice]}.sh" ]]; then
|
|
|
|
bash "${local_path}/${function_array[$user_choice]}.sh"
|
|
|
|
local_path=$script_path
|
2024-09-26 08:55:44 +08:00
|
|
|
fi
|
2024-07-23 20:50:16 +08:00
|
|
|
else
|
2024-11-18 23:12:52 +08:00
|
|
|
if [[ $local_path == $script_path ]]; then
|
2024-09-26 08:58:55 +08:00
|
|
|
exit
|
|
|
|
fi
|
2024-11-18 23:12:52 +08:00
|
|
|
local_path=$script_path
|
2024-07-24 00:56:26 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
done
|