更新软件结构

This commit is contained in:
lsy 2024-09-26 09:48:31 +08:00
parent 8b5d304ec4
commit db267ea0b9
14 changed files with 68 additions and 39 deletions

View File

@ -19,7 +19,7 @@ for item in "$web_path"/* ; do
echo "${item_name}" echo "${item_name}"
done done
echo "请输入需要屏蔽的目录用逗号隔开" echo "请输入需要屏蔽的目录用 空格 隔开"
read -p "请输入:" ignore read -p "请输入:" ignore

View File

@ -7,7 +7,7 @@ declare print_number=0
declare -a print_array declare -a print_array
for i in "${path_local}"/*;do for i in "${path_local}"/*;do
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)") file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
if [[ $file_name == "test" ]]; then if [[ $file_name == "test" || $file_name == "menu" ]]; then
continue continue
fi fi
print_number=$((print_number + 1)) print_number=$((print_number + 1))

View File

@ -0,0 +1,57 @@
#!/bin/bash
declare path_local=$1
declare pick
declare file_name
echo "========$(basename $0 .sh)========"
declare print_number=0
declare -a print_array
for i in "${path_local}"/*;do
file_name=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
if [[ $file_name == "test" || $file_name == "menu" ]]; then
continue
fi
print_number=$((print_number + 1))
print_array[$print_number]=$file_name
echo "${print_number}.${file_name}"
done
echo "输入其他任意返回主页"
read -p "请输入:" pick
if [[ ! ${pick} =~ [1-$print_number] ]];then
exit
fi
declare file_path
read -p "请输入软件储存位置,默认 /var/www/${print_array[${pick}]} " file_path
if [[ -z ${file_path} ]];then
file_path="/var/www/${print_array[${pick}]}"
fi
if [[ ! -d "$file_path" ]];then
sudo mkdir -p "$file_path" || { echo "目录创建失败"; exit 1; }
elif [[ ! -z "$(find "$file_path" -mindepth 1 -print -quit)" ]];then
echo "该目录存有文件"
exit
fi
declare dport=$(($RANDOM % 9000 + 1000))
while ss -tuln | grep $dport &> /dev/null
do
dport=$(($RANDOM % 9000 + 1000))
done
declare port
read -p "请输入访问端口,默认 $dport " port
if [[ -z $port ]];then
port=$dport
fi
if ss -tuln | grep $port &> /dev/null;then
echo "端口已被占用"
exit
fi
bash "${path_local}/${print_array[pick]}.sh" "$file_path" "$port"
echo "${print_array[${pick}]}安装完成,访问端口${port}"

5
Config/Docker/test.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
if ! command -v docker &> /dev/null; then
echo "docker未安装"
exit 1
fi

View File

@ -2,10 +2,6 @@
declare path_script=$1 declare path_script=$1
declare file_name=$(basename $0 .sh) declare file_name=$(basename $0 .sh)
if ! command -v docker &> /dev/null; then
echo "docker未安装"
exit
fi
declare pick_array declare pick_array
declare pick_number=6 declare pick_number=6
@ -58,40 +54,7 @@ elif [[ $pick == '2' ]];then
docker system prune -af docker system prune -af
echo "清理完成" echo "清理完成"
elif [[ "${pick}" =~ [${pick_number}-${#pick_array[*]}] ]];then elif [[ "${pick}" =~ [${pick_number}-${#pick_array[*]}] ]];then
declare file_path
read -p "请输入软件储存位置,默认 /var/www/${pick_array[${pick}]} " file_path
if [[ -z ${file_path} ]];then
file_path="/var/www/${pick_array[${pick}]}"
fi
if [[ ! -d "$file_path" ]];then
sudo mkdir -p "$file_path" || { echo "目录创建失败"; exit 1; }
elif [[ ! -z "$(find "$file_path" -mindepth 1 -print -quit)" ]];then
echo "该目录存有文件"
exit
fi
declare dport=$(($RANDOM % 9000 + 1000))
while ss -tuln | grep $dport &> /dev/null
do
dport=$(($RANDOM % 9000 + 1000))
done
declare port
read -p "请输入访问端口,默认 $dport " port
if [[ -z $port ]];then
port=$dport
fi
if ss -tuln | grep $port &> /dev/null;then
echo "端口已被占用"
exit
fi
bash "${path_script}/Config/${file_name}/${pick_array[${pick}]}.sh" "$file_path" "$port"
echo "${pick_array[${pick}]}安装完成,访问端口${port}"
fi fi

4
Run.sh
View File

@ -17,8 +17,12 @@ while true
do 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"
if [[ $? -eq 1 ]]; then
path_local=$path_script
fi
fi fi
if [[ -e "${path_local}/menu.sh" ]]; then if [[ -e "${path_local}/menu.sh" ]]; then
clear
bash "${path_local}/menu.sh" "$path_local" bash "${path_local}/menu.sh" "$path_local"
path_local=$path_script path_local=$path_script
fi fi