mirror of
https://github.com/Lienol/openwrt
synced 2025-01-07 03:06:49 +08:00
base-files: setting device MAC
This commit is contained in:
parent
1f14db8211
commit
2e4766b762
@ -15,6 +15,7 @@ generate_bridge() {
|
||||
set network.$name.name=$name
|
||||
set network.$name.type=bridge
|
||||
EOF
|
||||
[ -z "$macaddr" ] && macaddr=$(echo "02:$(openssl rand -hex 5 | tr 'a-z' 'A-Z' | sed 's/\(..\)/\1:/g;s/:$//')")
|
||||
if [ -n "$macaddr" ]; then
|
||||
uci -q batch <<-EOF
|
||||
set network.$name.macaddr=$macaddr
|
||||
@ -103,6 +104,9 @@ generate_network() {
|
||||
|
||||
[ -n "$device" -o -n "$ports" ] || return
|
||||
|
||||
[ -z "$macaddr" ] && macaddr=$(cat /sys/class/net/${device}/address 2>/dev/null | tr 'a-z' 'A-Z')
|
||||
[ -z "$macaddr" ] && macaddr=$(echo "02:$(openssl rand -hex 5 | tr 'a-z' 'A-Z' | sed 's/\(..\)/\1:/g;s/:$//')")
|
||||
|
||||
# Force bridge for "lan" as it may have other devices (e.g. wireless)
|
||||
# bridged
|
||||
[ "$1" = "lan" -a -z "$ports" ] && {
|
||||
@ -114,6 +118,7 @@ generate_network() {
|
||||
add network device
|
||||
set network.@device[-1].name='br-$1'
|
||||
set network.@device[-1].type='bridge'
|
||||
set network.@device[-1].macaddr='$macaddr'
|
||||
EOF
|
||||
for port in $ports; do uci add_list network.@device[-1].ports="$port"; done
|
||||
[ -n "$macaddr" ] && {
|
||||
|
Loading…
Reference in New Issue
Block a user