Whamcloud - gitweb
LU-11010 tests: remove calls to return after skip()
[fs/lustre-release.git] / lustre / tests / setup-nfs.sh
1 #!/bin/bash
2 #set -x
3 EXPORT_OPTS=${EXPORT_OPTS:-"rw,async,no_root_squash"}
4
5 setup_nfs() {
6         local NFS_VER=${1}
7         local MNTPNT=${2}
8         local LUSTRE_CLIENT=${3}
9         local NFS_CLIENTS=${4}
10         local nfs_climntpt=${5:-$MNTPNT}
11
12     local export_opts_v=$EXPORT_OPTS
13
14     echo "Exporting Lustre filesystem..."
15
16     if [ "$NFS_VER" = "4" ]; then
17         export_opts_v="$EXPORT_OPTS,fsid=0"
18         do_nodes $LUSTRE_CLIENT "mkdir -p /var/lib/nfs/v4recovery"
19     fi
20
21     do_nodes $LUSTRE_CLIENT,$NFS_CLIENTS "grep -q rpc_pipefs' ' /proc/mounts ||\
22         { mkdir -p /var/lib/nfs/rpc_pipefs && \
23         mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs; }" || return 1
24     sleep 5
25
26         do_nodes $LUSTRE_CLIENT "echo $MNTPNT *\($export_opts_v\) \
27                                  >> /etc/exports" || return 1
28
29         # restart nfs server according to distro
30         do_nodes $LUSTRE_CLIENT "{ [[ -e /etc/SuSE-release ]] &&
31                                  service nfsserver restart; } ||
32                                  service nfs restart" || return 1
33
34         do_nodes $NFS_CLIENTS "chkconfig --list rpcidmapd 2>/dev/null |
35                                grep -q rpcidmapd && service rpcidmapd restart ||
36                                true"
37
38         echo -e "\nMounting NFS clients (version $NFS_VER)..."
39
40         do_nodes $NFS_CLIENTS "mkdir -p $nfs_climntpt" || return 1
41         if [ "$NFS_VER" = "4" ]; then
42                 do_nodes $NFS_CLIENTS \
43                         "mount -t nfs$NFS_VER -o async \
44                         $LUSTRE_CLIENT:/ $nfs_climntpt" || return 1
45         else
46                 do_nodes $NFS_CLIENTS \
47                         "mount -t nfs -o nfsvers=$NFS_VER,async \
48                         $LUSTRE_CLIENT:$MNTPNT $nfs_climntpt" || return 1
49         fi
50         return 0
51 }
52
53 cleanup_nfs() {
54         local MNTPNT=${1}
55         local LUSTRE_CLIENT=${2}
56         local NFS_CLIENTS=${3}
57
58         echo -e "\nUnmounting NFS clients..."
59         do_nodes $NFS_CLIENTS "umount -f $MNTPNT" || true
60
61         echo -e "\nUnexporting Lustre filesystem..."
62         do_nodes $NFS_CLIENTS "chkconfig --list rpcidmapd 2>/dev/null |
63                                grep -q rpcidmapd && service rpcidmapd stop ||
64                                true"
65
66         do_nodes $LUSTRE_CLIENT "{ [[ -e /etc/SuSE-release ]] &&
67                                  service nfsserver stop; } ||
68                                  service nfs stop" || return 1
69
70         do_nodes $LUSTRE_CLIENT "sed -i '/${MNTPNT##*/}/d' /etc/exports" || return 1
71
72         do_nodes $LUSTRE_CLIENT "exportfs -v"
73 }