#!/bin/sh
#
# 
# Description:	wrapper of OCF RA Filesystem, based on original heartbeat RA.
#		See OCF RA Filesystem for more information.
#
# Author:	Xun Sun <xunsun@cn.ibm.com>
# Support:      linux-ha@lists.linux-ha.org
# License:      GNU General Public License (GPL)
# Copyright:	(C) 2005 International Business Machines
#
# usage: ./Filesystem <device> <directory> [<fstype> [<options>]] {start|stop|status}
#
#<device>    : name of block device for the filesystem. e.g. /dev/sda1, /dev/md0
#		Or a -U or -L option for mount, or an NFS mount specification,
#		or a samba share
#<directory> : the mount point for the filesystem
#<fstype>    : optional name of the filesystem type. e.g. ext2
#<options>   : options to be given to the mount command via -o
#
#
# An example usage in /etc/ha.d/haresources: 
#       node1  10.0.0.170 Filesystem::/dev/sda1::/data1::ext2
#  or
#       node1  10.0.0.170 Filesystem::-Ldata1::/data1::ext2
#  or
#       node1  10.0.0.170 Filesystem::server:/data1::/data1::nfs::ro
#
# This assumes you want to manage a filesystem on a shared (scsi) bus.
# Do not put this filesystem in /etc/fstab.  This script manages all of
# that for you.

. @HB_RA_DIR@/hto-mapfuncs

usage() {
    echo "usage: $0 <device> <directory> [<fstype> [<options>]] $LEGAL_ACTIONS"
    exit 1
}

# Check the arguments passed to this script
if [ $# -lt 3 ]; then
    usage
fi

if [ "x$2" != "x" ]; then
    OCF_RESKEY_device="$1"; shift 
    export OCF_RESKEY_device
fi

if [ "x$2" != "x" ]; then
    OCF_RESKEY_directory="$1"; shift
    export OCF_RESKEY_directory
fi

if [ "x$2" != "x" ]; then
    OCF_RESKEY_fstype=$1; shift
    export OCF_RESKEY_fstype
fi

if [ "x$2" != "x" ]; then
    OCF_RESKEY_options="$1";  shift
    export OCF_RESKEY_options
fi

OCF_TYPE=Filesystem
OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$OCF_RESKEY_device
export OCF_TYPE OCF_RESOURCE_INSTANCE

ra_execocf  $1
