From 50913b2b7a0b57b4ae27eec42e0bf972dc46918f Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Wed, 6 Nov 2024 20:39:36 +0530 Subject: [PATCH] [fix] Simplified compiling package without iwinfo Copy iwinfo.lua only when CONFIG_NETJSON_MONITORING_IWINFO is set to true. --- openwisp-monitoring/Makefile | 6 +++--- .../files/lib/openwisp-monitoring/monitoring.lua | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/openwisp-monitoring/Makefile b/openwisp-monitoring/Makefile index 6ae7e27..882a387 100644 --- a/openwisp-monitoring/Makefile +++ b/openwisp-monitoring/Makefile @@ -90,9 +90,9 @@ define Package/netjson-monitoring/install $(1)/usr/lib/lua/openwisp-monitoring/wifi.lua # Iwinfo is enabled by default unless specified otherwise - $(INSTALL_DIR) $(1)/usr/lib/lua/openwisp-monitoring - sed 's/true/$(if $(CONFIG_NETJSON_MONITORING_IWINFO),true,false)/' \ - files/lib/openwisp-monitoring/iwinfo.lua > $(1)/usr/lib/lua/openwisp-monitoring/iwinfo.lua + ifeq ($(CONFIG_NETJSON_MONITORING_IWINFO), y) + $(CP) files/lib/openwisp-monitoring/iwinfo.lua $(1)/usr/lib/lua/openwisp-monitoring/iwinfo.lua + endif $(CP) ../VERSION $(1)/usr/lib/openwisp-monitoring/ endef diff --git a/openwisp-monitoring/files/lib/openwisp-monitoring/monitoring.lua b/openwisp-monitoring/files/lib/openwisp-monitoring/monitoring.lua index caebb64..d3e6d6c 100644 --- a/openwisp-monitoring/files/lib/openwisp-monitoring/monitoring.lua +++ b/openwisp-monitoring/files/lib/openwisp-monitoring/monitoring.lua @@ -8,6 +8,14 @@ monitoring.neighbors = require('openwisp-monitoring.neighbors') monitoring.resources = require('openwisp-monitoring.resources') monitoring.utils = require('openwisp-monitoring.utils') monitoring.wifi = require('openwisp-monitoring.wifi') -monitoring.iwinfo = require('openwisp-monitoring.iwinfo') + +local success, iwinfo = pcall(require, 'openwisp-monitoring.iwinfo') +if success then + monitoring.iwinfo = iwinfo +else + monitoring.iwinfo = { + enabled = false + } +end return monitoring