From 08485e44b3b70b6bda899daffc86c3cbd8e32792 Mon Sep 17 00:00:00 2001 From: Meo597 <197331664+Meo597@users.noreply.github.com> Date: Mon, 24 Nov 2025 08:46:09 +0800 Subject: [PATCH] OpenRC: Improved syntax and update README --- README_zh-Hans.md | 2 +- README_zh-Hant.md | 2 +- alpinelinux/README.md | 23 ----------------- alpinelinux/README_zh-Hans.md | 23 ----------------- alpinelinux/README_zh-Hant.md | 23 ----------------- alpinelinux/install-release.sh | 47 +++++++++++++++++----------------- 6 files changed, 25 insertions(+), 95 deletions(-) diff --git a/README_zh-Hans.md b/README_zh-Hans.md index 447dcfe..e1f1b1f 100644 --- a/README_zh-Hans.md +++ b/README_zh-Hans.md @@ -4,7 +4,7 @@ 用于在支持 systemd 的操作系统(如 CentOS / Debian / OpenSUSE)中安装 Xray 的 Bash 脚本。 -**对于 Alpine Linux 用户**,请参考 **[Alpine Linux 专用说明](alpinelinux/README_zh-Hans.md)** 以获取适用于 Alpine Linux 的安装脚本和指南。 +**对于 Alpine 及 Gentoo Linux 用户**,请参考 **[OpenRC 专用说明](alpinelinux/README_zh-Hans.md)** 以获取适用于 Alpine/Gentoo Linux 的安装脚本和指南。 --- diff --git a/README_zh-Hant.md b/README_zh-Hant.md index e47b1e8..92172ef 100644 --- a/README_zh-Hant.md +++ b/README_zh-Hant.md @@ -4,7 +4,7 @@ 用於在支持 systemd 的作業系統(如 CentOS / Debian / OpenSUSE)中安裝 Xray 的 Bash 腳本。 -**對於 Alpine Linux 使用者**,請參考 **[Alpine Linux 專用說明](alpinelinux/README_zh-Hant.md)** 以獲取適用於 Alpine Linux 的安裝腳本和指南。 +**針對 Alpine 及 Gentoo Linux 使用者**,請參閱 **[OpenRC 專用說明](alpinelinux/README_zh-Hant.md)** 以獲取適用於 Alpine/Gentoo Linux 的安裝腳本與指南。 --- diff --git a/alpinelinux/README.md b/alpinelinux/README.md index 5129971..5ba5f1e 100644 --- a/alpinelinux/README.md +++ b/alpinelinux/README.md @@ -53,26 +53,3 @@ rc-service xray stop ```sh rc-service xray restart ``` - -## Breaking Changes at 2025-04-09 - -#### Path Change: Original path `/usr/local/lib/xray/` has been updated to new path `/usr/local/share/xray/` - -- This directory contains `geosite.dat` and `geoip.dat` -- If you have scripts to automatically update these files, please adjust them accordingly -- Regular users can ignore this change - -#### Watchdog: Xray process will now automatically restart indefinitely (every 5 seconds) upon panic, unless it panic 3 times in 10 minutes - -- Advanced users no longer need to manually modify `/etc/init.d/xray` or write custom daemon scripts -- Regular users can ignore this change - -#### No `root` Required: Xray now retains privileges (capabilities) to support `tproxy` and `sockopt` even when running as `nobody` - -- Advanced users **should not** (and need not) run Xray as `root` anymore — it already has all required network privileges -- If you run Xray as a **server** (not client), you _may_ optionally run the command below to reduce capabilities. This theoretically minimizes attack surface but has negligible practical impact -- Regular users can ignore this change - -```sh -sed -i 's/^capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"$/capabilities="^cap_net_bind_service"/g' /etc/init.d/xray -``` diff --git a/alpinelinux/README_zh-Hans.md b/alpinelinux/README_zh-Hans.md index b7cc347..a5d8280 100644 --- a/alpinelinux/README_zh-Hans.md +++ b/alpinelinux/README_zh-Hans.md @@ -53,26 +53,3 @@ rc-service xray stop ```sh rc-service xray restart ``` - -## 重大更改 at 2025-04-09 - -#### 路径变更:原路径 `/usr/local/lib/xray/` 变更为 新路径 `/usr/local/share/xray/` - -- 此目录存放了 `geosite.dat` 和 `geoip.dat` -- 如果你编写了一些脚本来自动更新这些文件,需要留意此项改动 -- 普通用户无需关注此改动 - -#### 看门狗:若 Xray 进程 `panic` 将无限自动重启,间隔 5 秒,除非 10 分钟内崩溃 3 次 - -- 对于高级用户,你无需再手动调整 `/etc/init.d/xray` 或自己编写 daemon 脚本了 -- 普通用户无需关注此改动 - -#### 无需 `root`:已为 Xray 授予特权,即便以 `nobody` 身份运行也支持 `tproxy` 和 `sockopt` - -- 对于高级用户,你无需、也**不应该**再让 Xray 以 `root` 身份运行,现在它们已具备所有网络特权 -- 如果你的 Xray 作为**节点**而不是客户端运行,或*可考虑*执行下面的命令撤销部分网络特权。理论上可以降低攻击面,实际上无关痛痒 -- 普通用户无需关注此改动 - -```sh -sed -i 's/^capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"$/capabilities="^cap_net_bind_service"/g' /etc/init.d/xray -``` diff --git a/alpinelinux/README_zh-Hant.md b/alpinelinux/README_zh-Hant.md index e3bb7a4..2725926 100644 --- a/alpinelinux/README_zh-Hant.md +++ b/alpinelinux/README_zh-Hant.md @@ -53,26 +53,3 @@ rc-service xray stop ```sh rc-service xray restart ``` - -## 重大變更 at 2025-04-09 - -#### 路徑變更:原始路徑 `/usr/local/lib/xray/` 變更為 新路徑 `/usr/local/share/xray/` - -- 此目錄存放了 `geosite.dat` 和 `geoip.dat` -- 如果你編寫了一些腳本來自動更新這些文件,需要留意此項改動 -- 普通用戶無需關注此改動 - -#### 看門狗:若 Xray 進程 `panic` 將無限自動重啟,間隔 5 秒,除非 10 分鐘內崩潰 3 次 - -- 對於高級用戶,你無需再手動調整 `/etc/init.d/xray` 或自己編寫 daemon 腳本了 -- 普通用戶無需關注此改動 - -#### 無需 `root`:已為 Xray 授予特權,即便以 `nobody` 身分執行也支援 `tproxy` 和 `sockopt` - -- 對於高級用戶,你無需、也**不應該**再讓 Xray 以 `root` 身份運行,現在它們已具備所有網絡特權 -- 如果你的 Xray 是作為**節點**而不是客戶端運行,或*可考慮*執行下面的命令撤銷部分網路特權。理論上可以降低攻擊面,實際上無關痛癢 -- 普通用戶無需關注此改動 - -```sh -sed -i 's/^capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"$/capabilities="^cap_net_bind_service"/g' /etc/init.d/xray -``` diff --git a/alpinelinux/install-release.sh b/alpinelinux/install-release.sh index b61d5b6..8a7cd02 100644 --- a/alpinelinux/install-release.sh +++ b/alpinelinux/install-release.sh @@ -4,33 +4,32 @@ set -euo pipefail pkg_manager() { - local OP="$1" PM=apk - shift - if [ -f /etc/gentoo-release ]; then - PM=emerge - case "$OP" in - add) - OP='-v' - ;; - del) - OP='-C' - ;; - esac - fi - if [ -z "$@" ]; then - echo "$PM $OP" - else - $PM $OP $@ - fi + local OP="$1" PM=apk + shift + if [ -f /etc/gentoo-release ]; then + PM=emerge + case "$OP" in + add) + OP='-v' + ;; + del) + OP='-C' + ;; + esac + fi + if [ $# -eq 0 ]; then + echo "$PM $OP" + else + $PM "$OP" "$@" + fi } - -check_distr() { +check_distro() { if [ -z "$(command -v rc-service)" ]; then - echo "No OpenRC init-system detected" + echo "No OpenRC init-system detected." return 1 fi - if [ -f /etc/alpine-release -o -f /etc/gentoo-release ]; then + if [ -f /etc/alpine-release ] || [ -f /etc/gentoo-release ]; then return 0 else return 1 @@ -117,7 +116,7 @@ install_dependencies() { fi if [ "$(command -v apk)" ]; then echo "Installing required dependencies..." - pkg_manager add curl unzip #to generalize installation procedure + pkg_manager add curl unzip # to generalize installation procedure else echo "error: The script does not support the package manager in this operating system." exit 1 @@ -238,7 +237,7 @@ information() { } main() { - check_distr || return 1 + check_distro || return 1 check_if_running_as_root || return 1 identify_architecture || return 1 install_dependencies