pmaports/main/postmarketos-mkinitfs-hook-netboot/netboot.sh
Luca Weiss eb7204df91
main/postmarketos-mkinitfs-hook-netboot: use custom IP address if available (MR 4350)
With the recent changes in commit 80fff9242, it's possible that the
client IP address is customized. Use the same code as in
init_functions.sh to get the this potentially customized IP address to
use for the nbd-client.

[ci:skip-build]: already built successfully in CI
2023-08-27 19:19:28 +02:00

35 lines
939 B
Bash

#!/bin/sh
# shellcheck disable=SC1091
. ./init_functions.sh
. /usr/share/misc/source_deviceinfo
NBD_PORT=9999
NBD_BLOCK_SIZE=${deviceinfo_rootfs_image_sector_size:-512}
setup_usb_network
start_unudhcpd
show_splash "Waiting for netboot...\\nhttps://postmarketos.org/netboot"
# Attempt to load the kernel module if CONFIG_BLK_DEV_NBD=m
modprobe nbd
# Check that we actually have nbd0 available, otherwise show an error screen.
if [ ! -b /dev/nbd0 ]; then
echo "Failed to get /dev/nbd0, stopping."
show_splash "ERROR: Failed to initialise netboot\\nhttps://postmarketos.org/netboot"
pmos_loop_forever
fi
client_ip="${unudhcpd_client_ip:-172.16.42.2}"
while ! busybox nbd-client "$client_ip" $NBD_PORT /dev/nbd0 -b "$NBD_BLOCK_SIZE"; do
echo "Connection attempt not successful, continuing..."
sleep 1
done
echo "Connected to $client_ip!"
# Show "Loading" splash again when continuing
show_splash "Loading..."
mount_subpartitions