Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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}

        fi
fi
done

exit 0

# EOS