From 28aeb29c516c870ac7efb5ebb124b014a5177103 Mon Sep 17 00:00:00 2001 From: SaltyMonkey <1570693+SaltyMonkey@users.noreply.github.com> Date: Wed, 8 Oct 2025 22:09:48 +0300 Subject: [PATCH] refactor: Update luci-app-podkop package * Removed direct package manager calls * Removed commands related to optional luci package * Update external global_check call with version pass * Removed useless external calls in version check cases * Improved build process support: version will be automatically set at installation time from package metadata and will be readable from JS as constant --- fe-app-podkop/src/constants.ts | 1 + luci-app-podkop/Makefile | 10 +++++++++- .../resources/view/podkop/diagnosticTab.js | 20 ++++++------------- .../luci-static/resources/view/podkop/main.js | 4 +++- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/fe-app-podkop/src/constants.ts b/fe-app-podkop/src/constants.ts index bdfe8f8..153f510 100644 --- a/fe-app-podkop/src/constants.ts +++ b/fe-app-podkop/src/constants.ts @@ -4,6 +4,7 @@ export const STATUS_COLORS = { WARNING: '#ff9800', }; +export const PODKOP_LUCI_APP_VERSION = '__COMPILED_VERSION_VARIABLE__'; export const FAKEIP_CHECK_DOMAIN = 'fakeip.podkop.fyi'; export const IP_CHECK_DOMAIN = 'ip.podkop.fyi'; diff --git a/luci-app-podkop/Makefile b/luci-app-podkop/Makefile index 03bf9af..94c0fdb 100644 --- a/luci-app-podkop/Makefile +++ b/luci-app-podkop/Makefile @@ -19,4 +19,12 @@ LUCI_LANGUAGES:=en ru include $(TOPDIR)/feeds/luci/luci.mk -# call BuildPackage - OpenWrt buildroot signature \ No newline at end of file +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)$(HTDOCS) + $(CP) $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/ + $(INSTALL_DIR) $(1)/ + $(CP) $(PKG_BUILD_DIR)/root/* $(1)/ + sed -i -e 's/__COMPILED_VERSION_VARIABLE__/$(PKG_VERSION)/g' $(1)$(HTDOCS)/luci-static/resources/view/podkop/main.js || true +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) \ No newline at end of file diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/diagnosticTab.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/diagnosticTab.js index 5b5b2cf..480ff2a 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/diagnosticTab.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/diagnosticTab.js @@ -376,7 +376,7 @@ function showConfigModal(command, title) { let formattedOutput = ''; if (command === 'global_check') { - safeExec('/usr/bin/podkop', [command], 'P0_PRIORITY', (res) => { + safeExec('/usr/bin/podkop', [command, `${main.PODKOP_LUCI_APP_VERSION}`], 'P0_PRIORITY', (res) => { formattedOutput = formatDiagnosticOutput(res.stdout || _('No output')); try { @@ -918,19 +918,11 @@ async function updateDiagnostics() { ); }); - safeExec( - '/usr/bin/podkop', - ['show_luci_version'], - 'P2_PRIORITY', - (result) => { - updateTextElement( - 'luci-version', - document.createTextNode( - result.stdout ? result.stdout.trim() : _('Unknown'), - ), - ); - }, - ); + updateTextElement( + 'luci-version', + document.createTextNode( + `${main.PODKOP_LUCI_APP_VERSION}` + ), safeExec( '/usr/bin/podkop', diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js index 3597c07..d0a9456 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js @@ -1,4 +1,4 @@ -// This file is autogenerated, please don't change manually +// This file is autogenerated, please don't change manually "use strict"; "require baseclass"; "require fs"; @@ -592,6 +592,7 @@ var STATUS_COLORS = { ERROR: "#f44336", WARNING: "#ff9800" }; +var PODKOP_LUCI_APP_VERSION = "__COMPILED_VERSION_VARIABLE__"; var FAKEIP_CHECK_DOMAIN = "fakeip.podkop.fyi"; var IP_CHECK_DOMAIN = "ip.podkop.fyi"; var REGIONAL_OPTIONS = [ @@ -1913,6 +1914,7 @@ return baseclass.extend({ FETCH_TIMEOUT, IP_CHECK_DOMAIN, REGIONAL_OPTIONS, + PODKOP_LUCI_APP_VERSION, STATUS_COLORS, TabService, TabServiceInstance,