From a48a5246a05f488c10ffd9e2e48b8eb9c961c80c Mon Sep 17 00:00:00 2001 From: xopenwrt Date: Mon, 29 Jun 2026 22:12:06 +0800 Subject: [PATCH] fix getenv diagnostics robustness --- AI_CHANGELOG_GETENV_ROBUSTNESS.md | 12 ++++++++++++ Scripts/AutoBuild_Getenv.sh | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 AI_CHANGELOG_GETENV_ROBUSTNESS.md diff --git a/AI_CHANGELOG_GETENV_ROBUSTNESS.md b/AI_CHANGELOG_GETENV_ROBUSTNESS.md new file mode 100644 index 0000000..73da3a1 --- /dev/null +++ b/AI_CHANGELOG_GETENV_ROBUSTNESS.md @@ -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. diff --git a/Scripts/AutoBuild_Getenv.sh b/Scripts/AutoBuild_Getenv.sh index 145f943..5b6200e 100644 --- a/Scripts/AutoBuild_Getenv.sh +++ b/Scripts/AutoBuild_Getenv.sh @@ -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" } \ No newline at end of file