#!/bin/bash## 20110922 neovandeen@googlemail.com## mount a NFS share, if it's available## Config file (NFS.conf) looks like: # <server>:/export/;/mount/point/# It should be located in the same direcory# ###########################################
MOUNT=`which mount`
PING=`which ping`
CONFIG="`dirname ${0}`/NFS.conf"for line in`cat ${CONFIG}`;do# find the servername
PSERVER=`echo ${line}|cut -d ':' -f1`
SERVER=`echo ${line}|cut -d ';' -f1`
SHARE=`echo ${line}|cut -d ';' -f2`# do we've already mounted it?
DOMOUNT=`${MOUNT} -l -t nfs|grep ${SERVER}`if [ ${?} -eq 1 ];then# is the server available?
DOPING=`${PING} -A -c10 ${PSERVER}`if [ ${?} -eq 0 ];then${MOUNT} -t nfs ${SERVER}${SHARE}fifidone
exit 0
# EOS