# do not stop an interface on nfsroot systems, it hangs reboot or shutdown

# do nothing if not nfsroot
if ! grep -q '\(^\| \)nfsroot=' /proc/cmdline; then
    return
fi

# do nothing if this is not an Ethernet interface (ethX or enXXX)
if [ "${interface#eth}" =  "${interface}" ] && [ "${interface#en}" =  "${interface}" ]; then
    return
fi

# we really need to abort and exit the sourcing script on situations that would
# certainly mean deconfiguring the network interface or changing its IP address,
# we cannot risk the sourcing script to do anything else, not even run its exit hooks
case "$reason" in
    STOP|RELEASE|TIMEOUT|FAIL|STOP6|RELEASE6)
        logger -p daemon.err "aborting dhclient $reason event on $interface due to nfsroot"
        exit 1
        ;;
    EXPIRE|EXPIRE6)
        if [ $(sed -e 's/\..*//' /proc/uptime) -lt 3600 ]; then
            logger -p daemon.err "aborting dhclient $reason event on $interface due to nfsroot and recent boot"
            exit 1
        fi
        ;;
esac
