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>
This commit is contained in:
Jo-Philipp Wich 2018-05-25 07:28:28 +02:00
parent 69f544937f
commit 7e664b7c2d

View File

@ -28,24 +28,30 @@ json_select_object() {
} }
ucidef_set_interface() { ucidef_set_interface() {
local network=$1 local network=$1; shift
[ -z "$network" ] && return [ -z "$network" ] && return
json_select_object network json_select_object network
json_select_object "$network" json_select_object "$network"
shift
while [ -n "$1" ]; do while [ -n "$1" ]; do
local opt="$1" local opt=$1; shift
local val="$2" local val=$1; shift
shift; shift;
[ -n "$opt" -a -n "$val" ] || break [ -n "$opt" -a -n "$val" ] || break
json_add_string "$opt" "$val" json_add_string "$opt" "$val"
done 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 ..
json_select .. json_select ..
} }