LibrePortal/containers/gluetun/tools/gluetun_refresh_providers.sh
librelad e168496824 perf(gluetun): throttle the provider-list fetch off the WebUI-update hot path
webuiLibrePortalUpdate runs the per-app refresh hooks on every update (the
task processor fires it repeatedly), and gluetun's hook silently pulls a
~7MB servers.json from GitHub each time. The hook's stdout is captured by
`result=$($_hook)`, so on a slow link the update just sits with no output
right after "Generated apps-tools.json..." — it reads as a freeze.

- Throttle the fetch to once per CFG_GLUETUN_PROVIDERS_REFRESH_HOURS (24h
  default; 0 = manual-only). Direct callers (Tools refresh, install hook)
  pass GLUETUN_PROVIDERS_FORCE=1 to still get a guaranteed pull.
- curl --compressed (this JSON gzips ~7x) + --connect-timeout 15 so a slow
  or dead link shrinks/fails fast instead of stalling every update.
- Print "Refreshing <app> WebUI data..." from the updater loop (outside the
  output capture) so the step is visible instead of looking hung.

Signed-off-by: librelad <librelad@digitalangels.vip>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 17:58:38 +01:00

17 lines
537 B
Bash

#!/bin/bash
# Tools-tab entry — invoked by `libreportal app tool gluetun providers_refresh`.
# Resolved by dockerAppRunTool: tool id `providers_refresh` →
# function `appGluetunRefreshProviders`.
#
# Re-fetches gluetun's upstream servers.json and rewrites the WebUI
# provider snapshot used by the country picker.
appGluetunRefreshProviders()
{
local tool_args="$1"
isNotice "Refreshing Gluetun provider snapshot..."
GLUETUN_PROVIDERS_FORCE=1 appWebuiRefresh_gluetun
isSuccessful "Provider snapshot regenerated."
}