Skip to content

Commit 08485e4

Browse files
Meo597yuhan6665
authored andcommitted
OpenRC: Improved syntax and update README
1 parent b5e8fdf commit 08485e4

File tree

6 files changed

+25
-95
lines changed

6 files changed

+25
-95
lines changed

README_zh-Hans.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
用于在支持 systemd 的操作系统(如 CentOS / Debian / OpenSUSE)中安装 Xray 的 Bash 脚本。
66

7-
**对于 Alpine Linux 用户**,请参考 **[Alpine Linux 专用说明](alpinelinux/README_zh-Hans.md)** 以获取适用于 Alpine Linux 的安装脚本和指南。
7+
**对于 Alpine 及 Gentoo Linux 用户**,请参考 **[OpenRC 专用说明](alpinelinux/README_zh-Hans.md)** 以获取适用于 Alpine/Gentoo Linux 的安装脚本和指南。
88

99
---
1010

README_zh-Hant.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
用於在支持 systemd 的作業系統(如 CentOS / Debian / OpenSUSE)中安裝 Xray 的 Bash 腳本。
66

7-
**對於 Alpine Linux 使用者**請參考 **[Alpine Linux 專用說明](alpinelinux/README_zh-Hant.md)** 以獲取適用於 Alpine Linux 的安裝腳本和指南
7+
**針對 Alpine 及 Gentoo Linux 使用者**請參閱 **[OpenRC 專用說明](alpinelinux/README_zh-Hant.md)** 以獲取適用於 Alpine/Gentoo Linux 的安裝腳本與指南
88

99
---
1010

alpinelinux/README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,3 @@ rc-service xray stop
5353
```sh
5454
rc-service xray restart
5555
```
56-
57-
## Breaking Changes at 2025-04-09
58-
59-
#### Path Change: Original path `/usr/local/lib/xray/` has been updated to new path `/usr/local/share/xray/`
60-
61-
- This directory contains `geosite.dat` and `geoip.dat`
62-
- If you have scripts to automatically update these files, please adjust them accordingly
63-
- Regular users can ignore this change
64-
65-
#### Watchdog: Xray process will now automatically restart indefinitely (every 5 seconds) upon panic, unless it panic 3 times in 10 minutes
66-
67-
- Advanced users no longer need to manually modify `/etc/init.d/xray` or write custom daemon scripts
68-
- Regular users can ignore this change
69-
70-
#### No `root` Required: Xray now retains privileges (capabilities) to support `tproxy` and `sockopt` even when running as `nobody`
71-
72-
- Advanced users **should not** (and need not) run Xray as `root` anymore — it already has all required network privileges
73-
- 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
74-
- Regular users can ignore this change
75-
76-
```sh
77-
sed -i 's/^capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"$/capabilities="^cap_net_bind_service"/g' /etc/init.d/xray
78-
```

alpinelinux/README_zh-Hans.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,3 @@ rc-service xray stop
5353
```sh
5454
rc-service xray restart
5555
```
56-
57-
## 重大更改 at 2025-04-09
58-
59-
#### 路径变更:原路径 `/usr/local/lib/xray/` 变更为 新路径 `/usr/local/share/xray/`
60-
61-
- 此目录存放了 `geosite.dat``geoip.dat`
62-
- 如果你编写了一些脚本来自动更新这些文件,需要留意此项改动
63-
- 普通用户无需关注此改动
64-
65-
#### 看门狗:若 Xray 进程 `panic` 将无限自动重启,间隔 5 秒,除非 10 分钟内崩溃 3 次
66-
67-
- 对于高级用户,你无需再手动调整 `/etc/init.d/xray` 或自己编写 daemon 脚本了
68-
- 普通用户无需关注此改动
69-
70-
#### 无需 `root`:已为 Xray 授予特权,即便以 `nobody` 身份运行也支持 `tproxy``sockopt`
71-
72-
- 对于高级用户,你无需、也**不应该**再让 Xray 以 `root` 身份运行,现在它们已具备所有网络特权
73-
- 如果你的 Xray 作为**节点**而不是客户端运行,或*可考虑*执行下面的命令撤销部分网络特权。理论上可以降低攻击面,实际上无关痛痒
74-
- 普通用户无需关注此改动
75-
76-
```sh
77-
sed -i 's/^capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"$/capabilities="^cap_net_bind_service"/g' /etc/init.d/xray
78-
```

