A cleaner way of mounting the nfs shares than Josep provided is something like what I have below. It looks for whether the nfs server responds to a ping rather than the default route and will retry 3 times with a 3 second timeout each time. It also checks all nfs mount points listed in /etc/fstab which largely restores the functionality of that file.
In any case this is a work around and it seems that fixing the original bug would be preferable to continued effort in this direction.
cat /etc/fstab | sed 's/#.*//' | grep nfs | while read LINE
do
HOST=`echo "$LINE" | cut -f1 -d:`
DIR=`echo "$LINE" | awk '{print $2}'`
if ! mount -l -t nfs | awk '{print $3}' | grep -q "^$DIR$"
then echo -n "Mounting '$DIR'" COUNT=0 STOP=0 while [ $STOP -eq 0 -a $COUNT -lt 3 ]
do if ping -qAc 3 $HOST > /dev/null then mount $DIR STOP=1 echo " done." else # no sleep needed here because ping will take 3 seconds to fail anyway COUNT=$( expr $COUNT + 1 ) echo -n "." fi done
if [ $STOP -eq 0 ] then echo " failed. $HOST not responding."
fi
else echo "$DIR already mounted"
fi
done
A cleaner way of mounting the nfs shares than Josep provided is something like what I have below. It looks for whether the nfs server responds to a ping rather than the default route and will retry 3 times with a 3 second timeout each time. It also checks all nfs mount points listed in /etc/fstab which largely restores the functionality of that file.
In any case this is a work around and it seems that fixing the original bug would be preferable to continued effort in this direction.
cat /etc/fstab | sed 's/#.*//' | grep nfs | while read LINE
echo -n "Mounting '$DIR'"
COUNT= 0
STOP= 0
while [ $STOP -eq 0 -a $COUNT -lt 3 ]
if ping -qAc 3 $HOST > /dev/null
then
mount $DIR
STOP= 1
echo " done."
else
# no sleep needed here because ping will take 3 seconds to fail anyway
COUNT= $( expr $COUNT + 1 )
echo -n "."
fi
done
then
echo " failed. $HOST not responding."
echo "$DIR already mounted"
do
HOST=`echo "$LINE" | cut -f1 -d:`
DIR=`echo "$LINE" | awk '{print $2}'`
if ! mount -l -t nfs | awk '{print $3}' | grep -q "^$DIR$"
then
do
if [ $STOP -eq 0 ]
fi
else
fi
done