#!/bin/sh
#
# $Id: Filesystem.in,v 1.6 2006/02/11 13:40:42 xunsun Exp $
# 
# 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.

unset LC_ALL; export LC_ALL
unset LANGUAGE; export LANGUAGE

. /etc/ha.d/resource.d//hto-mapfuncs

usage() {

cat <<-EOT;
	usage: $0 <device> <directory> [<fstype> [<options>]] {start|stop|status}

	<device>    : name of block device for the filesystem. e.g. /dev/sda1,
		      /dev/md0 OR -LFileSystemLabel OR -Uuuid OR an NFS 
		      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 as -o options to mount.

	$Id: Filesystem.in,v 1.6 2006/02/11 13:40:42 xunsun Exp $
	EOT
}

# Check the arguments passed to this script
case $# in
  3)	fstype=""; operation=$3; options="";;
  4)	fstype=$3; operation=$4; options="";;
  5)	fstype=$3; operation=$5; options="$4";;
  *)	usage; exit 1;;
esac

# Look for the 'start', 'stop' or 'status' argument
case "$operation" in
	start|stop|status);;
	*)	usage
		exit 1
		;;
esac
ra_execocf  "rsc_id=Filesystem_$1" "rsc_type=Filesystem" "provider=heartbeat" $operation "device=$1" "directory=$2" "fstype=$fstype" "options=$options"