alpinelinux/README_zh-Hant.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,3 @@ rc-service xray stop
5353
```sh
5454
rc-service xray restart
5555
```
56-
57-
## 重大變更 at 2025-04-09
58-
59-
#### 路徑變更:原始路徑 `/usr/local/lib/xray/` 變更為 新路徑 `/usr/local/share/xray/`
60-
61-
- 此目錄存放了 `geosite.dat``geoip.dat`
62-
- 如果你編寫了一些腳本來自動更新這些文件,需要留意此項改動
63-
- 普通用戶無需關注此改動
64-
65-
#### 看門狗:若 Xray 進程 `panic` 將無限自動重啟,間隔 5 秒,除非 10 分鐘內崩潰 3 次
66-
67-
- 對於高級用戶,你無需再手動調整 `/etc/init.d/xray` 或自己編寫 daemon 腳本了
68-
- 普通用戶無需關注此改動
69-
70-
#### 無需 `root`:已為 Xray 授予特權,即便以 `nobody` 身分執行也支援 `tproxy``sockopt`
71-
72-
- 對於高級用戶,你無需、也**不應該**再讓 Xray 以 `root` 身份運行,現在它們已具備所有網絡特權
73-
- 如果你的 Xray 是作為**節點**而不是客戶端運行,或*可考慮*執行下面的命令撤銷部分網路特權。理論上可以降低攻擊面,實際上無關痛癢
74-
- 普通用戶無需關注此改動
75-
76-
```sh
77-
sed -i 's/^capabilities="^cap_net_bind_service,^cap_net_admin,^cap_net_raw"$/capabilities="^cap_net_bind_service"/g' /etc/init.d/xray
78-
```

alpinelinux/install-release.sh

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,32 @@
44
set -euo pipefail
55

66
pkg_manager() {
7-
local OP="$1" PM=apk
8-
shift
9-
if [ -f /etc/gentoo-release ]; then
10-
PM=emerge
11-
case "$OP" in
12-
add)
13-
OP='-v'
14-
;;
15-
del)
16-
OP='-C'
17-
;;
18-
esac
19-
fi
20-
if [ -z "$@" ]; then
21-
echo "$PM $OP"
22-
else
23-
$PM $OP $@
24-
fi
7+
local OP="$1" PM=apk
8+
shift
9+
if [ -f /etc/gentoo-release ]; then
10+
PM=emerge
11+
case "$OP" in
12+
add)
13+
OP='-v'
14+
;;
15+
del)
16+
OP='-C'
17+
;;
18+
esac
19+
fi
20+
if [ $# -eq 0 ]; then
21+
echo "$PM $OP"
22+
else
23+
$PM "$OP" "$@"
24+
fi
2525
}
2626

27-
28-
check_distr() {
27+
check_distro() {
2928
if [ -z "$(command -v rc-service)" ]; then
30-
echo "No OpenRC init-system detected"
29+
echo "No OpenRC init-system detected."
3130
return 1
3231
fi
33-
if [ -f /etc/alpine-release -o -f /etc/gentoo-release ]; then
32+
if [ -f /etc/alpine-release ] || [ -f /etc/gentoo-release ]; then
3433
return 0
3534
else
3635
return 1
@@ -117,7 +116,7 @@ install_dependencies() {
117116
fi
118117
if [ "$(command -v apk)" ]; then
119118
echo "Installing required dependencies..."
120-
pkg_manager add curl unzip #to generalize installation procedure
119+
pkg_manager add curl unzip # to generalize installation procedure
121120
else
122121
echo "error: The script does not support the package manager in this operating system."
123122
exit 1
@@ -238,7 +237,7 @@ information() {
238237
}
239238

240239
main() {
241-
check_distr || return 1
240+
check_distro || return 1
242241
check_if_running_as_root || return 1
243242
identify_architecture || return 1
244243
install_dependencies

0 commit comments

Comments
 (0)