aboutsummaryrefslogtreecommitdiffstats
path: root/initramfs-init.in
diff options
context:
space:
mode:
authorMick Tarsel <mtarsel@gmail.com>2018-06-08 21:38:22 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2018-06-12 17:28:07 +0000
commit7e7fed4fee4c2e0bafd4a9714649b185b8696921 (patch)
tree0259d793e35f0a7a995d85842ef9240ffedf936e /initramfs-init.in
parent33865428099cf29934d02342f008e440b69b74c2 (diff)
downloadmkinitfs-7e7fed4fee4c2e0bafd4a9714649b185b8696921.tar.bz2
mkinitfs-7e7fed4fee4c2e0bafd4a9714649b185b8696921.tar.xz
Use first network interface that is up
Previous code would return eth0 every time and pay no attention if interface was up. This patch gets the state from operstate file in sysfs to use the interface that is actually up in case there are multiple interfaces present. If no interface is up, just use last interface.
Diffstat (limited to 'initramfs-init.in')
-rwxr-xr-xinitramfs-init.in5
1 files changed, 4 insertions, 1 deletions
diff --git a/initramfs-init.in b/initramfs-init.in
index 413fa1d..fd3c50c 100755
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -145,8 +145,11 @@ setup_inittab_console(){
# uses the first "eth" interface.
ip_choose_if() {
for x in /sys/class/net/eth*; do
- [ -e "$x" ] && echo ${x##*/} && return
+ if grep -iq up $x/operstate;then
+ [ -e "$x" ] && echo ${x##*/} && return
+ fi
done
+ [ -e "$x" ] && echo ${x##*/} && return
}
# ip_set <device> <ip> <netmask> <gateway-ip>