xref: /OK3568_Linux_fs/buildroot/package/ifupdown-scripts/nfs_check (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3# This allows NFS booting to work while also being able to configure
4# the network interface via DHCP when not NFS booting.  Otherwise, a
5# NFS booted system will likely hang during DHCP configuration.
6
7# Attempting to configure the network interface used for NFS will
8# initially bring that network down.  Since the root filesystem is
9# accessed over this network, the system hangs.
10
11# This script is run by ifup and will attempt to detect if a NFS root
12# mount uses the interface to be configured (IFACE), and if so does
13# not configure it.  This should allow the same build to be disk/flash
14# booted or NFS booted.
15
16nfsip=`sed -n '/^[^ ]*:.* \/ nfs.*[ ,]addr=\([0-9.]\+\).*/s//\1/p' /proc/mounts`
17if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then
18	echo Skipping $IFACE, used for NFS from $nfsip
19	exit 1
20fi
21