Files
NeoTachyon/tests/adguard_runtime.sh
T
hacker07 617107ef15 feat(adguard): add AdGuard Home component with DNS modes, failover and section upstream
Add AdGuard Home as an installable Tachyon component (component card with
check/update/remove/rollback/enable/disable) backed by providers/adguard
(validator + runtime) and an init.d service.

Backend:
- action.uc: install/remove/enable/backup/rollback/dispatch/releases for
  'adguard' (tar.gz from AdguardTeam/AdGuardHome, OpenWrt->AdGuard arch map)
- updater.uc: adguard asset selection; updates.uc: valid_component_name and
  automatic update checks
- runtime.uc: generates AdGuardHome.yaml from UCI (upstream=single-box DNS,
  fallback_dns for failover, web UI on LAN, filters), manages the daemon
- dns/apply.uc: dns_main_mode (dnsmasq->AdGuard->sing-box chain, or AdGuard on
  :53 with dnsmasq DHCP-only)
- settings: dns_main_mode (Main DNS) + dns_adguard_failover_enabled
- sections: routed_dns_type/dns_type 'adguard' resolve via the AdGuard provider
  upstreams; validator accepts the new type
- system-info: adguard_version/installed/enabled/backup fields

Frontend:
- component card 'AdGuard Home' with enable/disable + version actions
- LuCI DNS settings tab: Main DNS selector and failover flag
- section.js: AdGuard Home routed DNS protocol option

Tests: tests/adguard_validator.sh, tests/adguard_runtime.sh
2026-09-17 14:22:13 +03:00

57 lines
2.2 KiB
Bash

#!/usr/bin/env bash
set -eo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TACHYON_LIB="$ROOT_DIR/tachyon/files/usr/lib"
RUNTIME="$ROOT_DIR/tachyon/files/usr/lib/providers/adguard/runtime.uc"
fail() {
printf 'FAIL: %s\n' "$1" >&2
exit 1
}
# The binary is absent in the test environment, so "installed" must be false.
if ucode -L "$TACHYON_LIB" -- "$RUNTIME" installed >/dev/null 2>&1; then
fail "installed should be false without an AdGuardHome binary"
fi
if ucode -L "$TACHYON_LIB" -- "$RUNTIME" provider-available >/dev/null 2>&1; then
fail "provider-available should be false without an AdGuardHome binary"
fi
# package-version of a missing binary must be empty.
ver="$(ucode -L "$TACHYON_LIB" -- "$RUNTIME" package-version)"
[ -z "$ver" ] || fail "package-version should be empty when not installed, got '$ver'"
# Without UCI the provider section is absent -> disabled.
if ucode -L "$TACHYON_LIB" -- "$RUNTIME" provider-enabled >/dev/null 2>&1; then
fail "provider-enabled should be false when the adguard provider section is absent"
fi
# Default DNS main mode is dnsmasq.
mode="$(ucode -L "$TACHYON_LIB" -- "$RUNTIME" dns-main-mode)"
[ "$mode" = "dnsmasq" ] || fail "default dns_main_mode should be dnsmasq, got '$mode'"
# Default listen port in dnsmasq mode is the local 5354 port.
port="$(ucode -L "$TACHYON_LIB" -- "$RUNTIME" dns-listen-port)"
[ "$port" = "5354" ] || fail "dnsmasq mode listen port should be 5354, got '$port'"
host="$(ucode -L "$TACHYON_LIB" -- "$RUNTIME" dns-listen-host)"
[ "$host" = "127.0.0.1" ] || fail "dnsmasq mode listen host should be 127.0.0.1, got '$host'"
status="$(ucode -L "$TACHYON_LIB" -- "$RUNTIME" status)"
JSON_VALUE="$status" node - <<'NODE'
const value = JSON.parse(process.env.JSON_VALUE);
if (String(value.installed) !== 'false') process.exit(1);
if (String(value.enabled) !== 'false') process.exit(1);
if (String(value.dns_main_mode) !== 'dnsmasq') process.exit(1);
NODE
check="$(ucode -L "$TACHYON_LIB" -- "$RUNTIME" check)"
JSON_VALUE="$check" node - <<'NODE'
const value = JSON.parse(process.env.JSON_VALUE);
if (String(value.adguard_installed) !== 'false') process.exit(1);
if (value.adguard_provider_path !== '/usr/bin/AdGuardHome') process.exit(1);
NODE
printf 'OK: adguard runtime tests passed\n'