26 lines
630 B
Bash
Executable File
26 lines
630 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
eth_mac=$(ip addr show eth0 | awk '$1 == "link/ether" {gsub(/\/.*$/, "", $2); print $2}')
|
|
wlan_mac=$(echo $eth_mac | sed -r "s/^(.{9})50(.{6})/\170\2/")
|
|
bt_addr=$(echo $eth_mac | sed -r "s/^(.{9})50(.{6})/\180\2/")
|
|
|
|
|
|
# Set WLAN address
|
|
ifconfig wlan0 | grep UP > /dev/null
|
|
up=$?
|
|
if [[ $up == 0 ]]; then
|
|
ifconfig wlan0 down
|
|
fi
|
|
ip link set wlan0 address $wlan_mac
|
|
|
|
if [[ $up == 0 ]]; then
|
|
ifconfig wlan0 up
|
|
fi
|
|
|
|
|
|
# Set BT address
|
|
bt_addr_rev=$(echo $bt_addr | sed -r "s/^(.{2}):(.{2}):(.{2}):(.{2}):(.{2}):(.{2})/\6:\5:\4:\3:\2:\1/")
|
|
bdaddr $bt_addr_rev
|
|
hciconfig hci0 reset
|
|
systemctl restart bluetooth
|