Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
付燕斌
android-image-pack-tool
Commits
f0032879
Commit
f0032879
authored
Nov 21, 2023
by
fuyanbin
Browse files
没有固定mac地址的设备支持持久化设备的mac地址
parent
46e61e7c
Changes
1
Show whitespace changes
Inline
Side-by-side
services/set-mac.sh
View file @
f0032879
#!/system/bin/sh
if
[
[
-f
/system/.no_macaddres_in_eeprom
]
]
if
[
"
$(
cat
/sys/class/net/eth0/addr_assign_type
)
"
!=
"0"
]
then
macaddress
=
$(
cat
/data/.macaddress
)
if
[
[
-z
$macaddress
]
]
if
[
-z
"
$macaddress
"
]
then
MAC_ADDRESS_OUIID
=
"2c:f0:5d"
macaddress
=
$(
hexdump
-n3
-e
"/3
\"
$MAC_ADDRESS_OUIID
\"
3/1
\"
:%02x
\"
"
/dev/random
)
echo
$macaddress
>
/data/.macaddress
fi
macaddress
=
"
$(
ip
link
show eth0 |grep
"link/ether"
|
head
-n
1 |
awk
'{print $2}'
)
"
echo
"
$macaddress
"
>
/data/.macaddress
else
ip
link set
eth0 down
ip
link set
dev eth0 addr
$macaddress
ip
link set
dev eth0 addr
"
$macaddress
"
ip
link set
eth0 up
restart netd
fi
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment