#!/bin/sh
#
# $Id: Raid1.in,v 1.3 2005/11/03 07:45:51 xunsun Exp $
# 
# Description:	wrapper of OCF RA Raid1, based on original heartbeat RA.
#		See OCF RA Raid1 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: $0 <raidtab_config_file> <md_dev_name> {start|stop|status}
#
# in /etc/ha.d/haresources, use a line such as:
# nodea  10.0.0.170 Raid1::/etc/raidtab.md0::/dev/md0 Filesystem::/dev/md0::/data1::ext2
#
# The "start" arg starts up the raid device
# The "stop" arg stops it.  NOTE: all filesystems must be unmounted
#  and no processes should be accessing the device.
# The "status" arg just prints out whether the device is running or not
# 

unset LC_ALL; export LC_ALL
unset LANGUAGE; export LANGUAGE

# Source function library.
. /etc/ha.d/resource.d//hto-mapfuncs

usage() {
cat <<-EOT
	usage: $0 <raidtab_config_file> <md_dev_name> {start|stop|status}

	<raidtab_config_file> : name of MD configuration file. e.g. /etc/raidtab
	<md_dev_name>         : of the form /dev/md?? (the block device to use)

	$Id: Raid1.in,v 1.3 2005/11/03 07:45:51 xunsun Exp $
EOT
}

if [ ! -f "$1" ] ; then
	echo "ERROR: Couldn't open file $1"
	usage
	exit 1
fi

if [ ! -b "$2" ] ; then
	echo "ERROR: Couldn't find MD device $MDDEV. Expected /dev/md* to exist"
	usage
	exit 1
fi

case "$3" in
	start|stop|status)
		;;
	*)	usage
		exit 1
		;;
esac

ra_execocf  "rsc_id=Raid1_$2" "rsc_type=Raid1" "provider=heartbeat" $3 "raidconf=$1" "raiddev=$2"
