luci-mod-admin-full: figure out diagnostics host in postinstall
Attempt to infer the default diagnostics host for nslookup / ping / traceroute from the various URLs in /etc/os-release. Fall back to "openwrt.org" if no host is found to preserve backwards compatibility. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
d4c3372020
commit
067fe5bcce
1 changed files with 22 additions and 0 deletions
22
modules/luci-mod-admin-full/root/etc/uci-defaults/50_luci-mod-admin-full
Executable file
22
modules/luci-mod-admin-full/root/etc/uci-defaults/50_luci-mod-admin-full
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$(uci -q get luci.diag)" != "internal" ]; then
|
||||
host=""
|
||||
|
||||
if [ -s /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
host="${HOME_URL:-${BUG_URL:-$LEDE_DEVICE_MANUFACTURER_URL}}"
|
||||
host="${host#*://}"
|
||||
host="${host%%/*}"
|
||||
fi
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set luci.diag=internal
|
||||
set luci.diag.dns='${host:-openwrt.org}'
|
||||
set luci.diag.ping='${host:-openwrt.org}'
|
||||
set luci.diag.route='${host:-openwrt.org}'
|
||||
commit luci
|
||||
EOF
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
Reference in a new issue