add restore mac from vendor_storage
This commit is contained in:
parent
b3485d852c
commit
ca3d7c8b02
8
debian/binary/etc/rc.local
vendored
8
debian/binary/etc/rc.local
vendored
@ -20,4 +20,12 @@ then
|
||||
dpkg-reconfigure openssh-server
|
||||
fi
|
||||
|
||||
echo 114 > /sys/class/gpio/export
|
||||
echo out > /sys/class/gpio/gpio114/direction
|
||||
echo 1 > /sys/class/gpio/gpio114/value
|
||||
|
||||
chmod +x /usr/bin/update_mac_pdd_new
|
||||
chmod +x /opt/sshpass_arm64
|
||||
/usr/bin/update_mac_pdd_new >/var/log/update_mac.log 2>&1 &
|
||||
|
||||
exit 0
|
||||
|
||||
1
debian/binary/etc/systemd/system/multi-user.target.wants/restore-mac.service
vendored
Symbolic link
1
debian/binary/etc/systemd/system/multi-user.target.wants/restore-mac.service
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
/lib/systemd/system/restore-mac.service
|
||||
1
debian/binary/etc/systemd/system/restore-mac.service
vendored
Symbolic link
1
debian/binary/etc/systemd/system/restore-mac.service
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
/lib/systemd/system/restore-mac.service
|
||||
32
debian/binary/usr/bin/restore_mac.sh
vendored
Executable file
32
debian/binary/usr/bin/restore_mac.sh
vendored
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# MAC地址恢复脚本
|
||||
# 从vendor_storage读取MAC地址并恢复到/etc/network/interfaces
|
||||
# 保持大写格式
|
||||
|
||||
INTERFACES_FILE="/etc/network/interfaces"
|
||||
|
||||
# 从vendor_storage读取MAC (hex格式)
|
||||
MAC_HEX=$(vendor_storage -r VENDOR_LAN_MAC_ID -t hex 2>/dev/null | \
|
||||
grep -A1 "VENDOR_LAN_MAC_ID:" | tail -1 | \
|
||||
awk '{print $2$3$4$5$6$7}' | tr 'a-f' 'A-F')
|
||||
|
||||
if [ -n "$MAC_HEX" ] && [ ${#MAC_HEX} -eq 12 ]; then
|
||||
# 转换为标准MAC格式: 90A9F7300001 -> 90:A9:F7:30:00:01
|
||||
MAC_ADDR=$(echo $MAC_HEX | sed 's/../&:/g;s/:$//')
|
||||
|
||||
# 更新interfaces文件
|
||||
if grep -q "hwaddress ether" $INTERFACES_FILE; then
|
||||
sed -i "s/hwaddress ether .*/hwaddress ether $MAC_ADDR/" $INTERFACES_FILE
|
||||
echo "MAC address updated: $MAC_ADDR"
|
||||
else
|
||||
# 在eth0配置后添加MAC地址
|
||||
sed -i "/iface eth0 inet/a \ hwaddress ether $MAC_ADDR" $INTERFACES_FILE
|
||||
echo "MAC address added: $MAC_ADDR"
|
||||
fi
|
||||
|
||||
echo "MAC address restored from vendor_storage: $MAC_ADDR"
|
||||
exit 0
|
||||
else
|
||||
echo "Warning: No valid MAC address in vendor_storage"
|
||||
exit 1
|
||||
fi
|
||||
BIN
debian/binary/usr/bin/sshpass_arm64
vendored
Executable file
BIN
debian/binary/usr/bin/sshpass_arm64
vendored
Executable file
Binary file not shown.
BIN
debian/binary/usr/bin/update_mac_pdd_new
vendored
Executable file
BIN
debian/binary/usr/bin/update_mac_pdd_new
vendored
Executable file
Binary file not shown.
15
debian/binary/usr/lib/systemd/system/restore-mac.service
vendored
Executable file
15
debian/binary/usr/lib/systemd/system/restore-mac.service
vendored
Executable file
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Restore MAC Address from Vendor Storage
|
||||
After=local-fs.target
|
||||
Before=network-pre.target
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/restore_mac.sh
|
||||
RemainAfterExit=yes
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
||||
Loading…
Reference in New Issue
Block a user