- # Add switch master device
- for net in $(ls -d /sys/class/net/*/dsa); do
- master=$(dirname $net)
- device=$(basename $master)
- portid=$(cat $master/phys_port_name)
- lan_role="$lan_role ${portid##p}"
- json_select_object "switch$((switchid))"
- json_select_array ports
- json_add_object
- json_add_int num "${portid##p}"
- json_add_string device "$device"
- json_add_boolean need_tag 0
- json_add_boolean want_untag 0
- json_add_boolean master 1
- json_close_object
- json_select ..
- json_select_array roles
- json_add_object
- json_add_string role "lan"
- lan_role=$(echo $lan_role | xargs -n1 | sort -n | xargs)
- json_add_string ports "$lan_role"
- json_close_object
- json_select ..
- json_select ..
- done
- json_select ..
- lan_list=$(echo $lan_list | xargs -n1 | sort -V | xargs)