mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
wifidmd: add external apply handler
This commit is contained in:
parent
20c49302c1
commit
1fd74364fa
2 changed files with 30 additions and 25 deletions
|
|
@ -11,6 +11,17 @@
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
"loglevel": "3"
|
"loglevel": "3"
|
||||||
|
},
|
||||||
|
"apply_handler": {
|
||||||
|
"uci": [
|
||||||
|
{
|
||||||
|
"file": [
|
||||||
|
"wireless",
|
||||||
|
"mapcontroller"
|
||||||
|
],
|
||||||
|
"external_handler": "/etc/wifidmd/bbf_config_reload.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,25 @@
|
||||||
|
|
||||||
# Script: bbf_config_reload.sh
|
# Script: bbf_config_reload.sh
|
||||||
# Description:
|
# Description:
|
||||||
# This script reloads WiFi Configs based on JSON input.
|
# This script reloads WiFi Configs based on input args.
|
||||||
# Input should be a JSON string with boolean-like values (0 or 1) for:
|
# Input args should be one of the below or both with space separate
|
||||||
# - "wireless"
|
# - "wireless"
|
||||||
# - "mapcontroller"
|
# - "mapcontroller"
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# sh bbf_config_reload.sh '{"wireless":"1","mapcontroller":"0"}'
|
# sh bbf_config_reload.sh wireless mapcontroller
|
||||||
#
|
#
|
||||||
# Actions:
|
# Actions:
|
||||||
# - If wireless == 1 and mapcontroller == 1 → Reload mapcontroller (SIGHUP)
|
# - If both wireless and mapcontroller → Reload mapcontroller (SIGHUP)
|
||||||
# - If wireless == 1 and mapcontroller == 0 → Commit wireless config via ubus
|
# - If only wireless → Commit wireless config via ubus
|
||||||
# - If wireless == 0 and mapcontroller == 1 → Reload mapcontroller (SIGHUP)
|
# - If only mapcontroller → Reload mapcontroller (SIGHUP)
|
||||||
# - Otherwise → Do nothing
|
# - Otherwise → Do nothing
|
||||||
|
|
||||||
. /usr/share/libubox/jshn.sh
|
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo "${@}"|logger -t bbf.config.wifi.reload -p info
|
echo "${@}"|logger -t bbf.config.wifi.reload -p info
|
||||||
}
|
}
|
||||||
|
|
||||||
input="$1"
|
input="$@"
|
||||||
|
|
||||||
# Validate input
|
# Validate input
|
||||||
if [ -z "$input" ]; then
|
if [ -z "$input" ]; then
|
||||||
|
|
@ -30,18 +28,19 @@ if [ -z "$input" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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)
|
# Normalize inputs (default to 0 if not set)
|
||||||
wireless=${wireless:-0}
|
wireless=0
|
||||||
mapcontroller=${mapcontroller:-0}
|
mapcontroller=0
|
||||||
|
|
||||||
|
for arg in ${input}; do
|
||||||
|
if [ "${arg}" == "wireless" ]; then
|
||||||
|
wireless=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${arg}" == "mapcontroller" ]; then
|
||||||
|
mapcontroller=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Define function to reload mapcontroller
|
# Define function to reload mapcontroller
|
||||||
reload_mapcontroller() {
|
reload_mapcontroller() {
|
||||||
|
|
@ -65,9 +64,4 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output success as JSON
|
|
||||||
json_init
|
|
||||||
json_add_boolean "Success" 1
|
|
||||||
json_dump
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue