mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
map-topology: validate config options
This commit is contained in:
parent
c54e44a820
commit
b07664f7d5
1 changed files with 65 additions and 0 deletions
|
|
@ -5,7 +5,72 @@ STOP=21
|
|||
|
||||
USE_PROCD=1
|
||||
|
||||
IS_CFG_VALID=1
|
||||
|
||||
validate_topology_config() {
|
||||
uci_validate_section topology topology "topology" \
|
||||
'enabled:bool:true' \
|
||||
'depth:range(0,16)' \
|
||||
'interval:range(0,65535)' \
|
||||
'maxlog:range(0,128)' \
|
||||
|
||||
[ "$?" -ne 0 ] && {
|
||||
logger -s -t "topology" "Validation of topology UCI file failed"
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
validate_global_section() {
|
||||
uci_validate_section hosts global "global" \
|
||||
'ageing_timer:uinteger' \
|
||||
'reboot_persistent:bool'
|
||||
|
||||
[ "$?" -ne 0 ] && {
|
||||
logger -s -t "hosts" "Validation of global section failed"
|
||||
IS_CFG_VALID=0
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
validate_host_section() {
|
||||
local section="$1"
|
||||
|
||||
uci_validate_section hosts $section "${1}" \
|
||||
'macaddr:macaddr' \
|
||||
'interface_type:or("wifi","eth")' \
|
||||
'active:bool' \
|
||||
'active_last_change:string'
|
||||
|
||||
[ "$?" -ne 0 ] && {
|
||||
logger -s -t "hosts" "Validation of host section $section failed"
|
||||
IS_CFG_VALID=0
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
validate_hosts_config() {
|
||||
IS_CFG_VALID=1
|
||||
|
||||
validate_global_section &&
|
||||
config_foreach validate_host_section host
|
||||
|
||||
[ "$IS_CFG_VALID" -ne 1 ] && {
|
||||
logger -s -t "topology" "Validation of hosts UCI file failed"
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load "topology"
|
||||
validate_topology_config || return 1;
|
||||
|
||||
config_load "hosts"
|
||||
validate_hosts_config || return 1;
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "/usr/sbin/topologyd"
|
||||
procd_set_param respawn
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue