diff --git a/misc/alpine-install.func b/misc/alpine-install.func index 537a3148e..597d58c6a 100644 --- a/misc/alpine-install.func +++ b/misc/alpine-install.func @@ -14,6 +14,25 @@ catch_errors # Get LXC IP address (must be called INSIDE container, after network is up) get_lxc_ip +# ------------------------------------------------------------------------------ +# post_progress_to_api() +# +# - Lightweight progress ping from inside the container +# - Updates the existing telemetry record status from "installing" to "configuring" +# - Signals that the installation is actively progressing (not stuck) +# - Fire-and-forget: never blocks or fails the script +# - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set +# ------------------------------------------------------------------------------ +post_progress_to_api() { + command -v curl &>/dev/null || return 0 + [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 + [[ -z "${RANDOM_UUID:-}" ]] && return 0 + + curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \ + -H "Content-Type: application/json" \ + -d "{\"random_id\":\"${RANDOM_UUID}\",\"type\":\"lxc\",\"nsapp\":\"${app:-unknown}\",\"status\":\"configuring\"}" &>/dev/null || true +} + # This function enables IPv6 if it's not disabled and sets verbose mode verb_ip6() { set_std_mode # Set STD mode based on VERBOSE @@ -53,6 +72,7 @@ setting_up_container() { fi msg_ok "Set up Container OS" msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" + post_progress_to_api } # This function checks the network connection by pinging a known IP address and prompts the user to continue if the internet is not connected @@ -87,6 +107,7 @@ update_os() { $STD apk -U upgrade source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) msg_ok "Updated Container OS" + post_progress_to_api } # This function modifies the message of the day (motd) and SSH settings diff --git a/misc/build.func b/misc/build.func index 215fbb0e5..7c6baa33c 100644 --- a/misc/build.func +++ b/misc/build.func @@ -5265,8 +5265,8 @@ api_exit_script() { post_update_to_api "failed" "$exit_code" elif [[ "${POST_TO_API_DONE:-}" == "true" && "${POST_UPDATE_DONE:-}" != "true" ]]; then # Script exited with 0 but never sent a completion status - # This catches edge cases like early returns after post_to_api() - post_update_to_api "failed" "1" + # exit_code=0 is never an error — report as success + post_update_to_api "done" "0" fi } diff --git a/misc/install.func b/misc/install.func index 5a8d10d0b..8ec1838fa 100644 --- a/misc/install.func +++ b/misc/install.func @@ -40,6 +40,25 @@ catch_errors # Get LXC IP address (must be called INSIDE container, after network is up) get_lxc_ip +# ------------------------------------------------------------------------------ +# post_progress_to_api() +# +# - Lightweight progress ping from inside the container +# - Updates the existing telemetry record status from "installing" to "configuring" +# - Signals that the installation is actively progressing (not stuck) +# - Fire-and-forget: never blocks or fails the script +# - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set +# ------------------------------------------------------------------------------ +post_progress_to_api() { + command -v curl &>/dev/null || return 0 + [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 + [[ -z "${RANDOM_UUID:-}" ]] && return 0 + + curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \ + -H "Content-Type: application/json" \ + -d "{\"random_id\":\"${RANDOM_UUID}\",\"type\":\"lxc\",\"nsapp\":\"${app:-unknown}\",\"status\":\"configuring\"}" &>/dev/null || true +} + # ============================================================================== # SECTION 2: NETWORK & CONNECTIVITY # ============================================================================== @@ -103,6 +122,7 @@ setting_up_container() { msg_ok "Set up Container OS" #msg_custom "${CM}" "${GN}" "Network Connected: ${BL}$(hostname -I)" msg_ok "Network Connected: ${BL}$(hostname -I)" + post_progress_to_api } # ------------------------------------------------------------------------------ @@ -206,6 +226,7 @@ EOF $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED msg_ok "Updated Container OS" + post_progress_to_api source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) }