fix getenv diagnostics robustness

This commit is contained in:
xopenwrt 2026-06-29 22:12:06 +08:00
parent 2f177ace71
commit a48a5246a0
2 changed files with 16 additions and 4 deletions

View File

@ -0,0 +1,12 @@
# AI Modification Log: Getenv Robustness
Date: 2026-06-29
## Change
- Fixed `Get_Release_Info` so it prints the kernel patch version instead of executing grep output as a command.
- Added timeouts and failure tolerance to external IP lookup calls in `Get_Action_Info`.
## Reason
The old backtick command substitution could try to execute the matched `KERNEL_PATCHVER:=...` line. The IP lookup is only diagnostic, so it should not block or fail the build when the external services are unavailable.

View File

@ -15,16 +15,16 @@ df -h
# Get IP Info
echo "------------------------------- IP Address Info ------------------------------"
IP=`curl ip.115115.xyz -s`
curl ip.115115.xyz -s
IP="$(curl --connect-timeout 5 --max-time 10 -fsS ip.115115.xyz 2>/dev/null || true)"
printf "%s\n" "${IP}"
# curl -s https://searchplugin.csdn.net/api/v1/ip/get?ip=${IP} | jq -r .data.address
curl -s https://api.vore.top/api/IPdata?ip=${IP} | jq -r .adcode.o
[ -n "${IP}" ] && curl --connect-timeout 5 --max-time 10 -fsS "https://api.vore.top/api/IPdata?ip=${IP}" 2>/dev/null | jq -r .adcode.o || true
}
Get_Release_Info() {
echo "------------------------------- Build Version Data ----------------------------"
echo ${NOW_DATA_VERSION}
echo "------------------------------ Build Kernel Version ---------------------------"
`cat ${OPENWRT_BUILD_DIR}/target/linux/x86/Makefile | grep KERNEL_PATCHVER:=`
grep "KERNEL_PATCHVER:=" "${OPENWRT_BUILD_DIR}/target/linux/x86/Makefile"
}