Whamcloud - gitweb
97c8c31c401b3b971ae07fa667a0943265122521
[fs/lustre-release.git] / lustre / tests / setup-nfs.sh
1 #!/bin/bash
2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
3 #set -x
4 EXPORT_OPTS=${EXPORT_OPTS:-"rw,async,no_root_squash"}
5
6 setup_nfs() {
7     local NFS_VER=${1}
8     local MNTPNT=${2}
9     local LUSTRE_CLIENT=${3}
10     local NFS_CLIENTS=${4}
11     local export_opts_v=$EXPORT_OPTS
12
13     echo "Exporting Lustre filesystem..."
14
15     if [ "$NFS_VER" = "4" ]; then
16         export_opts_v="$EXPORT_OPTS,fsid=0"
17         do_nodes $LUSTRE_CLIENT "mkdir -p /var/lib/nfs/v4recovery"
18     fi
19
20     do_nodes $LUSTRE_CLIENT,$NFS_CLIENTS "grep -q rpc_pipefs' ' /proc/mounts ||\
21         { mkdir -p /var/lib/nfs/rpc_pipefs && \
22         mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs; }" || return 1
23     sleep 5
24
25     do_nodes $LUSTRE_CLIENT "service nfs restart" || return 1
26
27     do_nodes $NFS_CLIENTS "service rpcidmapd restart" || return 1
28
29     do_nodes $LUSTRE_CLIENT "exportfs -o $export_opts_v *:$MNTPNT \
30         && exportfs -v" || return 1
31
32     echo -e "\nMounting NFS clients (version $NFS_VER)..."
33
34     do_nodes $NFS_CLIENTS "mkdir -p $MNTPNT" || return 1
35     if [ "$NFS_VER" = "4" ]; then
36         do_nodes $NFS_CLIENTS \
37             "mount -t nfs$NFS_VER -o async $LUSTRE_CLIENT:/ $MNTPNT" || return 1
38     else
39         do_nodes $NFS_CLIENTS \
40             "mount -t nfs -o nfsvers=$NFS_VER,async \
41                 $LUSTRE_CLIENT:$MNTPNT $MNTPNT" || return 1
42     fi
43     return 0
44 }
45
46 cleanup_nfs() {
47     local MNTPNT=${1}
48     local LUSTRE_CLIENT=${2}
49     local NFS_CLIENTS=${3}
50
51     echo -e "\nUnmounting NFS clients..."
52     do_nodes $NFS_CLIENTS "umount -f $MNTPNT" || return 1
53
54     echo -e "\nUnexporting Lustre filesystem..."
55     do_nodes $NFS_CLIENTS "service rpcidmapd stop" || return 1
56
57     do_nodes $LUSTRE_CLIENT "service nfs stop" || return 1
58
59     do_nodes $LUSTRE_CLIENT "exportfs -u *:$MNTPNT" || return 1
60
61     do_nodes $LUSTRE_CLIENT "exportfs -v"
62 }