Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # In case the interface is used as nfsroot, avoid ifup, otherwise |
| 4 | # nfsroot may lose response |
| 5 | |
| 6 | nfsroot=0 |
| 7 | |
| 8 | if test "x$IFACE" = xlo ; then |
| 9 | exit 0 |
| 10 | fi |
| 11 | |
| 12 | exec 9<&0 < /proc/mounts |
| 13 | while read dev mtpt fstype rest; do |
| 14 | if test $mtpt = "/" ; then |
| 15 | case $fstype in |
| 16 | nfs | nfs4) |
| 17 | nfsroot=1 |
| 18 | nfs_addr=`echo $rest | sed -e 's/^.*addr=\([0-9.]*\).*$/\1/'` |
| 19 | break |
| 20 | ;; |
| 21 | *) |
| 22 | ;; |
| 23 | esac |
| 24 | fi |
| 25 | done |
| 26 | exec 0<&9 9<&- |
| 27 | |
| 28 | test $nfsroot -eq 0 && exit 0 |
| 29 | |
| 30 | if [ -x /bin/ip -o -x /sbin/ip ] ; then |
| 31 | nfs_iface=`ip route get $nfs_addr | grep dev | sed -e 's/^.*dev \([-a-z0-9.]*\).*$/\1/'` |
| 32 | fi |
| 33 | |
| 34 | if test "x$IFACE" = "x$nfs_iface" ; then |
| 35 | echo "ifup skipped for nfsroot interface $nfs_iface" |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | exit 0 |