irqbalance: add support for uci config
authorHannu Nyman <hannu.nyman@iki.fi>
Sun, 2 Jun 2019 09:29:17 +0000 (12:29 +0300)
committerHannu Nyman <hannu.nyman@iki.fi>
Sun, 2 Jun 2019 09:43:08 +0000 (12:43 +0300)
Add support for uci config file.

Only a global 'enabled" switch has been implemented so far.

* Default config disables irqbalance initially, so that there is
  no change with the previous behaviour (and the possibly existing
  separate launch scripts in people's builds).

Config file and init script can be later extended for irqbalance
options like the oneshot mode or the evaluation interval

(Also change the init file to use tabs)

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
utils/irqbalance/Makefile
utils/irqbalance/files/irqbalance.config [new file with mode: 0644]
utils/irqbalance/files/irqbalance.init

index 59536d04d392982996178a0aa88ef4350d4f1294..5523a19b23d8753c1918b7eaaf2529bdfaf1440e 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=irqbalance
 PKG_VERSION:=1.2.0
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_PROTO:=git
@@ -49,6 +49,8 @@ define Package/irqbalance/install
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/irqbalance $(1)/usr/sbin/
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/irqbalance.init $(1)/etc/init.d/irqbalance
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/irqbalance.config $(1)/etc/config/irqbalance
 endef
 
 $(eval $(call BuildPackage,irqbalance))
diff --git a/utils/irqbalance/files/irqbalance.config b/utils/irqbalance/files/irqbalance.config
new file mode 100644 (file)
index 0000000..5f074b0
--- /dev/null
@@ -0,0 +1,3 @@
+config irqbalance 'irqbalance'
+       option enabled '0'
+
index 34db0a23c192da48f79777381f96d8b2f4e7ae4c..e794b7365be2dba5fe69012b3531747c786c2a25 100644 (file)
@@ -4,9 +4,14 @@ START=11
 USE_PROCD=1
 
 start_service() {
-  procd_open_instance "irqbalance"
-  procd_set_param command /usr/sbin/irqbalance -f
-  procd_set_param respawn
-  procd_close_instance
+       local enabled
+       config_load 'irqbalance'
+       config_get_bool enabled irqbalance enabled 0
+       [ "$enabled" -gt 0 ] || return 0
+
+       procd_open_instance "irqbalance"
+       procd_set_param command /usr/sbin/irqbalance -f
+       procd_set_param respawn
+       procd_close_instance
 }