Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
feat: generate a random mac address for wlan
Browse files Browse the repository at this point in the history
* the default wlan mac address always be b8:27:eb:74:f2:6c
  • Loading branch information
kuoruan committed Sep 24, 2019
1 parent 1f5b272 commit 9abc86f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions config/templates/customize-image.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Main() {
esac

FixPhicommN1Firmware

RandomWlanMACAddress
} # Main

InstallOpenMediaVault() {
Expand Down Expand Up @@ -279,4 +281,28 @@ FixPhicommN1Firmware()
fi
} # FixPhicommN1Firmware

RandomWlanMACAddress()
{
# 2c:15:e1 Phicomm (shanghai) Co., Ltd.
# 2c:b2:1a Phicomm (shanghai) Co., Ltd.
# 68:db:54 Phicomm (shanghai) Co., Ltd.
# 74:7d:24 Phicomm (shanghai) Co., Ltd.
# 98:bb:99 Phicomm (sichuan) Co.,ltd.
# cc:81:da Phicomm (shanghai) Co., Ltd.
# d8:c8:e9 Phicomm (shanghai) Co., Ltd.
# fc:7c:02 Phicomm (shanghai) Co., Ltd.

RANDOM_MAC="$(printf 'cc:81:da:%02x:%02x:%02x\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])"

if [[ -f "/lib/firmware/brcm/brcmfmac43455-sdio.phicomm,n1.txt" ]] ; then
sed -i -e "s/^macaddr=b8:27:eb:74:f2:6c$/macaddr=$RANDOM_MAC/" \
"/lib/firmware/brcm/brcmfmac43455-sdio.phicomm,n1.txt"
fi

if [[ -f "/lib/firmware/brcm/brcmfmac43455-sdio.txt" ]] ; then
sed -i -e "s/^macaddr=b8:27:eb:74:f2:6c$/macaddr=$RANDOM_MAC/" \
"/lib/firmware/brcm/brcmfmac43455-sdio.txt"
fi
} # RandomWlanMACAddress

Main "$@"

0 comments on commit 9abc86f

Please sign in to comment.