Skip to content

Commit e5b062c

Browse files
committed
refactor: update changelog, enhance logging, and add debug script for better diagnostics
1 parent bad87af commit e5b062c

File tree

8 files changed

+121
-97
lines changed

8 files changed

+121
-97
lines changed

changelog.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# Change Log
1+
# Changelog
22

3-
- 优化了 DNS 配置
4-
- 更新秋风广告规则 1.6.5-release
5-
- 修改默认安装语言为中文
6-
- 优化了某些获取进程的方式
7-
- 取消了 --no-check-update 参数,现在用户可以在网页端自动更新 AdGuardHome
3+
- 添加了全模块中英双语支持
4+
- 尝试解决部分设备无法启动的问题
5+
- 添加了 debug.sh 作为排错工具
6+
- 移除了无效的黑白名单
7+
- 配置文件改名 setting.conf
8+
- 其它文本提示类的改进

docs/index.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,6 @@ rm /data/adb/modules/AdGuardHome/disable
7373

7474
如果使用代理模块,强烈建议禁用模块的 iptables 转发规则。禁用后,模块仅运行 AdGuardHome 本身。随后,将代理模块的上游 DNS 服务器配置为 `127.0.0.1:5591`,即可确保代理软件的所有 DNS 查询通过 AdGuardHome 进行广告屏蔽。
7575

76-
以下是 Mihomo 的配置示例:
77-
78-
```yaml
79-
dns:
80-
enable: true
81-
ipv6: true
82-
83-
default-nameserver:
84-
- 127.0.0.1:5591 # not necessary
85-
86-
listen: 0.0.0.0:1053
87-
use-hosts: true
88-
enhanced-mode: fake-ip
89-
fake-ip-range: 198.18.0.1/16
90-
fake-ip-filter:
91-
- '*.lan'
92-
93-
nameserver:
94-
- 127.0.0.1:5591 # necessary
95-
```
96-
9776
---
9877

9978
### 模块目录与配置文件

src/customize.sh

Lines changed: 35 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,83 +10,62 @@ function error() {
1010
[ "$language" = "en" ] && abort "$1" || abort "$2"
1111
}
1212

13-
info "- Installing AdGuardHome for $ARCH" "- 开始安装 AdGuardHome for $ARCH"
13+
info "- 🚀 Installing AdGuardHome for $ARCH" "- 🚀 开始安装 AdGuardHome for $ARCH"
1414

1515
AGH_DIR="/data/adb/agh"
1616
BIN_DIR="$AGH_DIR/bin"
1717
SCRIPT_DIR="$AGH_DIR/scripts"
18-
BACKUP_DIR="$AGH_DIR/backup"
1918
PID_FILE="$AGH_DIR/bin/agh.pid"
2019

21-
info "- Extracting module basic files..." "- 解压模块基本文件..."
22-
unzip -o "$ZIPFILE" "action.sh" -d $MODPATH >/dev/null 2>&1
23-
unzip -o "$ZIPFILE" "module.prop" -d $MODPATH >/dev/null 2>&1
24-
unzip -o "$ZIPFILE" "service.sh" -d $MODPATH >/dev/null 2>&1
25-
unzip -o "$ZIPFILE" "uninstall.sh" -d $MODPATH >/dev/null 2>&1
20+
info "- 📦 Extracting module basic files..." "- 📦 解压模块基本文件..."
21+
unzip -o "$ZIPFILE" "action.sh" -d "$MODPATH" >/dev/null 2>&1
22+
unzip -o "$ZIPFILE" "module.prop" -d "$MODPATH" >/dev/null 2>&1
23+
unzip -o "$ZIPFILE" "service.sh" -d "$MODPATH" >/dev/null 2>&1
24+
unzip -o "$ZIPFILE" "uninstall.sh" -d "$MODPATH" >/dev/null 2>&1
2625

2726
extract_keep_config() {
28-
info "- Keeping old configuration files" "- 保留原来的配置文件"
29-
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR >/dev/null 2>&1 || {
30-
error "- Failed to extract scripts" "- 解压脚本文件失败"
31-
}
32-
unzip -o "$ZIPFILE" "bin/*" -x "bin/AdGuardHome.yaml" -d $AGH_DIR >/dev/null 2>&1 || {
33-
error "- Failed to extract binary files" "- 解压二进制文件失败"
34-
}
35-
unzip -o "$ZIPFILE" "settings.conf" -d $AGH_DIR >/dev/null 2>&1 || {
36-
error "- Failed to extract configuration files" "- 解压配置文件失败"
37-
}
27+
info "- 📁 Keeping old configuration files" "- 📁 保留原来的配置文件"
28+
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract scripts" "- 解压脚本文件失败"
29+
unzip -o "$ZIPFILE" "bin/*" -x "bin/AdGuardHome.yaml" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract binary files" "- 解压二进制文件失败"
30+
info "- 📦 Extracting configuration files..." "- 📦 正在解压配置文件..."
31+
unzip -o "$ZIPFILE" "settings.conf" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract configuration files" "- 解压配置文件失败"
3832
}
3933

4034
extract_no_config() {
41-
[ -d "$BACKUP_DIR" ] && rm -r "$BACKUP_DIR"
42-
mkdir -p "$BACKUP_DIR"
43-
info "- Backing up old configuration files..." "- 正在备份旧配置文件..."
44-
mv "$AGH_DIR/settings.conf" "$BACKUP_DIR"
45-
mv "$AGH_DIR/bin/AdGuardHome.yaml" "$BACKUP_DIR"
46-
info "- Extracting script files..." "- 正在解压脚本文件..."
47-
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR >/dev/null 2>&1 || {
48-
error "- Failed to extract scripts" "- 解压脚本文件失败"
49-
}
50-
info "- Extracting binary files..." "- 正在解压二进制文件..."
51-
unzip -o "$ZIPFILE" "bin/*" -d $AGH_DIR >/dev/null 2>&1 || {
52-
error "- Failed to extract binary files" "- 解压二进制文件失败"
53-
}
54-
info "- Extracting configuration files..." "- 正在解压配置文件..."
55-
unzip -o "$ZIPFILE" "settings.conf" -d $AGH_DIR >/dev/null 2>&1 || {
56-
error "- Failed to extract configuration files" "- 解压配置文件失败"
57-
}
35+
info "- 💾 Backing up old configuration files with .bak extension..." "- 💾 使用 .bak 扩展名备份旧配置文件..."
36+
[ -f "$AGH_DIR/settings.conf" ] && mv "$AGH_DIR/settings.conf" "$AGH_DIR/settings.conf.bak"
37+
[ -f "$AGH_DIR/bin/AdGuardHome.yaml" ] && mv "$AGH_DIR/bin/AdGuardHome.yaml" "$AGH_DIR/bin/AdGuardHome.yaml.bak"
38+
info "- 📦 Extracting script files..." "- 📦 正在解压脚本文件..."
39+
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract scripts" "- 解压脚本文件失败"
40+
info "- 📦 Extracting binary files..." "- 📦 正在解压二进制文件..."
41+
unzip -o "$ZIPFILE" "bin/*" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract binary files" "- 解压二进制文件失败"
42+
info "- 📦 Extracting configuration files..." "- 📦 正在解压配置文件..."
43+
unzip -o "$ZIPFILE" "settings.conf" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract configuration files" "- 解压配置文件失败"
5844
}
5945

6046
first_install_extract() {
61-
info "- First time installation, extracting files..." "- 第一次安装,正在解压文件..."
47+
info "- 📦 First time installation, extracting files..." "- 📦 第一次安装,正在解压文件..."
6248
mkdir -p "$AGH_DIR" "$BIN_DIR" "$SCRIPT_DIR"
63-
info "- Extracting script files..." "- 正在解压脚本文件..."
64-
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR >/dev/null 2>&1 || {
65-
error "- Failed to extract scripts" "- 解压脚本文件失败"
66-
}
67-
info "- Extracting binary files..." "- 正在解压二进制文件..."
68-
unzip -o "$ZIPFILE" "bin/*" -d $AGH_DIR >/dev/null 2>&1 || {
69-
error "- Failed to extract binary files" "- 解压二进制文件失败"
70-
}
71-
info "- Extracting configuration files..." "- 正在解压配置文件..."
72-
unzip -o "$ZIPFILE" "settings.conf" -d $AGH_DIR >/dev/null 2>&1 || {
73-
error "- Failed to extract configuration files" "- 解压配置文件失败"
74-
}
49+
info "- 📦 Extracting script files..." "- 📦 正在解压脚本文件..."
50+
unzip -o "$ZIPFILE" "scripts/*" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract scripts" "- 解压脚本文件失败"
51+
info "- 📦 Extracting binary files..." "- 📦 正在解压二进制文件..."
52+
unzip -o "$ZIPFILE" "bin/*" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract binary files" "- 解压二进制文件失败"
53+
info "- 📦 Extracting configuration files..." "- 📦 正在解压配置文件..."
54+
unzip -o "$ZIPFILE" "settings.conf" -d $AGH_DIR >/dev/null 2>&1 || error "- Failed to extract configuration files" "- 解压配置文件失败"
7555
}
7656

7757
if [ -d "$AGH_DIR" ]; then
78-
# Kill all processes named AdGuardHome
79-
info "- Stopping all AdGuardHome processes..." "- 正在停止所有 AdGuardHome 进程..."
58+
info "- ⏹️ Stopping all AdGuardHome processes..." "- ⏹️ 正在停止所有 AdGuardHome 进程..."
8059
pkill -f "AdGuardHome" || pkill -9 -f "AdGuardHome"
8160
sleep 1
82-
info "- Found old version, do you want to keep the old configuration? (If not, it will be automatically backed up)" "- 发现旧版模块,是否保留原来的配置文件?(若不保留则自动备份)"
83-
info "- (Volume Up = Yes, Volume Down = No, 10s no input = No)" "- (音量上键 = 是, 音量下键 = 否,10秒无操作 = 否)"
61+
info "- 🔄 Found old version, do you want to keep the old configuration? (If not, it will be automatically backed up)" "- 🔄 发现旧版模块,是否保留原来的配置文件?(若不保留则自动备份)"
62+
info "- 🔊 (Volume Up = Yes, Volume Down = No, 10s no input = No)" "- 🔊 (音量上键 = 是, 音量下键 = 否,10秒无操作 = 否)"
8463
START_TIME=$(date +%s)
8564
while true ; do
8665
NOW_TIME=$(date +%s)
8766
timeout 1 getevent -lc 1 2>&1 | grep KEY_VOLUME > "$TMPDIR/events"
8867
if [ $(( NOW_TIME - START_TIME )) -gt 9 ]; then
89-
info "- No input detected after 10 seconds, defaulting to not keep old configuration." "- 10秒无输入,默认不保留原配置。"
68+
info "- No input detected after 10 seconds, defaulting to not keep old configuration." "- 10秒无输入,默认不保留原配置。"
9069
extract_no_config
9170
break
9271
elif $(cat $TMPDIR/events | grep -q KEY_VOLUMEUP); then
@@ -101,16 +80,11 @@ else
10180
first_install_extract
10281
fi
10382

104-
info "- Setting permissions..." "- 设置权限..."
83+
info "- 🔐 Setting permissions..." "- 🔐 设置权限..."
84+
10585
chmod +x "$BIN_DIR/AdGuardHome"
10686
chown root:net_raw "$BIN_DIR/AdGuardHome"
10787

