Hi K.Clemens,
Thank you for your e-mail and heads-up for this problem.
This finally explains why my living room and kitchen
squeezelite-raspberries weren't always synchronized in the morning. :D
Indeed on the latest Raspbian Stretch the "ifconfig" command (used for
determining MAC address) gives a different output then on earlier
versions, which made my code incorrect.
I've now changed my script so that it basically uses the script proposed
by DJanGo.
At first it executes these commands to get the wlan0 mac addres, or the
eth0 mac address:
Code:
--------------------
# get mac address from wifi adapter or on board network card
SL_MAC_ADDRESS=$(cat /sys/class/net/wlan0/address)
[ -n "$SL_MAC_ADDRESS" ] || SL_MAC_ADDRESS=$(cat /sys/class/net/eth0/address)
--------------------
Then it loads the squeezelite_settings.sh file, in which the mac address
might be set too.
After loading the settings, it checks if the MAC adddres has a correct
format. If the format isn't correct, it generates a random mac address:
Code:
--------------------
# check if valid mac address is obtained
if [[ ! "$SL_MAC_ADDRESS" =~ ^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$ ]]; then
echo "Warning: no valid mac addres found in SL_MAC_ADDRESS, generating random
one."
hexchars="0123456789ABCDEF"
RANDOMMAC=$( for i in {1..12} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1}
; done | sed -e 's/\(..\)/:\1/g' )
SL_MAC_ADDRESS=${RANDOMMAC:1}
fi
--------------------
This way the mac address will allways be set.
One additional benefit might be that if you would enter "random" as
value in SL_MAC_ADDRESS in the settings file, it will force the script
to use a random mac address.
This might be usefull when using multiple squeezelite instances on one
machine.
A "drawback" is that the player will have a different mac address after
each reboot.
I've tested these changes on piCore, Raspbian Jessie and Raspbian
Stretch.
Comments/suggestions, welcome!
Greetings,
Gerrelt.
------------------------------------------------------------------------
Gerrelt's Profile: http://forums.slimdevices.com/member.php?userid=58186
View this thread: http://forums.slimdevices.com/showthread.php?t=108327
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix