Skip to content

Commit

Permalink
common update
Browse files Browse the repository at this point in the history
  • Loading branch information
twoone-3 committed Oct 30, 2024
1 parent ec98313 commit c060c76
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 23 deletions.
23 changes: 18 additions & 5 deletions agh_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,34 @@ AGH_DIR="/data/adb/agh"
SCRIPT_DIR="$AGH_DIR/scripts"
MOD_PATH="/data/adb/modules/AdGuardHome"

update_description() {
sed -i "s/description=\[.*\]/description=\[$1\]/" "$MOD_PATH/module.prop"
}

exec >$AGH_DIR/agh.log 2>&1

(
exec >$AGH_DIR/agh.log 2>&1
wait_time=0
while [ "$(getprop init.svc.bootanim)" != "stopped" ]; do
echo "Waiting for system to finish booting..."
sleep 8
echo "Waiting for system to finish booting... ($wait_time)"
sleep 3
wait_time=$((wait_time + 3))
done

if [ ! -f "$MOD_PATH/disable" ]; then
echo "start normally"
$SCRIPT_DIR/service.sh start
if [ ! -f "$MOD_PATH/disable_iptable" ]; then
echo "enabling iptables"
$SCRIPT_DIR/iptables.sh enable
sed -i "s/description=\[.*\]/description=\[😎AdGuardHome is running and 🔗iptables is enabled\]/" "$MOD_PATH/module.prop"
update_description "🟢AdGuardHome is running | iptables is enabled"
else
sed -i "s/description=\[.*\]/description=\[😎AdGuardHome is running but ⛓️‍💥iptables is disabled\]/" "$MOD_PATH/module.prop"
echo "don't enable iptables"
update_description "🟢AdGuardHome is running | iptables is disabled"
fi
else
echo "don't start"
update_description "🔴AdGuardHome is stopped"
fi

inotifyd $SCRIPT_DIR/inotify.sh $MOD_PATH:d,n >/dev/null 2>&1 &
Expand Down
6 changes: 3 additions & 3 deletions bin/AdGuardHome.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ dns:
bootstrap_prefer_ipv6: false
upstream_timeout: 10s
private_networks: []
use_private_ptr_resolvers: false
use_private_ptr_resolvers: true
local_ptr_upstreams: []
use_dns64: false
dns64_prefixes: []
Expand Down Expand Up @@ -135,7 +135,7 @@ filtering:
pixabay: true
yandex: true
youtube: true
blocking_mode: default
blocking_mode: null_ip
parental_block_host: family-block.dns.adguard.com
safebrowsing_block_host: standard-block.dns.adguard.com
rewrites: []
Expand All @@ -144,7 +144,7 @@ filtering:
safesearch_cache_size: 1048576
parental_cache_size: 1048576
cache_time: 30
filters_update_interval: 168
filters_update_interval: 72
blocked_response_ttl: 10
filtering_enabled: true
parental_enabled: false
Expand Down
8 changes: 3 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# ChangeLog
- 新增模块描述动态显示模块状态功能
- 新增 [Wiki](https://github.com/twoone-3/AdGuardHomeForMagisk/wiki) 页面
- 更新 `AdGuardHome` 到 v0.107.53
- 更新 `AdGuardHome.yaml` 版本
- 删除 `config.sh` 中的 manual 配置项,转而改用创建 `disable_iptable` 文件
- 修复在模块禁用时,开机模块状态显示错误
- 优化了模块状态显示emoji
- 优化了默认模块配置
6 changes: 3 additions & 3 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=AdGuardHome
name=AdGuardHome for Magisk
version=20241012
versionCode=23
version=20241030
versionCode=24
author=twoone3
description=[😐AdGuardHome is stopped and ⛓️‍💥iptables is disabled] Filter ads at the DNS level
description=[state] Filter ads at the DNS level
updateJson=https://raw.githubusercontent.com/twoone-3/AdGuardHomeForMagisk/main/version.json
14 changes: 9 additions & 5 deletions scripts/inotify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,38 @@ MOD_PATH="/data/adb/modules/AdGuardHome"

exec >>$AGH_DIR/agh.log 2>&1

update_description () {
sed -i "s/description=\[.*\]/description=\[$1\]/" "$MOD_PATH/module.prop"
}

if [ "${monitor_file}" = "disable" ]; then
if [ "${events}" = "d" ]; then
$SCRIPT_DIR/service.sh start
if [ ! -f "/data/adb/modules/AdGuardHome/disable_iptable" ]; then
$SCRIPT_DIR/iptables.sh enable
sed -i "s/description=\[.*\]/description=\[😎AdGuardHome is running and 🔗iptables is enabled\]/" "$MOD_PATH/module.prop"
update_description "🟢AdGuardHome is running | iptables is enabled"
else
sed -i "s/description=\[.*\]/description=\[😎AdGuardHome is running but ⛓️‍💥iptables is disabled\]/" "$MOD_PATH/module.prop"
update_description "🟢AdGuardHome is running | iptables is disabled"
fi
elif [ "${events}" = "n" ]; then
if [ ! -f "/data/adb/modules/AdGuardHome/disable_iptable" ]; then
$SCRIPT_DIR/iptables.sh disable
fi
$SCRIPT_DIR/service.sh stop
sed -i "s/description=\[.*\]/description=\[😐AdGuardHome is stopped and ⛓️‍💥iptables is disabled\]/" "$MOD_PATH/module.prop"
update_description "🔴AdGuardHome is stopped"
fi
fi

if [ "${monitor_file}" = "disable_iptable" ]; then
if [ "${events}" = "d" ]; then
if [ ! -f "/data/adb/modules/AdGuardHome/disable" ]; then
$SCRIPT_DIR/iptables.sh enable
sed -i "s/description=\[.*\]/description=\[😎AdGuardHome is running and 🔗iptables is enabled\]/" "$MOD_PATH/module.prop"
update_description "🟢AdGuardHome is running | iptables is enabled"
fi
elif [ "${events}" = "n" ]; then
if [ ! -f "/data/adb/modules/AdGuardHome/disable" ]; then
$SCRIPT_DIR/iptables.sh disable
sed -i "s/description=\[.*\]/description=\[😎AdGuardHome is running but ⛓️‍💥iptables is disabled\]/" "$MOD_PATH/module.prop"
update_description "🟢AdGuardHome is running | iptables is disabled"
fi
fi
fi
2 changes: 2 additions & 0 deletions scripts/iptables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
AGH_DIR="/data/adb/agh"
source "$AGH_DIR/scripts/config.sh"

exec >>$AGH_DIR/agh.log 2>&1

find_packages_uid() {
uid_list=()
for package in "${packages_list[@]}"; do
Expand Down
2 changes: 2 additions & 0 deletions scripts/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ BIN_DIR="$AGH_DIR/bin"
SCRIPT_DIR="$AGH_DIR/scripts"
source "$AGH_DIR/scripts/config.sh"

exec >>$AGH_DIR/agh.log 2>&1

start_bin() {
# to fix https://github.com/AdguardTeam/AdGuardHome/issues/7002
export SSL_CERT_DIR="/system/etc/security/cacerts/"
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"versionCode": 23,
"version": "20241012",
"versionCode": 24,
"version": "20241030",
"zipUrl": "https://github.com/twoone-3/AdGuardHomeForMagisk/releases/latest/download/AdGuardHomeForMagisk_arm64.zip",
"changelog": "https://raw.githubusercontent.com/twoone-3/AdGuardHomeForMagisk/main/changelog.md"
}

0 comments on commit c060c76

Please sign in to comment.