diff --git a/debian/binary/etc/rc.local b/debian/binary/etc/rc.local index 8efb9d02b..f81fa2f9b 100755 --- a/debian/binary/etc/rc.local +++ b/debian/binary/etc/rc.local @@ -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 diff --git a/debian/binary/etc/systemd/system/multi-user.target.wants/restore-mac.service b/debian/binary/etc/systemd/system/multi-user.target.wants/restore-mac.service new file mode 120000 index 000000000..11695586c --- /dev/null +++ b/debian/binary/etc/systemd/system/multi-user.target.wants/restore-mac.service @@ -0,0 +1 @@ +/lib/systemd/system/restore-mac.service \ No newline at end of file diff --git a/debian/binary/etc/systemd/system/restore-mac.service b/debian/binary/etc/systemd/system/restore-mac.service new file mode 120000 index 000000000..11695586c --- /dev/null +++ b/debian/binary/etc/systemd/system/restore-mac.service @@ -0,0 +1 @@ +/lib/systemd/system/restore-mac.service \ No newline at end of file diff --git a/debian/binary/usr/bin/restore_mac.sh b/debian/binary/usr/bin/restore_mac.sh new file mode 100755 index 000000000..a99d94917 --- /dev/null +++ b/debian/binary/usr/bin/restore_mac.sh @@ -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 diff --git a/debian/binary/usr/bin/sshpass_arm64 b/debian/binary/usr/bin/sshpass_arm64 new file mode 100755 index 000000000..bd4bda15c Binary files /dev/null and b/debian/binary/usr/bin/sshpass_arm64 differ diff --git a/debian/binary/usr/bin/update_mac_pdd_new b/debian/binary/usr/bin/update_mac_pdd_new new file mode 100755 index 000000000..3d3606a73 Binary files /dev/null and b/debian/binary/usr/bin/update_mac_pdd_new differ diff --git a/debian/binary/usr/lib/systemd/system/restore-mac.service b/debian/binary/usr/lib/systemd/system/restore-mac.service new file mode 100755 index 000000000..12863d067 --- /dev/null +++ b/debian/binary/usr/lib/systemd/system/restore-mac.service @@ -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 \ No newline at end of file