From 2ae7fcbfdbcb029d627fffb2aa565d4cac0bfa27 Mon Sep 17 00:00:00 2001 From: lsy Date: Fri, 22 Nov 2024 20:10:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dnginx=E5=AE=89=E8=A3=85?= =?UTF-8?q?=EF=BC=8C=E5=B0=9D=E8=AF=95=E4=B8=8D=E7=94=A8=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E4=BD=BF=E7=94=A8alist=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=96=87=E4=BB=B6=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Manage/install.sh | 15 ++- Config/{Other => System/Basic}/bbr_open.sh | 0 Config/{Other => System/Basic}/language.sh | 0 Config/{Other => System/Basic}/reinstall.sh | 0 .../manage.sh => System/User/account.sh} | 0 Config/{ => System}/User/key.sh | 0 Config/{ => System}/User/ssh.sh | 0 Config/{ => System}/User/test.sh | 0 .../Installs/acme_update.sh | 0 .../{Automation => Task}/Installs/backup.sh | 0 Config/{Automation => Task}/Installs/menu.sh | 0 .../Installs/up-docker_compose.sh | 0 .../{Automation => Task}/Installs/update.sh | 0 Config/{Automation => Task}/manage.sh | 0 Config/Web/nginx/install.sh | 18 ++- README.md | 123 +++++++++--------- 16 files changed, 84 insertions(+), 72 deletions(-) rename Config/{Other => System/Basic}/bbr_open.sh (100%) rename Config/{Other => System/Basic}/language.sh (100%) rename Config/{Other => System/Basic}/reinstall.sh (100%) rename Config/{User/manage.sh => System/User/account.sh} (100%) rename Config/{ => System}/User/key.sh (100%) rename Config/{ => System}/User/ssh.sh (100%) rename Config/{ => System}/User/test.sh (100%) rename Config/{Automation => Task}/Installs/acme_update.sh (100%) rename Config/{Automation => Task}/Installs/backup.sh (100%) rename Config/{Automation => Task}/Installs/menu.sh (100%) rename Config/{Automation => Task}/Installs/up-docker_compose.sh (100%) rename Config/{Automation => Task}/Installs/update.sh (100%) rename Config/{Automation => Task}/manage.sh (100%) diff --git a/Config/Manage/install.sh b/Config/Manage/install.sh index ff0c33a..6cb4718 100644 --- a/Config/Manage/install.sh +++ b/Config/Manage/install.sh @@ -20,7 +20,6 @@ if ! command -v git &> /dev/null; then fi fi - declare path echo "请输入脚本的安装位置" read -p "默认 /var/script:" path @@ -69,18 +68,22 @@ update_alias() { if [[ -e "$file" ]]; then sed -i '/alias tool.*/d' "$file" echo "alias tool='$path/linuxtool/run.sh'" >> "$file" - source "$file" &> /dev/null fi } +shopt -s expand_aliases +alias tool="$path/linuxtool/run.sh" +export -f tool 2>/dev/null || true + for file in "${HOME}/.bashrc" "${HOME}/.profile" "${HOME}/.zshrc" "/etc/profile"; do update_alias "$file" done -alias tool="$path/linuxtool/run.sh" - - echo "工具箱已经安装成功" echo "位置:${path}/linuxtool" echo "命令:tool" -kill $PPID &> /dev/null \ No newline at end of file + + +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + kill $PPID &> /dev/null +fi \ No newline at end of file diff --git a/Config/Other/bbr_open.sh b/Config/System/Basic/bbr_open.sh similarity index 100% rename from Config/Other/bbr_open.sh rename to Config/System/Basic/bbr_open.sh diff --git a/Config/Other/language.sh b/Config/System/Basic/language.sh similarity index 100% rename from Config/Other/language.sh rename to Config/System/Basic/language.sh diff --git a/Config/Other/reinstall.sh b/Config/System/Basic/reinstall.sh similarity index 100% rename from Config/Other/reinstall.sh rename to Config/System/Basic/reinstall.sh diff --git a/Config/User/manage.sh b/Config/System/User/account.sh similarity index 100% rename from Config/User/manage.sh rename to Config/System/User/account.sh diff --git a/Config/User/key.sh b/Config/System/User/key.sh similarity index 100% rename from Config/User/key.sh rename to Config/System/User/key.sh diff --git a/Config/User/ssh.sh b/Config/System/User/ssh.sh similarity index 100% rename from Config/User/ssh.sh rename to Config/System/User/ssh.sh diff --git a/Config/User/test.sh b/Config/System/User/test.sh similarity index 100% rename from Config/User/test.sh rename to Config/System/User/test.sh diff --git a/Config/Automation/Installs/acme_update.sh b/Config/Task/Installs/acme_update.sh similarity index 100% rename from Config/Automation/Installs/acme_update.sh rename to Config/Task/Installs/acme_update.sh diff --git a/Config/Automation/Installs/backup.sh b/Config/Task/Installs/backup.sh similarity index 100% rename from Config/Automation/Installs/backup.sh rename to Config/Task/Installs/backup.sh diff --git a/Config/Automation/Installs/menu.sh b/Config/Task/Installs/menu.sh similarity index 100% rename from Config/Automation/Installs/menu.sh rename to Config/Task/Installs/menu.sh diff --git a/Config/Automation/Installs/up-docker_compose.sh b/Config/Task/Installs/up-docker_compose.sh similarity index 100% rename from Config/Automation/Installs/up-docker_compose.sh rename to Config/Task/Installs/up-docker_compose.sh diff --git a/Config/Automation/Installs/update.sh b/Config/Task/Installs/update.sh similarity index 100% rename from Config/Automation/Installs/update.sh rename to Config/Task/Installs/update.sh diff --git a/Config/Automation/manage.sh b/Config/Task/manage.sh similarity index 100% rename from Config/Automation/manage.sh rename to Config/Task/manage.sh diff --git a/Config/Web/nginx/install.sh b/Config/Web/nginx/install.sh index 407f2a0..fd78c19 100644 --- a/Config/Web/nginx/install.sh +++ b/Config/Web/nginx/install.sh @@ -4,30 +4,34 @@ read -p "请输入要绑定的域名(多个用空格隔开):" domain_names declare ssl_cert_path declare ssl_key_path declare primary_domain=$(echo "${domain_names}" | awk '{print $1}') - +declare folder_domain echo "SSL证书选择" echo "1.自动申请(默认)" echo "2.手动输入" read -p "请输入选择:" user_choice if [[ $user_choice == 2 ]]; then - echo "证书路径, 默认 ${HOME}/.acme.sh/${primary_domain}_ecc/fullchain.cer" + + folder_domain=$(ls ${HOME}/.acme.sh/ | grep "^${primary_domain}" | head -n1) + echo "证书路径, 默认 ${HOME}/.acme.sh/${folder_domain:-"${primary_domain}_ecc"}/fullchain.cer" read -p "请输入证书地址:" ssl_cert_path if [[ -z $ssl_cert_path ]];then - ssl_cert_path="${HOME}/.acme.sh/${primary_domain}_ecc/fullchain.cer" + ssl_cert_path="${HOME}/.acme.sh/${folder_domain:-"${primary_domain}_ecc"}/fullchain.cer" + fi - echo "密钥路径, 默认 ${HOME}/.acme.sh/${primary_domain}_ecc/${primary_domain}.key" + echo "密钥路径, 默认 ${HOME}/.acme.sh/${folder_domain:-"${primary_domain}_ecc"}/${primary_domain}.key" read -p "请输入密钥地址:" ssl_key_path if [[ -z $ssl_key_path ]];then - ssl_key_path="${HOME}/.acme.sh/${primary_domain}_ecc/${primary_domain}.key" + ssl_key_path="${HOME}/.acme.sh/${folder_domain:-"${primary_domain}_ecc"}/${primary_domain}.key" fi else echo "1.nginx(默认)" read -p "请选择:" user_choice bash "$(dirname $(dirname $0))/acme/test.sh" bash "$(dirname $(dirname $0))/acme/apply.sh" "nginx" "${domain_names}" - ssl_cert_path="${HOME}/.acme.sh/${primary_domain}_ecc/fullchain.cer" - ssl_key_path="${HOME}/.acme.sh/${primary_domain}_ecc/${primary_domain}.key" + folder_domain=$(ls ${HOME}/.acme.sh/ | grep "${primary_domain}") + ssl_cert_path="${HOME}/.acme.sh/${folder_domain}/fullchain.cer" + ssl_key_path="${HOME}/.acme.sh/${folder_domain}/${primary_domain}.key" fi declare config_file_name diff --git a/README.md b/README.md index ac38380..4411177 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,77 @@ -## 功能概述 +# 🛠 Linux 服务器管理工具箱 -### 1. Automation(自动化脚本管理) -- **作用**:管理和执行各种自动化任务。 -- **主要文件**: - - `manage.sh`:用户管理脚本。 - - `acme_update.sh`:更新 ACME 脚本和续订证书。 - - `backup.sh`:数据备份,支持多种备份方式。 - - `menu.sh`:交互式菜单,选择执行功能。 - - `up-docker_compose.sh`:更新 Docker Compose 服务。 - - `update.sh`:自动更新系统包管理器配置。 +一个功能强大的 Linux 服务器运维管理工具集,提供图形化菜单界面,简化各类运维任务。 -### 2. Docker(Docker 相关功能) -- **作用**:Docker 功能和服务管理。 -- **主要文件**: - - `image.sh`:管理 Docker 镜像。 - - `manage.sh`:Docker 服务管理。 - - `source.sh`:配置 Docker 镜像源。 - - `test.sh`:检查 Docker 安装。 - - `alist.sh`、`gitea.sh`、`nginx-proxy-manager.sh`、`safeline.sh`、`siyuan.sh`、`typecho.sh`、`vaultwarden.sh`、`xboard.sh`:安装和配置不同 Docker 应用。 +## ✨ 主要特性 -### 3. Manage(系统管理) -- **作用**:系统管理相关功能。 -- **主要文件**: - - `install.sh`:安装和配置系统工具。 - - `unInstall.sh`:卸载系统工具和清理配置。 +- 🎯 智能环境检测,自动安装依赖 +- 🎨 中文交互式菜单界面 +- 📦 模块化设计,功能可扩展 +- 🔒 安全可靠,支持权限控制 +- 🚀 一键部署常用服务 -### 4. Other(其他功能) -- **作用**:其他实用功能。 -- **主要文件**: - - `bbr_open.sh`:开启 BBR 加速。 - - `language.sh`:更改系统语言设置。 - - `reinstall.sh`:重新安装系统工具。 +## 🔧 核心功能 -### 5. User(用户管理) -- **作用**:用户和权限管理功能。 -- **主要文件**: - - `key.sh`:管理 SSH 密钥。 - - `manage.sh`:用户管理功能。 - - `ssh.sh`:管理和配置 SSH 服务。 - - `test.sh`:检查 SSH 客户端安装。 +### 系统管理 +- 用户账号管理 +- SSH 安全配置 +- 系统重装 +- BBR 网络加速 +- 语言环境设置 -### 6. Web(网页相关功能) -- **作用**:网页相关功能。 -- **主要文件**: - - `acme`:SSL 证书管理脚本。 - - `apply.sh`:申请 SSL 证书。 - - `manage.sh`:管理已申请证书。 - - `test.sh`:测试 SSL 证书有效性。 - - `nginx`:Nginx 配置相关脚本。 - - `install.sh`:安装 Nginx。 - - `manage.sh`:管理 Nginx 配置。 - - `test.sh`:测试 Nginx 是否正常运行。 +### Docker 应用 +一键部署以下应用: +- Alist (文件管理) +- Gitea (Git 服务器) +- Nginx Proxy Manager (反向代理) +- Safeline (WAF 防火墙) +- Siyuan (知识管理) +- Typecho (博客系统) +- Vaultwarden (密码管理) +- XBoard (代理面板) -### 7. Sources.sh(源管理) -- **作用**:管理软件源配置。 +### SSL 证书 +- 自动申请/续期 +- HTTP/DNS 验证 +- Cloudflare API 集成 -### 8. VPN(VPN 管理) -- **作用**:VPN 服务的安装 +### Web 服务 +- Nginx 配置管理 +- 站点管理 +- 反向代理设置 -### 9. Software(软件管理) -- **作用**:安装常用软件包。 +### 自动化任务 +- 系统更新 +- 数据备份(支持网盘) +- Docker 服务更新 +- 证书自动续期 +### 软件源管理 +- 智能切换镜像源 +- 自动更新软件源 -### 菜单机制 -该系统通过菜单提供用户友好的界面,允许用户选择可用脚本执行。菜单机制包括以下两个子功能: +## 💻 安装方法 -#### 1. test 菜单 -- **功能**:执行特定测试脚本,验证系统功能正常。 +### 快速安装 +```bash +wget -O install.sh https://raw.githubusercontent.com/lsy2246/linuxtool/main/install.sh && bash install.sh +``` -#### 2. menu 菜单 -- **功能**:用户友好的界面,选择可用脚本执行。 +### 使用说明 +1. 运行安装脚本 +2. 选择安装位置(默认 /var/script) +3. 重新连接终端 +4. 输入 `tool` 启动工具箱 + +## 🔍 系统要求 + +- 系统: Debian/Ubuntu/Arch Linux +- 权限: root 权限 +- 内核: Linux 5.0+ +- 工具: curl/wget + +## 📝 问题反馈 + +如有问题或建议: +- 提交 Issue +- 关注公众号: lsy22