-# mount lustre on mds
-lustre_client=$(facet_active_host $SINGLEMDS)
-[ "$NFSVERSION" = "4" ] && cl_mnt_opt="$MOUNTOPT,32bitapi" || cl_mnt_opt=""
-zconf_mount_clients $lustre_client $MOUNT "$cl_mnt_opt" || \
- error "mount lustre on $lustre_client failed"
+# lustre client used as nfs server (default is mds node)
+LUSTRE_CLIENT_NFSSRV=${LUSTRE_CLIENT_NFSSRV:-$(facet_active_host $SINGLEMDS)}
+NFS_SRVMNTPT=${NFS_SRVMNTPT:-$MOUNT}
+NFS_CLIENTS=${NFS_CLIENTS:-$CLIENTS}
+NFS_CLIENTS=$(exclude_items_from_list $NFS_CLIENTS $LUSTRE_CLIENT_NFSSRV)
+NFS_CLIMNTPT=${NFS_CLIMNTPT:-$MOUNT}
+
+[ -z "$NFS_CLIENTS" ] &&
+ skip_env "need at least two nodes: nfs server and nfs client" && exit 0
+
+[ "$NFSVERSION" = "4" ] && cl_mnt_opt="${MOUNT_OPTS:+$MOUNT_OPTS,}32bitapi" ||
+ cl_mnt_opt=""
+
+cleanup_exit () {
+ trap 0
+ cleanup
+ check_and_cleanup_lustre
+ exit
+}
+
+cleanup () {
+ cleanup_nfs "$NFS_CLIMNTPT" "$LUSTRE_CLIENT_NFSSRV" "$NFS_CLIENTS" ||
+ error_noexit false "failed to cleanup nfs"
+ zconf_umount $LUSTRE_CLIENT_NFSSRV $NFS_SRVMNTPT force ||
+ error_noexit false "failed to umount lustre on"\
+ "$LUSTRE_CLIENT_NFSSRV"
+ # restore lustre mount
+ restore_mount $MOUNT ||
+ error_noexit false "failed to mount lustre"
+}
+
+trap cleanup_exit EXIT SIGHUP SIGINT
+
+zconf_mount $LUSTRE_CLIENT_NFSSRV $NFS_SRVMNTPT "$cl_mnt_opt" ||
+ error "mount lustre on $LUSTRE_CLIENT_NFSSRV failed"