mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
wifidmd: add a script to handle wifi configs relaod
This commit is contained in:
parent
fd208e0e5f
commit
bf8b4de5da
2 changed files with 79 additions and 3 deletions
|
|
@ -5,13 +5,13 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=wifidmd
|
||||
PKG_VERSION:=1.1.24
|
||||
PKG_VERSION:=1.1.25
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/wifidmd.git
|
||||
PKG_SOURCE_VERSION:=bed749fd1e3275c06fda4d2319614bae5c3a1d7f
|
||||
PKG_SOURCE_VERSION:=7d680a0cd58fddcc909fb6cf89ebcc6a91ece3cc
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
|
@ -64,10 +64,13 @@ endif
|
|||
define Package/wifidmd/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/wifidmd $(1)/usr/sbin/wifidmd
|
||||
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/etc/init.d/wifidmd $(1)/etc/init.d/wifidmd
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/wifidmd
|
||||
$(INSTALL_BIN) ./files/etc/wifidmd/bbf_config_reload.sh $(1)/etc/wifidmd
|
||||
|
||||
$(BBFDM_REGISTER_SERVICES) ./bbfdm_service.json $(1) $(PKG_NAME)
|
||||
endef
|
||||
|
||||
|
|
|
|||
73
wifidmd/files/etc/wifidmd/bbf_config_reload.sh
Executable file
73
wifidmd/files/etc/wifidmd/bbf_config_reload.sh
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Script: bbf_config_reload.sh
|
||||
# Description:
|
||||
# This script reloads WiFi Configs based on JSON input.
|
||||
# Input should be a JSON string with boolean-like values (0 or 1) for:
|
||||
# - "wireless"
|
||||
# - "mapcontroller"
|
||||
#
|
||||
# Usage:
|
||||
# sh bbf_config_reload.sh '{"wireless":"1","mapcontroller":"0"}'
|
||||
#
|
||||
# Actions:
|
||||
# - If wireless == 1 and mapcontroller == 1 → Reload mapcontroller (SIGHUP)
|
||||
# - If wireless == 1 and mapcontroller == 0 → Commit wireless config via ubus
|
||||
# - If wireless == 0 and mapcontroller == 1 → Reload mapcontroller (SIGHUP)
|
||||
# - Otherwise → Do nothing
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
log() {
|
||||
echo "${@}"|logger -t bbf.config.wifi.reload -p info
|
||||
}
|
||||
|
||||
input="$1"
|
||||
|
||||
# Validate input
|
||||
if [ -z "$input" ]; then
|
||||
log "Error: No input provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Parse JSON input
|
||||
json_load "$input" || {
|
||||
log "Error: Failed to parse JSON input"
|
||||
exit 1
|
||||
}
|
||||
|
||||
json_get_var wireless wireless
|
||||
json_get_var mapcontroller mapcontroller
|
||||
|
||||
# Normalize inputs (default to 0 if not set)
|
||||
wireless=${wireless:-0}
|
||||
mapcontroller=${mapcontroller:-0}
|
||||
|
||||
# Define function to reload mapcontroller
|
||||
reload_mapcontroller() {
|
||||
pid=$(pidof mapcontroller)
|
||||
if [ -n "$pid" ]; then
|
||||
log "Reloading mapcontroller (PID: $pid)..."
|
||||
kill -SIGHUP "$pid"
|
||||
else
|
||||
log "Warning: mapcontroller process not found"
|
||||
fi
|
||||
}
|
||||
|
||||
# Apply logic based on flags
|
||||
if [ "$mapcontroller" -eq 1 ]; then
|
||||
reload_mapcontroller
|
||||
elif [ "$wireless" -eq 1 ]; then
|
||||
log "Committing wireless config..."
|
||||
ubus call uci commit '{"config":"wireless"}'
|
||||
else
|
||||
log "No action needed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Output success as JSON
|
||||
json_init
|
||||
json_add_boolean "Success" 1
|
||||
json_dump
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Reference in a new issue