Skip to content

Commit 24c94c0

Browse files
stackiaclaude
andcommitted
fix(install): use uclient-fetch and jsonfilter for OpenWrt compatibility
- Replace wget with uclient-fetch (OpenWrt's native HTTP client) - Replace grep/sed JSON parsing with jsonfilter for reliable parsing - uclient-fetch returns single-line JSON which broke grep/sed parsing - Update documentation commands to use uclient-fetch Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 9afb29e commit 24c94c0

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ https://github.com/user-attachments/assets/fedc0c28-f9ac-4675-9b19-a8efdd062506
7878
### OpenWrt 一键安装/更新
7979

8080
```bash
81-
wget -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
81+
uclient-fetch -q -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
8282
```
8383

8484
安装完成后,在 LuCI 管理界面的 "服务" 菜单中找到 "rtp2httpd" 进行配置。

docs/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ OpenWrt 是 rtp2httpd 的最佳运行环境。在完成 IPTV 网络融合后(
1313
使用一键安装脚本自动下载并安装最新版本。如果你已经安装了 rtp2httpd,重新运行脚本也可以一键更新到最新版。
1414

1515
```bash
16-
wget -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
16+
uclient-fetch -q -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
1717
```
1818

1919
脚本会自动:
@@ -26,7 +26,7 @@ wget -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/insta
2626
<summary>如果需要使用 prerelease 测试版本,点击查看命令</summary>
2727

2828
```bash
29-
wget -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh -s -- --prerelease
29+
uclient-fetch -q -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh -s -- --prerelease
3030
```
3131

3232
</details>

docs/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
使用一键安装脚本自动下载并安装最新版本:
66

77
```bash
8-
wget -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
8+
uclient-fetch -q -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
99
```
1010

1111
脚本会自动:

scripts/install-openwrt.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,17 @@ check_requirements() {
121121

122122
print_info "检测到包管理器: $PKG_MANAGER"
123123

124-
# 检查 wget
125-
if ! check_command wget; then
126-
print_error "未找到命令: wget"
127-
print_error "请先安装 wget 或 uclient-fetch"
124+
# 检查 uclient-fetch
125+
if ! check_command uclient-fetch; then
126+
print_error "未找到命令: uclient-fetch"
127+
print_error "请先安装 uclient-fetch"
128+
exit 1
129+
fi
130+
131+
# 检查 jsonfilter
132+
if ! check_command jsonfilter; then
133+
print_error "未找到命令: jsonfilter"
134+
print_error "请先安装 jshn 包"
128135
exit 1
129136
fi
130137

@@ -211,10 +218,10 @@ get_latest_version() {
211218
if [ "$USE_PRERELEASE" = true ]; then
212219
print_info "使用 prerelease 模式,将获取最新的预发布版本"
213220
# 获取所有 releases(包括 prerelease),取第一个
214-
version=$(wget -q -O - "${GITHUB_API}/releases" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/')
221+
version=$(uclient-fetch -q -O - "${GITHUB_API}/releases" | jsonfilter -e '@[0].tag_name')
215222
else
216223
# 只获取最新的正式版本
217-
version=$(wget -q -O - "${GITHUB_API}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
224+
version=$(uclient-fetch -q -O - "${GITHUB_API}/releases/latest" | jsonfilter -e '@.tag_name')
218225
fi
219226

220227
if [ -z "$version" ]; then
@@ -254,7 +261,7 @@ select_version() {
254261

255262
# 验证版本是否存在
256263
print_info "验证版本是否存在..."
257-
local version_check=$(wget -q -O - "${GITHUB_API}/releases/tags/${version_tag}" 2>/dev/null | grep '"tag_name":')
264+
local version_check=$(uclient-fetch -q -O - "${GITHUB_API}/releases/tags/${version_tag}" 2>/dev/null | jsonfilter -e '@.tag_name' 2>/dev/null)
258265

259266
if [ -z "$version_check" ]; then
260267
print_error "版本 ${user_version} 不存在"
@@ -277,7 +284,7 @@ get_release_assets() {
277284

278285
print_info "获取 Release Assets 列表..."
279286

280-
local assets=$(wget -q -O - "${GITHUB_API}/releases/tags/${version}" | grep '"name":' | sed -E 's/.*"name":\s*"([^"]+)".*/\1/')
287+
local assets=$(uclient-fetch -q -O - "${GITHUB_API}/releases/tags/${version}" | jsonfilter -e '@.assets[*].name')
281288

282289
if [ -z "$assets" ]; then
283290
print_error "无法获取 Release Assets 列表"
@@ -334,7 +341,7 @@ download_file() {
334341

335342
print_info "下载: $(basename "$output")"
336343

337-
if ! wget -q -O "$output" "$url"; then
344+
if ! uclient-fetch -q -O "$output" "$url"; then
338345
print_error "下载失败: $url"
339346
return 1
340347
fi

0 commit comments

Comments
 (0)