├── README.md ├── README_EN.md ├── install_deeplx.sh ├── make_info.sh └── set_env_vars.sh /README.md: -------------------------------------------------------------------------------- 1 | # DeepLX 部署与安装指南 2 | 3 | 本指南介绍如何在 FreeBSD (Serv00) 环境中使用 `pm2` 部署 [DeepLX](https://deeplx.owo.network),并详细说明脚本的运行步骤。DeepLX 是一个开源的翻译服务,兼容 DeepL API,允许用户在本地化环境中部署翻译服务。 4 | 5 | 【 [视频教程](https://www.bilibili.com/video/BV1e9bceoECw/) 】 6 | 7 | ## 项目简介 8 | 9 | DeepLX 是一个由 [OwO Network](https://deeplx.owo.network) 提供的 API 服务,能够模拟 DeepL 官方 API 进行翻译请求。用户可以选择开源的免费版本部署到本地,享受无限制的翻译请求服务。常见功能包括: 10 | - 翻译任意文本。 11 | - 支持设置 HTTP 代理。 12 | - 提供访问令牌保护 API。 13 | - 可选使用 DeepL Pro 的 `dl_session` 进行高级功能。 14 | 15 | ## 环境要求 16 | 17 | 1. FreeBSD 系统 (Serv00)。 18 | 19 | 20 | ## 安装步骤 21 | 22 | ### 0. 一键脚本 23 | ```bash 24 | git clone https://github.com/aigem/deeplx-freeAPI-serv00.git 25 | cd deeplx-freeAPI-serv00 26 | chmod +x install_deeplx.sh 27 | ./install_deeplx.sh 28 | ``` 29 | 30 | ### 1. 克隆项目代码 31 | 32 | 首先将项目克隆到用户主目录: 33 | ```bash 34 | git clone https://github.com/aigem/deeplx-freeAPI-serv00.git 35 | cd deeplx-freeAPI-serv00 36 | ``` 37 | 38 | ### 2. 赋予安装脚本执行权限 39 | ```bash 40 | chmod +x install_deeplx.sh 41 | ``` 42 | 43 | ### 3. 运行安装脚本 44 | 执行以下命令来自动部署 DeepLX: 45 | ```bash 46 | ./install_deeplx.sh 47 | ``` 48 | 49 | ### 4. 脚本执行流程 50 | 51 | - **系统设置**:脚本首先启用 FreeBSD 的二进制执行权限: 52 | 53 | - **下载最新的 DeepLX 版本**:通过 GitHub API 获取最新的 DeepLX 版本,并下载 FreeBSD 版本的二进制文件。 54 | 55 | - **端口管理**:提示用户输入已有的开放端口或通过 `devil` 自动开通新的端口。 56 | 57 | - **域名绑定**:脚本允许用户选择默认域名 (`$(whoami).serv00.net`) 或自定义域名进行绑定。使用 `devil www` 命令完成域名的重置和新建。 58 | 59 | - **安装并启动 pm2**:使用 `npm` 安装 `pm2`,并通过 `pm2` 管理 DeepLX 服务,保证在系统重启后自动启动。 60 | 61 | ## 使用说明 62 | 63 | [视频教程](https://www.bilibili.com/video/BV1e9bceoECw/) 64 | 65 | ### 命令行参数 66 | DeepLX 支持多种命令行参数,具体说明请参考 [DeepLX 变量文档](https://deeplx.owo.network/install/variables.html)【24†source】【25†source】。 67 | 68 | 常见命令行参数包括: 69 | 70 | - `-ip`:绑定服务的 IP 地址,默认为 `0.0.0.0`。 71 | - `-port`:设置服务监听的端口,默认值为 `1188`。 72 | - `-token`:设置访问 API 所需的令牌(可选)。 73 | - `-proxy`:设置 HTTP 代理服务器地址(可选)。 74 | - `-s`:设置 `dl_session` 用于 DeepL Pro 账户的高级功能(可选)。 75 | 76 | ### pm2 命令 77 | 你可以使用 `pm2` 命令查看和管理 DeepLX 服务的状态: 78 | ```bash 79 | pm2 list # 查看所有运行中的进程 80 | pm2 logs deeplx # 查看 DeepLX 的日志 81 | ``` 82 | 83 | ### 日志与排查 84 | 如果服务启动失败,可以通过 `pm2 logs deeplx` 查看详细日志排查问题。 85 | 86 | ## 常见问题 87 | 88 | - **DeepLX 无法启动**:检查所选端口是否已被占用,或者查看日志中是否存在错误。 89 | - **域名绑定失败**:确保域名正确配置 A 记录指向你的服务器 IP,检查 `devil www` 的操作日志。可系统后台进行设置。 90 | 91 | ## 许可证 92 | 93 | 此项目基于 [MIT 许可证](https://opensource.org/licenses/MIT) 进行发布。 94 | 95 | -------------------------------------------------------------------------------- /README_EN.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # DeepLX Installation and Setup on FreeBSD (Serv00) 4 | 5 | This guide provides step-by-step instructions to deploy the [DeepLX](https://github.com/OwO-Network/DeepLX) service on FreeBSD (Serv00) using `pm2` for process management. The script automates downloading, configuring, and starting the DeepLX service while binding it to a domain. 6 | 7 | ## Prerequisites 8 | 9 | 1. **FreeBSD** system (Serv00). 10 | 2. Installed tools: 11 | - `devil` for domain and port management. 12 | - `npm` for installing `pm2`. 13 | - Internet connection to download DeepLX binaries. 14 | 15 | ## Script Overview 16 | 17 | The script performs the following tasks: 18 | 19 | 1. Sets necessary system settings with `devil binexec on`. 20 | 2. Fetches the latest DeepLX version from GitHub and downloads the FreeBSD binary. 21 | 3. Asks for the port to bind the service or opens a new port using `devil`. 22 | 4. Prompts for domain binding, allowing you to use an existing domain or reset an old one. 23 | 5. Installs and configures `pm2` to manage the DeepLX service. 24 | 6. Starts DeepLX and saves the process state for future reboots. 25 | 26 | ## Installation Steps 27 | 28 | 1. **Clone or Download** this repository into your home directory: 29 | ```bash 30 | git clone https://github.com/aigem/deeplx-freeAPI-serv00.git 31 | cd deeplx-freeAPI-serv00 32 | ``` 33 | 34 | 2. **Make the install script executable**: 35 | ```bash 36 | chmod +x install_deeplx.sh 37 | ``` 38 | 39 | 3. **Run the script**: 40 | ```bash 41 | ./install_deeplx.sh 42 | ``` 43 | 44 | ## Customizing the Installation 45 | 46 | You can customize the following variables in the script: 47 | 48 | - **`API_TOKEN`**: If you have a token for the DeepLX API, set it here to protect your service. 49 | - **`DEEPLX_PORT`**: You can select an existing port or create a new one dynamically. 50 | - **Domain**: You can use an existing domain or reset your default domain (`$(whoami).serv00.net`). 51 | 52 | ## Troubleshooting 53 | 54 | - **DeepLX not starting**: Ensure the port you've selected is open and not in use. 55 | - **Domain binding issues**: If the domain fails to bind, check `devil www` for any errors and re-run the script to attempt the binding process again. 56 | - **PM2 logs**: You can view logs for the DeepLX service using the following command: 57 | ```bash 58 | pm2 logs deeplx 59 | ``` 60 | 61 | ## License 62 | 63 | This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). 64 | 65 | --- 66 | -------------------------------------------------------------------------------- /install_deeplx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 系统必要设置 4 | devil binexec on 5 | 6 | # 配置变量 7 | PROJECT_NAME="deeplx" 8 | GITHUB_REPO_NAME="deeplx-freeAPI-serv00" 9 | API_TOKEN="deeplx" 10 | USER_HOME="/usr/home/$(whoami)" 11 | BASH_PROFILE="$USER_HOME/.bash_profile" 12 | OK_SITE="待配置" 13 | 14 | # 色彩设置 15 | GREEN='\033[0;32m' 16 | RED='\033[0;31m' 17 | YELLOW='\033[1;33m' 18 | NC='\033[0m' # 无色彩 19 | 20 | # 输出信息 21 | function print_success { 22 | echo -e "${GREEN}$1${NC}" 23 | } 24 | 25 | function print_error { 26 | echo -e "${RED}$1${NC}" 27 | } 28 | 29 | function print_warning { 30 | echo -e "${YELLOW}$1${NC}" 31 | } 32 | 33 | # 生成 info.html 文件 34 | chmod +x ./make_info.sh 35 | print_success "生成 info.html 文件..." 36 | ./make_info.sh 37 | 38 | # 拷贝配置文件并设置权限 39 | cp "$USER_HOME/$GITHUB_REPO_NAME/set_env_vars.sh" "$USER_HOME/$PROJECT_NAME/set_env_vars.sh" 40 | chmod +x "$USER_HOME/$PROJECT_NAME/set_env_vars.sh" 41 | 42 | # 创建目录并获取最新版本的 DeepLX 43 | cd "$USER_HOME" 44 | mkdir -p "$USER_HOME/$PROJECT_NAME" 45 | 46 | last_version=$(curl -Ls "https://api.github.com/repos/OwO-Network/DeepLX/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') 47 | if [ -z "$last_version" ]; then 48 | print_error "无法获取 DeepLX 最新版本。" 49 | last_version="v0.9.7" 50 | print_error "使用默认版本进行安装。" 51 | fi 52 | 53 | print_success "DeepLX 安装版本: $last_version,开始安装..." 54 | 55 | # 下载并赋予执行权限 56 | fetch -o "$USER_HOME/deeplx/deeplx" "https://github.com/OwO-Network/DeepLX/releases/download/${last_version}/deeplx_freebsd_amd64" 57 | chmod +x "$USER_HOME/deeplx/deeplx" 58 | 59 | # 选择端口 60 | echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" 61 | print_warning "你在 Serv00 开通的端口号为: " 62 | devil port list 63 | read -p "请输入开通的端口号,或输入 'add' 来开通一个新的端口号: " user_input 64 | 65 | if [[ "$user_input" == "add" ]]; then 66 | devil port add tcp random 67 | devil port list 68 | read -r DEEPLX_PORT 69 | if [[ "$DEEPLX_PORT" -lt 1024 || "$DEEPLX_PORT" -gt 65535 ]]; then 70 | print_error "端口号不在有效范围内 (1024-65535)。" 71 | exit 1 72 | fi 73 | else 74 | DEEPLX_PORT="$user_input" 75 | if [[ "$DEEPLX_PORT" -lt 1024 || "$DEEPLX_PORT" -gt 65535 ]]; then 76 | print_error "端口号不在有效范围内 (1024-65535)。" 77 | exit 1 78 | fi 79 | print_success "选定端口为: $DEEPLX_PORT" 80 | fi 81 | 82 | # 网站绑定 83 | echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" 84 | print_warning "现需要绑定网站并指向 $DEEPLX_PORT" 85 | read -p "输入 'yes' 来重置网站 ($(whoami).serv00.net),或输入自定义域名,或输入 'no' 退出: " user_input 86 | 87 | if [[ "$user_input" == "yes" ]]; then 88 | print_success "开始重置网站..." 89 | DELETE_OUTPUT=$(devil www del "$(whoami).serv00.net") 90 | ADD_OUTPUT=$(devil www add "$(whoami).serv00.net" proxy localhost "$DEEPLX_PORT") 91 | if echo "$ADD_OUTPUT" | grep -q "Domain added succesfully"; then 92 | print_success "网站 $(whoami).serv00.net 成功重置。" 93 | OK_SITE="$(whoami).serv00.net" 94 | else 95 | print_error "新建网站失败,请之后检查。" 96 | fi 97 | elif [[ "$user_input" != "no" ]]; then 98 | custom_domain="$user_input" 99 | DELETE_OUTPUT=$(devil www del "$custom_domain") 100 | ADD_OUTPUT=$(devil www add "$custom_domain" proxy localhost "$DEEPLX_PORT") 101 | if echo "$ADD_OUTPUT" | grep -q "Domain added succesfully"; then 102 | print_success "网站 $custom_domain 成功绑定。" 103 | OK_SITE="$custom_domain" 104 | else 105 | print_error "新建网站失败,请之后检查。" 106 | fi 107 | else 108 | print_warning "跳过网站设置。" 109 | fi 110 | 111 | # 安装 PM2 112 | if [ ! -f "$USER_HOME/node_modules/pm2/bin/pm2" ]; then 113 | print_success "正在安装 PM2..." 114 | npm install pm2 115 | else 116 | print_success "PM2 已安装。" 117 | fi 118 | 119 | # 删除旧的 PM2 环境变量 120 | sed -i.bak '/export PATH=".*\/node_modules\/pm2\/bin:$PATH"/d' "$BASH_PROFILE" 121 | echo "export PATH=\"$USER_HOME/node_modules/pm2/bin:\$PATH\"" >> "$BASH_PROFILE" 122 | source "$BASH_PROFILE" 123 | 124 | # 启动 DeepLX 125 | pm2 start "$USER_HOME/deeplx/deeplx" --name deeplx -- -ip 0.0.0.0 -port "$DEEPLX_PORT" -token "$API_TOKEN" 126 | if pm2 list | grep -q "deeplx"; then 127 | print_success "DeepLX 启动成功,监听端口 $DEEPLX_PORT。" 128 | else 129 | print_error "DeepLX 启动失败。" 130 | exit 1 131 | fi 132 | 133 | # 保存 PM2 状态并配置重启自启 134 | pm2 save 135 | PM2_PATH=$(which pm2) 136 | # 清除所有与 pm2 相关的 @reboot 任务 137 | crontab -l | grep -v '@reboot.*pm2' | crontab - 138 | (crontab -l 2>/dev/null; echo "@reboot $PM2_PATH resurrect"; echo "@reboot /usr/home/$(whoami)/$PROJECT_NAME/set_env_vars.sh") | crontab - 139 | 140 | if [[ -f "$USER_HOME/domains/$OK_SITE/public_html/index.html" ]]; then 141 | rm "$USER_HOME/domains/$OK_SITE/public_html/index.html" 142 | fi 143 | 144 | print_success "DeepLX 安装完成,服务已启动,查看网站: $OK_SITE" -------------------------------------------------------------------------------- /make_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 用户目录 4 | PROJECT_NAME="deeplx" 5 | GITHUB_REPO_NAME="deeplx-freeAPI-serv00" 6 | USER_HOME="/usr/home/$(whoami)" 7 | BASH_PROFILE="$USER_HOME/.bash_profile" 8 | 9 | # 生成 info文件 10 | INFO_FILE="/usr/home/$(whoami)/$PROJECT_NAME/info.html" 11 | 12 | cat < "$INFO_FILE" 13 | 14 | 15 | 16 | 17 | 18 | WebDAV-go 安装成功 19 | 49 | 50 | 51 |
52 |

