diff options
author | Ain <41307858+nero@users.noreply.github.com> | 2018-09-02 18:47:56 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2018-11-08 16:32:05 +0000 |
commit | 06e34557edb00b7962de97cf71818605a8364f9a (patch) | |
tree | cc49455171bbb14faddf77a1ad80498dd492f1a6 | |
parent | 83f3b26cac43c01607b8e3da33bb457f1a9ab7a7 (diff) | |
download | mkinitfs-06e34557edb00b7962de97cf71818605a8364f9a.tar.bz2 mkinitfs-06e34557edb00b7962de97cf71818605a8364f9a.tar.xz |
Add support for BOOTIF boot parameter
BOOTIF can be set by the SYSAPPEND option of PXELINUX. Its primary
usecase is telling the OS which interface it was booted from. This
fixes netbooting from eth1 or upwards if eth0 is connected to an
different network.
-rwxr-xr-x | initramfs-init.in | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/initramfs-init.in b/initramfs-init.in index 22e4250..5f0a5ff 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -138,6 +138,12 @@ setup_inittab_console(){ # determine the default interface to use if ip=dhcp is set # uses the first "eth" interface with operstate 'up'. ip_choose_if() { + if [ -n "$KOPT_BOOTIF" ]; then + mac=$(printf "%s\n" "$KOPT_BOOTIF"|sed 's/^01-//;s/-/:/g') + dev=$(grep -l $mac /sys/class/net/*/address|head -n 1) + dev=${dev%/*} + [ -n "$dev" ] && echo "${dev##*/}" + fi for x in /sys/class/net/eth*; do if grep -iq up $x/operstate;then [ -e "$x" ] && echo ${x##*/} && return @@ -294,7 +300,8 @@ set -- $(cat /proc/cmdline) myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm cryptheader cryptoffset cryptdiscards cryptkey debug_init dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root usbdelay ip alpine_repo apkovl alpine_start splash - blacklist overlaytmpfs rootfstype rootflags nbd resume s390x_net dasd ssh_key" + blacklist overlaytmpfs rootfstype rootflags nbd resume s390x_net dasd ssh_key + BOOTIF" for opt; do case "$opt" in |