108-
chmod +x "$SCRIPT_DIR/inotify.sh"
109-
chmod +x "$SCRIPT_DIR/iptables.sh"
110-
chmod +x "$SCRIPT_DIR/tool.sh"
111-
112-
chmod +x "$MODPATH/action.sh"
113-
chmod +x "$MODPATH/service.sh"
114-
chmod +x "$MODPATH/uninstall.sh"
88+
chmod +x "$SCRIPT_DIR"/*.sh "$MODPATH"/*.sh
11589

116-
info "- Installation completed, please reboot." "- 安装完成,请重启设备。"
90+
info "- Installation completed, please reboot." "- 安装完成,请重启设备。"

src/module.prop

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=AdGuardHome
22
name=AdGuardHome for Root
3-
version=20250509(preview)
4-
versionCode=35
3+
version=20250511
4+
versionCode=36
55
author=twoone3
6-
description=Active
6+
description=none
77
updateJson=https://raw.githubusercontent.com/twoone-3/AdGuardHomeForRoot/main/version.json

src/scripts/debug.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/system/bin/sh
2+
3+
AGH_DIR="/data/adb/agh"
4+
LOG="$AGH_DIR/debug.log"
5+
6+
{
7+
echo "==== AdGuardHome Debug Log ===="
8+
date
9+
echo
10+
11+
echo "== System Info =="
12+
uname -a
13+
echo "Android Version: $(getprop ro.build.version.release)"
14+
echo "Device: $(getprop ro.product.model)"
15+
echo "Architecture: $(uname -m)"
16+
echo
17+
18+
echo "== Magisk Info =="
19+
[ -f /sbin/magisk ] && /sbin/magisk -v 2>/dev/null
20+
echo "Magisk Path: $(magisk --path 2>/dev/null)"
21+
echo
22+
23+
echo "== AGH Directory Listing =="
24+
ls -lR "$AGH_DIR"
25+
echo
26+
27+
echo "== AGH Bin Log (last 30 lines) =="
28+
tail -n 30 "$AGH_DIR/bin.log" 2>/dev/null
29+
echo
30+
31+
echo "== AGH Settings =="
32+
cat "$AGH_DIR/settings.conf" 2>/dev/null
33+
echo
34+
35+
echo "== AGH PID File =="
36+
cat "$AGH_DIR/bin/agh.pid" 2>/dev/null
37+
echo
38+
39+
echo "== Running Processes (AdGuardHome) =="
40+
ps | grep AdGuardHome
41+
echo
42+
43+
echo "== iptables -t nat -L -n -v =="
44+
iptables -t nat -L -n -v
45+
echo
46+
47+
echo "== ip6tables -t filter -L -n -v =="
48+
ip6tables -t filter -L -n -v
49+
echo
50+
51+
echo "== Network Interfaces =="
52+
ip addr
53+
echo
54+
55+
echo "== Disk Usage =="
56+
df -h
57+
echo
58+
59+
echo "== SELinux Status =="
60+
getenforce
61+
echo
62+
63+
} > "$LOG" 2>&1
64+
65+
echo "Debug info collected in $LOG"

src/scripts/iptables.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
. /data/adb/agh/settings.conf
2+
23
iptables_w="iptables -w 64"
34
ip6tables_w="ip6tables -w 64"
45

src/scripts/tool.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ start_adguardhome() {
1414

1515
# check if AdGuardHome started successfully
1616
if ps | grep -w "$adg_pid" | grep -q "AdGuardHome"; then
17-
log "AdGuardHome started, PID: $adg_pid" "- AdGuardHome 启动成功,PID: $adg_pid"
18-
update_description " Started 🚀" " 启动成功 🚀"
17+
log "🥰 started, PID: $adg_pid" "- 🥰 启动成功,PID: $adg_pid"
18+
update_description "🥰 Started, PID: $adg_pid" "🥰 启动成功, PID: $adg_pid"
1919
echo "$adg_pid" >"$PID_FILE"
2020
if [ "$enable_iptables" = true ]; then
2121
$SCRIPT_DIR/iptables.sh enable
2222
fi
2323
else
24-
log "Failed to start AdGuardHome" "- AdGuardHome 启动失败"
25-
update_description "❌ Failed to start" "❌ 启动失败"
24+
log "😭 Error occurred, check logs for details" "😭 出现错误,请检查日志以获取详细信息"
25+
update_description "😭 Error occurred, check logs for details" "😭 出现错误,请检查日志以获取详细信息"
26+
log "==== Last 20 lines of bin.log ====" "==== bin.log 的最后 20 行 ===="
27+
tail -n 20 "$AGH_DIR/bin.log" | while read -r line; do
28+
log "$line" "$line"
29+
done
2630
exit 1
2731
fi
2832
}

version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"versionCode": 35,
3-
"version": "20250427",
2+
"versionCode": 36,
3+
"version": "20250511",
44
"zipUrl": "https://github.com/twoone-3/AdGuardHomeForRoot/releases/latest/download/AdGuardHomeForRoot_arm64.zip",
55
"changelog": "https://raw.githubusercontent.com/twoone-3/AdGuardHomeForRoot/main/changelog.md"
66
}

0 commit comments

Comments
 (0)