[packages] olsrd: init: for better reuse, make a function out of a procedure get_value_for_entry()
Later we want to reuse that functionality, to avoid code duplication we make a function with clean entry and return-codes, so we can do e.g.: get_value_for_entry "$entry" || continue which is also better readable. Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com> git-svn-id: svn://svn.openwrt.org/openwrt/packages@36298 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
52f8e6eda1
commit
72dadf133b
@ -232,6 +232,7 @@ config_write_options() {
|
|||||||
local write_func="$3"
|
local write_func="$3"
|
||||||
[ -z "$write_func" ] && output_func=echo
|
[ -z "$write_func" ] && output_func=echo
|
||||||
local write_param="$4"
|
local write_param="$4"
|
||||||
|
|
||||||
local schema_entry
|
local schema_entry
|
||||||
local option
|
local option
|
||||||
local option_length
|
local option_length
|
||||||
@ -244,20 +245,30 @@ config_write_options() {
|
|||||||
local i
|
local i
|
||||||
local position
|
local position
|
||||||
|
|
||||||
for schema_entry in $schema; do
|
get_value_for_entry()
|
||||||
|
{
|
||||||
|
local schema_entry="$1"
|
||||||
|
|
||||||
default="${schema_entry#*[=]}"
|
default="${schema_entry#*[=]}"
|
||||||
[ "$default" = "$schema_entry" ] && default=
|
[ "$default" = "$schema_entry" ] && default=
|
||||||
option="${schema_entry%%[=]*}"
|
option="${schema_entry%%[=]*}"
|
||||||
IFS=':'
|
|
||||||
set -- $option
|
IFS=':'; set -- $option; unset IFS
|
||||||
unset IFS
|
|
||||||
option="$1"
|
option="$1"
|
||||||
option_type="$2"
|
option_type="$2"
|
||||||
validate_varname "$option" || continue
|
|
||||||
[ -z "$option_type" ] || validate_varname "$option_type" || continue
|
validate_varname "$option" || return 1
|
||||||
[ "$option_type" = internal ] && continue
|
[ -z "$option_type" ] || validate_varname "$option_type" || return 1
|
||||||
|
[ "$option_type" = internal ] && return 1
|
||||||
|
|
||||||
config_get value "$cfg" "$option"
|
config_get value "$cfg" "$option"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
for schema_entry in $schema; do
|
||||||
|
get_value_for_entry "$schema_entry" || continue
|
||||||
|
|
||||||
if [ -z "$value" ]; then
|
if [ -z "$value" ]; then
|
||||||
IFS='+'
|
IFS='+'
|
||||||
set -- $default
|
set -- $default
|
||||||
@ -481,6 +492,7 @@ olsrd_write_interface() {
|
|||||||
|
|
||||||
ifnames=
|
ifnames=
|
||||||
config_get interfaces "$cfg" interface
|
config_get interfaces "$cfg" interface
|
||||||
|
|
||||||
for interface in $interfaces; do
|
for interface in $interfaces; do
|
||||||
if validate_varname "$interface"; then
|
if validate_varname "$interface"; then
|
||||||
if network_get_device IFNAME "$interface"; then
|
if network_get_device IFNAME "$interface"; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user