contrib/meshwizard: Fix getting of mac address when the interface is not up yet,...
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / gen_auto-ipv6-dhcpv6-ip.sh
1 #!/bin/sh
2 netrenamed=$1
3
4 local PREFIX="$(echo $profile_ipv6_prefix| cut -d "/" -f 1| sed 's/::/:/')"
5
6 # Get the devices mac address
7 local device="$(uci -p/var/state -q get network.$1.ifname)"
8 if [ -n "$device" ]; then
9 local MAC="$(ifconfig $netrenamed |grep HWaddr | awk '{ print $5 '})"
10 else
11 local MAC="$(cat /sys/class/net/$1/address)"
12 local IPV6_UNIQ="$(echo $MAC | awk -F: '{ print $1$2":"$3$4":"$5$6 }')"
13 fi
14
15 echo "${PREFIX}${IPV6_UNIQ}:1"
16