Improve network boot troubleshooting documentation and initramfs scripts
Update NETWORK-BOOT-TROUBLESHOOTING.md to clarify the boot process and emphasize the need to disable PXE before rebooting to ensure EEPROM updates are applied. Enhance initramfs scripts to improve DHCP lease acquisition and capture the device's IP address more reliably. Add a revision tracking feature to the initramfs build process for better version control. Modify provisioning-client.sh to ensure proper reboot handling after deployment and backup actions.
This commit is contained in:
@@ -13,7 +13,12 @@ get_mac() {
|
||||
}
|
||||
|
||||
get_ip() {
|
||||
hostname -I 2>/dev/null | awk '{print $1}' || echo ""
|
||||
# Prefer IP captured by init; fallback to ip (match "inet 1.2.3.4/..." to skip inet6)
|
||||
if [ -f /tmp/client_ip ] && [ -s /tmp/client_ip ]; then
|
||||
cat /tmp/client_ip
|
||||
return
|
||||
fi
|
||||
ip addr show dev eth0 2>/dev/null | awk '/inet [0-9]/ { print $2; exit }' | cut -d/ -f1
|
||||
}
|
||||
|
||||
MAC=$(get_mac)
|
||||
@@ -37,10 +42,14 @@ while true; do
|
||||
sleep 10
|
||||
continue
|
||||
fi
|
||||
curl -sL "$url" | dd of="$EMMC_DEV" bs=4M status=progress conv=fsync
|
||||
curl -sL "$url" | dd of="$EMMC_DEV" bs=4M conv=fsync 2>&1
|
||||
sync
|
||||
echo "Deploy done. Disabling network boot on server so device boots from eMMC next time."
|
||||
curl -s -X POST "$BASE_URL/api/action-done?mac=$MAC" || true
|
||||
exit 0
|
||||
echo "Rebooting in 3 seconds..."
|
||||
sleep 3
|
||||
reboot -f 2>/dev/null || echo b > /proc/sysrq-trigger
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
if [ "$action" = "backup" ] && [ -n "$upload_url" ]; then
|
||||
@@ -50,16 +59,20 @@ while true; do
|
||||
sleep 10
|
||||
continue
|
||||
fi
|
||||
dd if="$EMMC_DEV" bs=4M status=progress 2>/dev/null | curl -s -X POST -T - "$upload_url"
|
||||
dd if="$EMMC_DEV" bs=4M 2>/dev/null | curl -s -X POST -T - "$upload_url"
|
||||
sync
|
||||
echo "Backup done. Disabling network boot on server."
|
||||
curl -s -X POST "$BASE_URL/api/action-done?mac=$MAC" || true
|
||||
exit 0
|
||||
echo "Rebooting in 3 seconds..."
|
||||
sleep 3
|
||||
reboot -f 2>/dev/null || echo b > /proc/sysrq-trigger
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
if [ "$action" = "reboot" ]; then
|
||||
echo "Boot normally: rebooting..."
|
||||
reboot -f 2>/dev/null || exec reboot 2>/dev/null || true
|
||||
exit 0
|
||||
echo "Rebooting..."
|
||||
reboot -f 2>/dev/null || echo b > /proc/sysrq-trigger
|
||||
sleep 60
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
|
||||
Reference in New Issue
Block a user