diff --git a/Config/Automation/backup.sh b/Config/Automation/backup.sh index 51f3b9b..455c401 100644 --- a/Config/Automation/backup.sh +++ b/Config/Automation/backup.sh @@ -19,7 +19,7 @@ for item in "$web_path"/* ; do echo "${item_name}" done -echo "请输入需要屏蔽的目录用逗号隔开" +echo "请输入需要屏蔽的目录用 空格 隔开" read -p "请输入:" ignore diff --git a/Config/Automation/menu.sh b/Config/Automation/menu.sh index d2cf682..9b4ad60 100644 --- a/Config/Automation/menu.sh +++ b/Config/Automation/menu.sh @@ -7,7 +7,7 @@ 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" ]]; then + if [[ $file_name == "test" || $file_name == "menu" ]]; then continue fi print_number=$((print_number + 1)) diff --git a/Config/Docker/Alist.sh b/Config/Docker/Software/Alist.sh similarity index 100% rename from Config/Docker/Alist.sh rename to Config/Docker/Software/Alist.sh diff --git a/Config/Docker/Gitea.sh b/Config/Docker/Software/Gitea.sh similarity index 100% rename from Config/Docker/Gitea.sh rename to Config/Docker/Software/Gitea.sh diff --git a/Config/Docker/Nginx-proxy-manager.sh b/Config/Docker/Software/Nginx-proxy-manager.sh similarity index 100% rename from Config/Docker/Nginx-proxy-manager.sh rename to Config/Docker/Software/Nginx-proxy-manager.sh diff --git a/Config/Docker/Safeline.sh b/Config/Docker/Software/Safeline.sh similarity index 100% rename from Config/Docker/Safeline.sh rename to Config/Docker/Software/Safeline.sh diff --git a/Config/Docker/Siyuan.sh b/Config/Docker/Software/Siyuan.sh similarity index 100% rename from Config/Docker/Siyuan.sh rename to Config/Docker/Software/Siyuan.sh diff --git a/Config/Docker/Typecho.sh b/Config/Docker/Software/Typecho.sh similarity index 100% rename from Config/Docker/Typecho.sh rename to Config/Docker/Software/Typecho.sh diff --git a/Config/Docker/Vaultwarden.sh b/Config/Docker/Software/Vaultwarden.sh similarity index 100% rename from Config/Docker/Vaultwarden.sh rename to Config/Docker/Software/Vaultwarden.sh diff --git a/Config/Docker/Xboard.sh b/Config/Docker/Software/Xboard.sh similarity index 100% rename from Config/Docker/Xboard.sh rename to Config/Docker/Software/Xboard.sh diff --git a/Config/Docker/Software/menu.sh b/Config/Docker/Software/menu.sh new file mode 100644 index 0000000..0fb15cf --- /dev/null +++ b/Config/Docker/Software/menu.sh @@ -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}" \ No newline at end of file diff --git a/Config/Docker/test.sh b/Config/Docker/test.sh new file mode 100644 index 0000000..957ddf8 --- /dev/null +++ b/Config/Docker/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash +if ! command -v docker &> /dev/null; then + echo "docker未安装" + exit 1 +fi diff --git a/Menus/Docker.sh b/Menus/Docker.sh index eb2551e..f653539 100644 --- a/Menus/Docker.sh +++ b/Menus/Docker.sh @@ -2,10 +2,6 @@ declare path_script=$1 declare file_name=$(basename $0 .sh) -if ! command -v docker &> /dev/null; then - echo "docker未安装" - exit -fi declare pick_array declare pick_number=6 @@ -58,40 +54,7 @@ elif [[ $pick == '2' ]];then docker system prune -af echo "清理完成" 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 diff --git a/Run.sh b/Run.sh index a84ee08..4ad3337 100644 --- a/Run.sh +++ b/Run.sh @@ -17,8 +17,12 @@ while true do if [[ -e "${path_local}/test.sh" ]]; then bash "${path_local}/test.sh" + if [[ $? -eq 1 ]]; then + path_local=$path_script + fi fi if [[ -e "${path_local}/menu.sh" ]]; then + clear bash "${path_local}/menu.sh" "$path_local" path_local=$path_script fi