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