WebDAV 已成功安装

53 |

恭喜!WebDAV-go 已成功安装并运行在 $(whoami).serv00.net 上。当前的 WebDAV 服务正在 运行

54 |

打 开 网 盘

55 |

主要功能

56 | 61 | 62 |

进一步阅读

63 |

欲了解更多详细说明和安装步骤,请访问 GitHub 仓库:

64 |

WebDAV-go GitHub 仓库

65 | 66 |

常见问题

67 |

1. 如何启动及重启 WebDAV-go 服务?

68 |

使用以下命令恢复启动 PWebDAV-go:

69 |
pm2 resurrect
70 |

使用以下命令重启 PM2 中的所有服务:

71 |
pm2 restart all
72 | 73 |

2. 如何查看 WebDAV-go 的运行日志?

74 |

使用以下命令查看 PM2 的日志:

75 |
pm2 logs
76 | 77 |

3. 如何停止 WebDAV-go 服务?

78 |

使用以下命令停止服务:

79 |
pm2 stop WebDAV-go
80 | 81 |

4. 相关路径

82 |

网盘具体路径如下,更多详情请查看WebDAV-go GitHub 仓库

83 |
/usr/home/用户名/webdav//
84 |
85 | 86 | 87 | EOF -------------------------------------------------------------------------------- /set_env_vars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 系统重启后运行本脚本。 4 | 5 | # 定义用户目录 6 | USER_HOME="/usr/home/$(whoami)" 7 | BASH_PROFILE="$USER_HOME/.bash_profile" 8 | 9 | # 添加新的环境变量条目到 .bash_profile 10 | if ! grep -q 'export PATH="$USER_HOME/node_modules/pm2/bin:$PATH"' "$BASH_PROFILE"; then 11 | echo "export PATH=\"$USER_HOME/node_modules/pm2/bin:\$PATH\"" >> "$BASH_PROFILE" 12 | fi --------------------------------------------------------------------------------