Browse Source

netifyd: support uci parameters

Integrate with uci to support 'enabled/disabled' startup option and
override netify's default auto network selection.

config netifyd
       option enabled 0
       option autoconfig 1

autoconfig: Use netify's in-built interface selection
else use 'internal/external_if' definitions.

Also persist important agent config across sysupgrade
agent.uuid, serial.uuid, site.uuid

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
lilik-openwrt-22.03
Kevin Darbyshire-Bryant 5 years ago
committed by Kevin Darbyshire-Bryant
parent
commit
f084977ca3
3 changed files with 41 additions and 12 deletions
  1. +6
    -0
      net/netifyd/Makefile
  2. +5
    -0
      net/netifyd/files/netifyd.config
  3. +30
    -12
      net/netifyd/files/netifyd.init

+ 6
- 0
net/netifyd/Makefile View File

@ -45,6 +45,10 @@ endef
define Package/netifyd/conffiles
/etc/netifyd.conf
/etc/config/netifyd
/etc/netify.d/agent.uuid
/etc/netify.d/serial.uuid
/etc/netify.d/site.uuid
endef
TARGET_CFLAGS+=-ffunction-sections -fdata-sections -Wno-psabi
@ -85,6 +89,8 @@ endef
define Package/netifyd/install
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) $(PKG_BUILD_DIR)/deploy/netifyd.conf $(1)/etc
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/netifyd.config $(1)/etc/config/netifyd
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/netifyd.init $(1)/etc/init.d/netifyd
$(INSTALL_DIR) $(1)/usr/sbin


+ 5
- 0
net/netifyd/files/netifyd.config View File

@ -0,0 +1,5 @@
config netifyd
option enabled 1
option autoconfig 1
# option internal_if 'eth0'
# option external_if 'eth1'

+ 30
- 12
net/netifyd/files/netifyd.init View File

@ -9,20 +9,38 @@ STOP=50
USE_PROCD=1
PROG=/usr/sbin/netifyd
NETIFYD_AUTODETECT=yes
start_service() {
mkdir -p /etc/netify.d
mkdir -p /var/run/netifyd
start_netifyd() {
local instance enabled autoconfig internal_if external_if
instance="$1"
config_get_bool enabled "$instance" enabled 0
[ "$enabled" -eq 0 ] && return 0
[ ! -d /var/run/netifyd ] && mkdir -p /var/run/netifyd
source /usr/share/netifyd/functions.sh
NETIFYD_OPTS=$(auto_detect_options)
config_get_bool autoconfig "$instance" autoconfig 1
load_modules
if [ "$autoconfig" -gt 0 ] ; then
source /usr/share/netifyd/functions.sh
load_modules
NETIFYD_AUTODETECT=yes
NETIFYD_OPTS=$(auto_detect_options)
else
config_get internal_if "$instance" internal_if "eth0"
config_get external_if "$instance" external_if "eth1"
NETIFYD_OPTS="-E $external_if -I $internal_if"
fi
procd_open_instance
procd_set_param command $PROG -R $NETIFYD_OPTS
procd_set_param file /etc/netifyd.conf
procd_set_param respawn
procd_close_instance
procd_open_instance
procd_set_param command $PROG -R $NETIFYD_OPTS
procd_set_param file /etc/netifyd.conf
procd_set_param respawn
procd_close_instance
}
start_service() {
config_load netifyd
config_foreach start_netifyd netifyd
}

Loading…
Cancel
Save