Last summer I posted a script that would repeatedly (via cron) check on a availability and status of a NFS mount, and attempt to keep it mounted if possible. That script was written for (Free)BSD. Below is a slightly modified version that runs on Linux (in this case, CentOS).
#!/bin/sh
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# remote system name
remotesystem=sunrise.externalized.net
# remote share name
remoteshare=/nfs4exports/minecraft-backups
# local mount point
mountpoint=/bak/remote
# file to indicate local mount status
testfile=$mountpoint/.minecraftbackups
# command locations
pingcmd=/bin/ping
showmountcmd=/usr/sbin/showmount
grepcmd=/bin/grep
mountcmd=/bin/mount
umountcmd=/bin/umount
statcmd=/usr/bin/stat
# --- end variables ---
# make sure the mountpoint is not stale
testvar=`${statcmd} ${mountpoint} 2>&1 | ${grepcmd} "Stale"`
if [ "${testvar}" != "" ]; then
#result not empty: mountpoint is stale; remove it
${umountcmd} -f ${mountpoint}
fi
# ping the remote system (2 sec timeout)
${pingcmd} -w2 -c1 -q ${remotesystem} > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
# server is available so query availability of the remote share; not empty is OK
offsiteshare=`${showmountcmd} -e ${remotesystem} | ${grepcmd} "${remoteshare}"`
# make sure the local mountpoint is not active
localmount=`${mountcmd} | ${grepcmd} "${mountpoint}"`
if [ "${offsiteshare}" != "" ] ; then
if [ ! -e ${testfile} ] ; then
if [ "${localmount}" = "" ] ; then
${mountcmd} -w -t nfs ${remotesystem}:${remoteshare} ${mountpoint}
fi
fi
fi
fi
exit 0