diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-05-25 07:28:28 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-05-25 07:48:25 +0200 |
commit | 7e664b7c2dc00006ba29bf947cf177b5bccdc47d (patch) | |
tree | 5cd37f5cc1a9c816e810bda584f9239fc3ed2306 /package/base-files/files/lib | |
parent | 69f544937f8498e856690f9809a016f0d7f5f68b (diff) | |
download | upstream-7e664b7c2dc00006ba29bf947cf177b5bccdc47d.tar.gz upstream-7e664b7c2dc00006ba29bf947cf177b5bccdc47d.tar.bz2 upstream-7e664b7c2dc00006ba29bf947cf177b5bccdc47d.zip |
base-files: fix ucidef_set_interface() protocol selection
The previous refactoring of ucidef_set_interface() removed the protocol
selection heuristic which breaks the networking defaults for the majority
of boards.
Re-add the protocol selection and rename two bad "proto" references to
the expected "protocol" value.
Fixes: 85048a9c1f ("base-files: rework _ucidef_set_interface to be more generic")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'package/base-files/files/lib')
-rwxr-xr-x | package/base-files/files/lib/functions/uci-defaults.sh | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 8065af24a5..7fa328ac20 100755 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -28,24 +28,30 @@ json_select_object() { } ucidef_set_interface() { - local network=$1 + local network=$1; shift [ -z "$network" ] && return json_select_object network json_select_object "$network" - shift while [ -n "$1" ]; do - local opt="$1" - local val="$2" - shift; shift; + local opt=$1; shift + local val=$1; shift [ -n "$opt" -a -n "$val" ] || break json_add_string "$opt" "$val" done + if ! json_is_a protocol string; then + case "$network" in + lan) json_add_string protocol static ;; + wan) json_add_string protocol dhcp ;; + *) json_add_string protocol none ;; + esac + fi + json_select .. json_select .. } |