Send Linux-ha-cvs mailing list submissions to linux-ha-cvs@lists.linux-ha.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Linux-ha-cvs digest..." Today's Topics: 1. Linux-HA CVS: resources by andrew from (linux-ha-cvs@lists.linux-ha.org) ---------------------------------------------------------------------- Message: 1 Date: Mon, 14 Aug 2006 03:37:22 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: resources by andrew from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : andrew Host : Project : linux-ha Module : resources Dir : linux-ha/resources/heartbeat Modified Files: AudibleAlarm.in Delay.in Filesystem.in ICP.in IPaddr.in IPaddr2.in IPsrcaddr.in IPv6addr.in LVM.in LinuxSCSI.in MailTo.in Raid1.in ServeRAID.in WAS.in WinPopup.in Xinetd.in apache.in db2.in hto-mapfuncs.in portblock.in Log Message: Remove the most bizare abstraction code I've seen to date Remove all redundant features from the wrappers Wrappers now *only* grab the required options and pass them to the real RA =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/AudibleAlarm.in,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- AudibleAlarm.in 8 Nov 2005 01:18:34 -0000 1.6 +++ AudibleAlarm.in 14 Aug 2006 09:37:21 -0000 1.7 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: AudibleAlarm.in,v 1.6 2005/11/08 01:18:34 xunsun Exp $ +# $Id: AudibleAlarm.in,v 1.7 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA AudibleAlarm, based on original heartbeat RA. # See OCF RA AudibleAlarm for more information. @@ -14,26 +14,23 @@ . @HB_RA_DIR@/hto-mapfuncs usage() { - echo "Usage: $0 [node1 node2 ... ] {start|stop|restart|status}" - echo " The node list is an optional space delimited" - echo " list of hosts that should never sound the alarm." - echo "$Id: AudibleAlarm.in,v 1.6 2005/11/08 01:18:34 xunsun Exp $"; + echo "Usage: $0 [node1 node2 ... ] $LEGAL_ACTIONS" } + +if [ $# = 0 ]; then + usage +fi + # Get operation name, which is the last argument we are passed. for arg in "$@"; do op=$arg done -# See how we were called. -case "$op" in - start|stop|restart|status) - ;; - usage) - usage; exit 0;; - *) - usage; exit 1;; -esac - nodelist=`echo $* | sed 's%'$op'$%%'` -ra_execocf "rsc_id=AudibleAlarm" "rsc_type=AudibleAlarm" "provider=heartbeat" $op "nodelist=$nodelist" +OCF_TYPE=AudibleAlarm +OCF_RESOURCE_INSTANCE=AudibleAlarm +export OCF_TYPE OCF_RESOURCE_INSTANCE + +OCF_RESKEY_nodelist=$nodelist; export OCF_RESKEY_nodelist +ra_execocf $op =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/Delay.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- Delay.in 2 Apr 2006 14:35:29 -0000 1.5 +++ Delay.in 14 Aug 2006 09:37:21 -0000 1.6 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Delay.in,v 1.5 2006/04/02 14:35:29 xunsun Exp $ +# $Id: Delay.in,v 1.6 2006/08/14 09:37:21 andrew Exp $ # # License: GNU General Public License (GPL) # Support: [EMAIL PROTECTED] @@ -15,29 +15,28 @@ # usage() { - cat <<-! - usage: $0 [delay [stopdelay]] {start|stop|status|monitor}"; - $Id: Delay.in,v 1.5 2006/04/02 14:35:29 xunsun Exp $ - ! + echo "usage: $0 [delay [stopdelay]] $LEGAL_ACTIONS" exit 1 } . @HB_RA_DIR@/hto-mapfuncs -startdelay= -stopdelay= - case $# in 1) op=$1;; - 2) startdelay=$1; op=$2;; - 3) startdelay=$1; stopdelay=$2; op=$3;; + 2) OCF_RESKEY_startdelay=$1; export OCF_RESKEY_startdelay; op=$2;; + 3) OCF_RESKEY_startdelay=$1; + OCF_RESKEY_stopdelay=$2; + export OCF_RESKEY_startdelay OCF_RESKEY_stopdelay; + op=$3;; *) usage;; esac -case $op in - start|stop|status|monitor) - ;; - *) - usage;; -esac -ra_execocf "rsc_id=Delay" "rsc_type=Delay" "provider=heartbeat" $op "startdelay=$startdelay" "stopdelay=$stopdelay" +if [ -z $OCF_RESKEY_startdelay ]; then + OCF_RESKEY_startdelay=10 +fi + +OCF_TYPE=Delay +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_${OCF_RESKEY_startdelay} +export OCF_TYPE OCF_RESOURCE_INSTANCE + +ra_execocf $op;; =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/Filesystem.in,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- Filesystem.in 11 Feb 2006 13:40:42 -0000 1.6 +++ Filesystem.in 14 Aug 2006 09:37:21 -0000 1.7 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Filesystem.in,v 1.6 2006/02/11 13:40:42 xunsun Exp $ +# $Id: Filesystem.in,v 1.7 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA Filesystem, based on original heartbeat RA. # See OCF RA Filesystem for more information. @@ -31,40 +31,40 @@ # 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 - . @HB_RA_DIR@/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 + echo "usage: $0 <device> <directory> [<fstype> [<options>]] $LEGAL_ACTIONS" + exit 1 } # 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" +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=IPaddr +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$OCF_RESKEY_device +export OCF_TYPE OCF_RESOURCE_INSTANCE + +ra_execocf $1 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/ICP.in,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ICP.in 3 Nov 2005 07:45:51 -0000 1.4 +++ ICP.in 14 Aug 2006 09:37:21 -0000 1.5 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: ICP.in,v 1.4 2005/11/03 07:45:51 xunsun Exp $ +# $Id: ICP.in,v 1.5 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA ICP, based on original heartbeat RA. # See OCF RA ICP for more information. @@ -21,63 +21,22 @@ . @HB_RA_DIR@/hto-mapfuncs -unset LC_ALL; export LC_ALL -unset LANGUAGE; export LANGUAGE - usage() { - methods=`ICP_methods` - methods=`echo $methods | tr ' ' '|'` - cat <<-! >&1 - usage: $0 <ICP cluster drive ID> <device> {$methods} - usage: $0 methods - - $0 manages an ICP Vortex clustered host drive. - - The 'start' operation reserves the given host drive. - The 'stop' operation releses the given host drive. - The 'status' operation reports whether the host drive is reserved. - The 'monitor' operation reports whether the host drive is reserved. - The 'methods' operation reports on the methods $0 supports - - $Id: ICP.in,v 1.4 2005/11/03 07:45:51 xunsun Exp $ - ! - exit 1 + echo "usage: $0 <ICP cluster drive ID> <device> $LEGAL_ACTIONS" + exit 1 } -# -# methods: What methods/operations do we support? -# -ICP_methods() { - cat <<-! - start - stop - status - monitor - methods - ! -} - -# -# 'main' starts here... -# -case $# in - 1) if [ "methods" = "$1" ]; then - ICP_methods - exit $? - fi;; - 3) ;; - *) usage;; -esac - -# What kind of method was invoked? -case "$3" in - start|stop|status|monitor) - ;; - methods) - ICP_methods - exit $?;; - *) - usage;; -esac +if [ $# != 3 ]; then + usage + exit 1 +fi + +OCF_TYPE=ICP +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$1 +export OCF_TYPE OCF_RESOURCE_INSTANCE + +OCF_RESKEY_driveid=$1 +OCF_RESKEY_device=$2 +export OCF_RESKEY_device OCF_RESKEY_driveid -ra_execocf "rsc_id=ICP_$1" "rsc_type=ICP" "provider=heartbeat" $3 "driveid=$1" "device=$2" +ra_execocf $3 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/IPaddr.in,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- IPaddr.in 10 Jun 2006 17:33:30 -0000 1.19 +++ IPaddr.in 14 Aug 2006 09:37:21 -0000 1.20 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: IPaddr.in,v 1.19 2006/06/10 17:33:30 alan Exp $ +# $Id: IPaddr.in,v 1.20 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA IPaddr, based on original heartbeat RA. # See OCF RA IPaddr for more information. @@ -21,71 +21,45 @@ # Surprisingly, the "stop" arg removes one. :-) # -unset LC_ALL; export LC_ALL # Make ifconfig work in France for David Jules :-) -unset LANGUAGE; export LANGUAGE # Make ifconfig work in France for Fabrice :-) -# make ifconfig work in Austria for Gregor Göstl -# I have no idea why the previous fix didn't fix it for him. -LC_MESSAGES=C -export LC_MESSAGES - . @HB_RA_DIR@/hto-mapfuncs -USAGE="usage: $0 <ip-address> {start|stop|status|monitor}"; usage() { - echo $USAGE >&2 - echo "$Id: IPaddr.in,v 1.19 2006/06/10 17:33:30 alan Exp $" + echo "usage: $0 <ip-address> $LEGAL_ACTIONS" + exit 1 } -# -# Add or remove IP alias for the given IP address... -# - -case $# in - 1) - case $1 in - info) cat <<-!INFO - Abstract=IP address takeover - Argument=IP address OR IP address/broadcast address OR IP address/broadcast address/netmaskbits - Description: - An IPaddr resource is an IP address which is to be taken over by \\ - the owning node. An argument is required, and is of this form: - nnn.nnn.nnn.nnn/bbb.bbb.bbb.bbb - Where nnn.nnn.nnn.nnn is the IP address to be taken over, and\\ - bbb.bbb.bbb.bbb is the broadcast address to be used with this address. - - Since IPaddr is the "default" resource type, it is not necessary\\ - to prefix the IP address by "IPaddr::". - This allows IPaddr::192.2.4.63 to be abbreviated as 192.2.4.63. - !INFO - exit 0;; - esac;; - 2) ;; - *) usage - exit 1;; -esac +if [ $# != 2 ]; then + usage +fi # We need to split the argument into pieces that IPaddr OCF RA can # recognize, sed is prefered over Bash specific builtin functions # for portability. BASEIP=`echo $1 | sed 's%/.*%%'` -str=`echo $1 | sed 's%^'$BASEIP'/*%%'` +OCF_RESKEY_ip=$BASEIP; export OCF_RESKEY_ip +str=`echo $1 | sed 's%^'$BASEIP'/*%%'` if [ ! -z "$str" ]; then - NETMASK=`echo $str | sed 's%/.*%%'` - str=`echo $str | sed 's%^'$NETMASK'/*%%'` + NETMASK=`echo $str | sed 's%/.*%%'` + OCF_RESKEY_cidr_netmask=$NETMASK; export OCF_RESKEY_cidr_netmask - NIC=`echo $str | sed 's%/.*%%'` - case $NIC in + str=`echo $str | sed 's%^'$NETMASK'/*%%'` + NIC=`echo $str | sed 's%/.*%%'` + case $NIC in [0-9]*) BROADCAST=$NIC - NIC= - ;; + OCF_RESKEY_broadcast=$BROADCAST; export OCF_RESKEY_broadcast + NIC= + ;; "") ;; *) BROADCAST=`echo $str | sed -e 's%^'$NIC'/*%%' -e 's%/.*%%'` - ;; - esac + OCF_RESKEY_nic=$NIC; export OCF_RESKEY_nic + OCF_RESKEY_broadcast=$BROADCAST; export OCF_RESKEY_broadcast + ;; + esac fi + # # Determine if this IP address is really being served, or not. # Note that we don't distinguish if *we're* serving it locally... @@ -122,14 +96,15 @@ } case $2 in - start|stop|status) - ;; monitor) ip_monitor ;; - *) usage - exit 1 + *) ;; esac -ra_execocf "rsc_id=IPaddr_$BASEIP" "rsc_type=IPaddr" "provider=heartbeat" $2 "ip=$BASEIP" "broadcast=$BROADCAST" "nic=$NIC" "cidr_netmask=$NETMASK" +OCF_TYPE=IPaddr +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$BASEIP +export OCF_TYPE OCF_RESOURCE_INSTANCE + +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/IPaddr2.in,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- IPaddr2.in 10 Jun 2006 17:33:30 -0000 1.12 +++ IPaddr2.in 14 Aug 2006 09:37:21 -0000 1.13 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: IPaddr2.in,v 1.12 2006/06/10 17:33:30 alan Exp $ +# $Id: IPaddr2.in,v 1.13 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA IPaddr2, based on original heartbeat RA. # See OCF RA IPaddr2 for more information. @@ -27,50 +27,44 @@ . @HB_RA_DIR@/hto-mapfuncs -USAGE="usage: $0 ip-address[/netmaskbits[/interface[:label][/broadcast]]] -{start|stop|status|monitor}\n\nNote: $0 only works on Linux"; +# We need to split the argument into pieces that IPaddr OCF RA can +# recognize, sed is prefered over Bash specific builtin functions +# for portability. usage() { - echo -e $USAGE >&2 + echo "usage: $0 <ip-address> $LEGAL_ACTIONS" } -# -# Add or remove IP alias for the given IP address... -# -if - [ $# -ne 2 ] -then +if [ $# != 2 ]; then usage exit 1 fi -# We need to split the argument into pieces that IPaddr2 OCF RA can -# recognize, sed is prefered over Bash specific builtin functions -# for portability. - BASEIP=`echo $1 | sed 's%/.*%%'` -str=`echo $1 | sed 's%^'$BASEIP'/*%%'` +OCF_RESKEY_ip=$BASEIP; export OCF_RESKEY_ip +str=`echo $1 | sed 's%^'$BASEIP'/*%%'` if [ ! -z "$str" ]; then - NETMASK=`echo $str | sed 's%/.*%%'` - str=`echo $str | sed 's%^'$NETMASK'/*%%'` - - NIC=`echo $str | sed 's%/.*%%'` - case $NIC in - [0-9]*) BROADCAST=$NIC - NIC= - ;; - "") ;; - *) BROADCAST=`echo $str | sed -e 's%^'$NIC'/*%%' -e 's%/.*%%'` - ;; - esac + NETMASK=`echo $str | sed 's%/.*%%'` + OCF_RESKEY_cidr_netmask=$NETMASK; export OCF_RESKEY_cidr_netmask + + str=`echo $str | sed 's%^'$NETMASK'/*%%'` + NIC=`echo $str | sed 's%/.*%%'` + case $NIC in + [0-9]*) BROADCAST=$NIC + OCF_RESKEY_broadcast=$BROADCAST; export OCF_RESKEY_broadcast + NIC= + ;; + "") ;; + *) BROADCAST=`echo $str | sed -e 's%^'$NIC'/*%%' -e 's%/.*%%'` + OCF_RESKEY_nic=$NIC; export OCF_RESKEY_nic + OCF_RESKEY_broadcast=$BROADCAST; export OCF_RESKEY_broadcast + ;; + esac fi -case $2 in - start|stop|status|monitor) ;; - *) usage - exit 1 - ;; -esac +OCF_TYPE=IPaddr2 +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$BASEIP +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=IPaddr2_$BASEIP" "rsc_type=IPaddr2" "provider=heartbeat" $2 "ip=$BASEIP" "broadcast=$BROADCAST" "nic=$NIC" "cidr_netmask=$NETMASK" +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/IPsrcaddr.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- IPsrcaddr.in 3 Nov 2005 07:45:51 -0000 1.2 +++ IPsrcaddr.in 14 Aug 2006 09:37:21 -0000 1.3 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: IPsrcaddr.in,v 1.2 2005/11/03 07:45:51 xunsun Exp $ +# $Id: IPsrcaddr.in,v 1.3 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA IPsrcaddr, based on original heartbeat RA. # See OCF RA IPsrcaddr for more information. @@ -36,31 +36,20 @@ . @HB_RA_DIR@/hto-mapfuncs -USAGE="usage: $0 ip-address {start|stop|status|monitor}"; +USAGE="usage: $0 <ip-address> $LEGAL_ACTIONS"; usage() { - echo $USAGE >&2 + echo $USAGE >&2 + exit 1 } -# -# Add or remove the preferred source IP address to be used for packets -# originating on the localhost and leaving via the default route. -# - -if - [ $# -ne 2 ] -then - usage - exit 1 +if [ $# != 2 ]; then + usage fi -case $2 in - start|stop|status|monitor) - ;; - *) - usage - exit 1 - ;; -esac +OCF_TYPE=IPsrcaddr +OCF_RESOURCE_INSTANCE=${OCF_TYPE} +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=IPsrcaddr" "rsc_type=IPsrcaddr" "provider=heartbeat" $2 "ipaddress=$1" +OCF_RESKEY_ipaddress=$1; export OCF_RESKEY_ipaddres +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/IPv6addr.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- IPv6addr.in 3 Nov 2005 07:42:49 -0000 1.1 +++ IPv6addr.in 14 Aug 2006 09:37:21 -0000 1.2 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: IPv6addr.in,v 1.1 2005/11/03 07:42:49 xunsun Exp $ +# $Id: IPv6addr.in,v 1.2 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA IPv6addr. See OCF RA IPv6addr for more information. # @@ -13,23 +13,18 @@ # Source function library. . @HB_RA_DIR@/hto-mapfuncs -usage () { - echo "Usage: $0 <ipv6addr> {start|stop|status|monitor}" +usage() { + echo "usage: $0 <ip-address> $LEGAL_ACTIONS" + exit 1 } -if [ $# -ne 2 ]; then - usage - exit 1 +if [ $# != 2 ]; then + usage fi -# See how we were called. -case "$2" in - start|stop|monitor|status) - ;; - *) - usage - exit 1 - ;; -esac +OCF_TYPE=IPv6addr +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$1 +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=IPv6addr_$1" "rsc_type=IPv6addr" "provider=heartbeat" $2 "ipv6addr=$1" +OCF_RESKEY_ipv6addr=$1; export OCF_RESKEY_ipv6addr +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/LVM.in,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- LVM.in 29 Mar 2006 13:56:30 -0000 1.7 +++ LVM.in 14 Aug 2006 09:37:21 -0000 1.8 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: LVM.in,v 1.7 2006/03/29 13:56:30 xunsun Exp $ +# $Id: LVM.in,v 1.8 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA LVM, based on original heartbeat RA. # See OCF RA LVM for more information. @@ -19,60 +19,18 @@ . @HB_RA_DIR@/hto-mapfuncs -unset LC_ALL; export LC_ALL -unset LANGUAGE; export LANGUAGE - usage() { - methods=`LVM_methods | grep -v methods` - methods=`echo $methods | tr ' ' '|'` - cat <<-! >&1 - usage: $0 <LVM-configuration file> {$methods} - usage: $0 methods - - $0 manages an Linux Volume Manager (LVM) volume as an HA resource - - The 'start' operation brings the given volume online - The 'stop' operation takes the given volume offline - The 'status' operation reports whether the volume is available - The 'monitor' operation reports whether the volume seems present - The 'methods' operation reports on the methods $0 supports - - $Id: LVM.in,v 1.7 2006/03/29 13:56:30 xunsun Exp $ - ! - exit 1 + echo "usage: $0 <LVM-configuration file> $LEGAL_ACTIONS" + exit 1 } -# -# methods: What methods/operations do we support? -# -LVM_methods() { - cat <<-! - start - stop - status - monitor - methods - ! -} - -# -# 'main' starts here... -# - -case $# in - 1) if [ "methods" = "$1" ]; then - LVM_methods - exit $? - fi;; - 2) ;; - *) usage;; -esac -# What kind of method was invoked? -case "$2" in - start|stop|status|monitor) ;; - methods) LVM_methods - exit $?;; - *) usage -esac +if [ $# != 2 ]; then + usage +fi + +OCF_TYPE=LVM +OCF_RESOURCE_INSTANCE=${OCF_TYPE} +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=LVM_$1" "rsc_type=LVM" "provider=heartbeat" $2 "volgrpname=$1" +OCF_RESKEY_volgrpname=$1; export OCF_RESKEY_volgrpname +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/LinuxSCSI.in,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- LinuxSCSI.in 3 Nov 2005 07:45:51 -0000 1.3 +++ LinuxSCSI.in 14 Aug 2006 09:37:21 -0000 1.4 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: LinuxSCSI.in,v 1.3 2005/11/03 07:45:51 xunsun Exp $ +# $Id: LinuxSCSI.in,v 1.4 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA LinuxSCSI, based on original heartbeat RA. # See OCF RA LinuxSCSI for more information. @@ -26,104 +26,18 @@ # . @HB_RA_DIR@/hto-mapfuncs -unset LC_ALL; export LC_ALL -unset LANGUAGE; export LANGUAGE - usage() { - cat <<-! >&1 - usage: $0 <host>:<channel>:<target>[:<lun>] {start|stop|status} - - $0 manages the availability of a SCSI device from the point - of view of the Linux kernel. It makes Linux believe the - device has gone away, and it can make it come back again. - - The purpose of this resource script is to keep admins from - accidentally messing with a shared disk that is managed by the - HA subsystem and is currently owned by the other side. - - To get maximum benefit from this feature, you should (manually) - disable the resources on boot, and let your HA software enable - them when it wants to acquire the disk. - - The kernel code says this is potentially dangerous. DO NOT USE - IT ON AN ACTIVE DEVICE. If the device is inactive, this script - will make it stay inactive, when given "off". If you inactivate - the wrong device, you may have to reboot your machine, and your - data may take a hit. - - On the other hand, at least one RAID controller requires the - use of this technique for it to work correctly in a failover - environment - so it is believed that it is more stable in this - usage than the comments in the code imply. - - Here are the warnings from the kernel source about the "stop" - operation as of 2.4.10: - - ------------------------------ - Consider this feature pre-BETA. - CAUTION: This is not for hotplugging your peripherals. As - SCSI was not designed for this, you could damage your - hardware and thoroughly confuse the SCSI subsystem. - - Similar warnings apply to the "start" operation... - - Consider this feature BETA. - CAUTION: This is not for hotplugging your peripherals. - As SCSI was not designed for this you could damage your - hardware ! - However perhaps it is legal to switch on an already connected - device. It is perhaps not guaranteed this device doesn't corrupt - an ongoing data transfer. - ------------------------- - - So, Caveat Emptor, and test this feature thoroughly on - your kernel and your configuration with real load on the SCSI - bus before using it in production! - - Another potential trouble spot... - The order in which you bring up LinuxSCSI resources determines which - SCSI device they show up as on Linux. If you have two SCSI devices - in different resource groups they will be brought up asyncronously - resulting in indeterminate device name assignments. This usually - happens in an active-active configuration. - - To solve this you probably should use LVM or EVMS to manage these - volumes. LVM and EVMS solve this problem for you by labels they - keep in the volumes. If you don't use a reasonable volume manager, - then you'll have to mount by UUID. - - $Id: LinuxSCSI.in,v 1.3 2005/11/03 07:45:51 xunsun Exp $ - ! - exit 1 + echo "usage: $0 <host>:<channel>:<target>[:<lun>] $LEGAL_ACTIONS" + exit 1 } -scsi_methods() { - cat <<-! - start - stop - status - methods - ! -} - -case $# in - 1) if [ $1 = "methods" ]; then - scsi_methods - exit $? - fi;; - 2) ;; - *) usage;; -esac - -# Look for the start, stop, status, or methods calls... -case "$2" in - methods) - scsi_methods - exit $?;; - start|stop|status) - ;; - *) - usage;; -esac +if [ $# != 2 ]; then + usage +fi + +OCF_TYPE=LinuxSCSI +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$1 +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=LinuxSCSI_$1" "rsc_type=LinuxSCSI" "provider=heartbeat" $2 "scsi=$1" +OCF_RESKEY_scsi=$1; export OCF_RESKEY_scsi +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/MailTo.in,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- MailTo.in 3 Nov 2005 07:45:51 -0000 1.3 +++ MailTo.in 14 Aug 2006 09:37:21 -0000 1.4 @@ -18,35 +18,31 @@ . @HB_RA_DIR@/hto-mapfuncs usage() { - echo "Usage: $0 <email> [<subject>] {start|stop|status}" - echo "$Id: MailTo.in,v 1.3 2005/11/03 07:45:51 xunsun Exp $" + echo "Usage: $0 <email> [<subject>] $LEGAL_ACTIONS" exit 1 } -# -# See how we were called. -# case "$#" in 0|1) echo "At least 1 Email address has to be given!" usage ;; - 2) email=$1 + 2) cmd=$2 - subject="" + OCF_RESKEY_email=$1 + export OCF_RESKEY_email ;; - 3) email=$1 + 3) cmd=$3 - subject=$2 + OCF_RESKEY_email=$1 + OCF_RESKEY_subject=$2 + export OCF_RESKEY_email OCF_RESKEY_subject ;; *) echo "Additional parameters found: $# but max. 3 are allowed!" usage;; esac -case "$cmd" in - start|stop|status) - ;; - *) usage - ;; -esac +OCF_TYPE=MailTo +OCF_RESOURCE_INSTANCE=${OCF_TYPE} +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=MailTo" "rsc_type=MailTo" "provider=heartbeat" $cmd "email=$email" "subject=$subject" +ra_execocf $cmd =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/Raid1.in,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- Raid1.in 3 Nov 2005 07:45:51 -0000 1.3 +++ Raid1.in 14 Aug 2006 09:37:21 -0000 1.4 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Raid1.in,v 1.3 2005/11/03 07:45:51 xunsun Exp $ +# $Id: Raid1.in,v 1.4 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA Raid1, based on original heartbeat RA. # See OCF RA Raid1 for more information. @@ -21,41 +21,23 @@ # 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. . @HB_RA_DIR@/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 + echo "usage: $0 <raidtab_config_file> <md_dev_name> $LEGAL_ACTIONS" } -if [ ! -f "$1" ] ; then - echo "ERROR: Couldn't open file $1" - usage - exit 1 +if [ $# != 3 ]; then + 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" +OCF_TYPE=Raid1 +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$1 +export OCF_TYPE OCF_RESOURCE_INSTANCE + +OCF_RESKEY_raidconf=$1 +OCF_RESKEY_raiddev=$2 +export OCF_RESKEY_raiddev OCF_RESKEY_raidconf +ra_execocf $3 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/ServeRAID.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ServeRAID.in 3 Nov 2005 07:45:51 -0000 1.5 +++ ServeRAID.in 14 Aug 2006 09:37:21 -0000 1.6 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: ServeRAID.in,v 1.5 2005/11/03 07:45:51 xunsun Exp $ +# $Id: ServeRAID.in,v 1.6 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA ServeRAID, based on original heartbeat RA. # See OCF RA ServeRAID for more information. @@ -21,66 +21,21 @@ # Source function library. . @HB_RA_DIR@/hto-mapfuncs -unset LC_ALL; export LC_ALL -unset LANGUAGE; export LANGUAGE - usage() { - cat <<-! >&1 - usage: $0 <serveraid#> <sharedmergegroup#> {start|stop|status} - - The serveraid# is the number of the ServeRAID adapter - ServeRAID adapters are numbered starting from 1. - - The shared merge group number is a number between 1 and 8 inclusive. - It indicates to the controller which logical disk to fail over. - - node1 10.0.0.170 ServeRAID::1::1 - - PREREQUISITES: - You must configure your ServeRAID adapters for clustering for this - to work. - - To do this, you must use the bootable "ServeRAID Support CD" and right - click your controller and pick "configure for clustering". The Linux - version of the ServeRAID manager does not have the "configure for - clustering" option. - - You will need at least version 6.10 (~July 2003 release) of the ipssend - command for this script to work. The official releases are available from - IBM website. - - $Id: ServeRAID.in,v 1.5 2005/11/03 07:45:51 xunsun Exp $ - ! - exit 1 -} - -ServeRAID_methods() { - cat <<-! - start - stop - status - methods - ! + echo "usage: $0 <serveraid#> <sharedmergegroup#> $LEGAL_ACTIONS" + exit 1 } -case $# in - 1) if [ "$1" = "methods" ]; then - ServeRAID_methods - exit $? - fi;; - 3) ;; - *) usage;; -esac - -# Look for the start, stop, status, or methods calls... -case "$3" in - stop|start|status) - ;; - methods) - ServeRAID_methods - exit $?;; - *) - usage;; -esac +if [ $# != 3 ]; then + usage +fi + +OCF_TYPE=ServeRAID +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$1 +export OCF_TYPE OCF_RESOURCE_INSTANCE + +OCF_RESKEY_serveraid=$1 +OCF_RESKEY_mergegroup=$2 +export OCF_RESKEY_mergegroup OCF_RESKEY_serveraid -ra_execocf "rsc_id=ServeRAID_$1" "rsc_type=ServeRAID" "provider=heartbeat" $3 "serveraid=$1" "mergegroup=$2" +ra_execocf $3 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/WAS.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- WAS.in 3 Nov 2005 07:45:51 -0000 1.5 +++ WAS.in 14 Aug 2006 09:37:21 -0000 1.6 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: WAS.in,v 1.5 2005/11/03 07:45:51 xunsun Exp $ +# $Id: WAS.in,v 1.6 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA WAS, based on original heartbeat RA. # See OCF RA WAS for more information. @@ -19,93 +19,34 @@ # Source function library. . @HB_RA_DIR@/hto-mapfuncs -WGET=/usr/bin/wget -# -# unset LC_ALL; export LC_ALL unset LANGUAGE; export LANGUAGE usage() { - methods=`WAS_methods | grep -v methods` - methods=`echo $methods | tr ' ' '|'` cat <<-! >&1 For the single server edition of WAS: - usage: $0 [<WAS-configuration file>] {$methods} - usage: $0 methods + usage: $0 [<WAS-configuration file>] $LEGAL_ACTIONS For the advanced edition of WAS: - usage: $0 [<WAS-(snoop)-port-number>] {$methods} - usage: $0 methods - - $0 manages a Websphere Application Server (WAS) as an HA resource - - The 'start' operation starts WAS. - The 'stop' operation stops WAS. - The 'status' operation reports whether WAS is running - The 'monitor' operation reports whether the WAS seems to be working - (httpd also needs to be working for this case) - The 'methods' operation reports on the methods $0 supports - - This is known to work with the Single Server edition of Websphere, - and is believed to work with the Advanced edition too. - Since the Advanced Edition has no configuration file (it's in a the - database) you need to give a port number instead of a - configuration file for this config parameter. - - The start and stop operations must be run as root. - - The status operation will report a pid of "-" for the - WAS root process using unless it is run as root. - - If you don't have xmllint on your system, parsing of WAS - configuration files is very primitive. - In this case, the port specification we need from the XML - config file has to be on the same line as the - first part of the <transports/> tag. - - We run servlet/snoop on the first transport port listed in - the config file for the "monitor" operation. - - $Id: WAS.in,v 1.5 2005/11/03 07:45:51 xunsun Exp $ + usage: $0 [<WAS-(snoop)-port-number>] $LEGAL_ACTIONS ! exit 1 } -# -# methods: What methods/operations do we support? -# -WAS_methods() { - cat <<-! - start - stop - status - methods - ! - if - [ -f $WGET -a -x $WGET ] - then - echo monitor - fi -} - -# -# 'main' starts here... -# -config= -port= case $# in 1) op=$1;; 2) op=$2 if [ -f $1 ]; then - config=$1 + OCF_RESKEY_config=$1; export OCF_RESKEY_config else case $1 in *[^0-9]*) echo "ERROR: $1 is neither a WAS configuration file nor a valid port number!" usage;; *) + OCF_RESKEY_port=$1; export OCF_RESKEY_port port=$1;; esac fi;; @@ -113,13 +54,8 @@ usage;; esac -# What kind of method was invoked? -case "$op" in - start|stop|status|monitor) - ;; - methods) WAS_methods - exit $?;; - *) usage;; -esac +OCF_TYPE=WAS +OCF_RESOURCE_INSTANCE=${OCF_TYPE} +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=WAS" "rsc_type=WAS" "provider=heartbeat" $op "config=$config" "port=$port" +ra_execocf $op =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/WinPopup.in,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- WinPopup.in 29 Mar 2006 15:48:55 -0000 1.3 +++ WinPopup.in 14 Aug 2006 09:37:21 -0000 1.4 @@ -25,8 +25,7 @@ . @HB_RA_DIR@/hto-mapfuncs usage() { - echo "Usage: $0 [workstationfile] {start|stop|status}" - echo "$Id: WinPopup.in,v 1.3 2006/03/29 15:48:55 xunsun Exp $" + echo "Usage: $0 [workstationfile] $LEGAL_ACTIONS" exit 1 } @@ -46,16 +45,11 @@ hostfile="hosts" fi -case "$cmd" in - start|stop) - ;; - # Not quite sure what to do with this one... - status) - echo "status not implemented yet" - exit 0 - ;; - *) - usage -esac +OCF_RESKEY_hostfile=$hostfile +export OCF_RESKEY_hostfile -ra_execocf "rsc_id=WinPopup" "rsc_type=WinPopup" "provider=heartbeat" $cmd "hostfile=$hostfile" +OCF_TYPE=WinPopup +OCF_RESOURCE_INSTANCE=${OCF_TYPE} +export OCF_TYPE OCF_RESOURCE_INSTANCE + +ra_execocf $cmd =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/Xinetd.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- Xinetd.in 13 Nov 2005 17:16:43 -0000 1.5 +++ Xinetd.in 14 Aug 2006 09:37:21 -0000 1.6 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Xinetd.in,v 1.5 2005/11/13 17:16:43 davidlee Exp $ +# $Id: Xinetd.in,v 1.6 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA Xinetd, based on original heartbeat RA. # See OCF RA Xinetd for more information. @@ -14,32 +14,18 @@ # Source function library. . @HB_RA_DIR@/hto-mapfuncs [EMAIL PROTECTED]@ -RCFILE=$ETC/xinetd.d/$1 - xup_usage () { - echo "Usage: $0 <xinetd-service-name> {start|stop|restart|status}" + echo "Usage: $0 <xinetd-service-name> $LEGAL_ACTIONS" + exit 1 } if [ $# -ne 2 ]; then xup_usage - exit 1 fi -# Make sure the first parameter is a valid xinetd service name -if [ ! -f $RCFILE ]; then - echo "ERROR: Service descriptor $RCFILE not found!" - xup_usage - exit 1 -fi - -# See how we were called. -case "$2" in - start|stop|restart|status) - ;; - *) - xup_usage - exit 1 -esac +OCF_TYPE=Xinetd +OCF_RESOURCE_INSTANCE=${OCF_TYPE} +export OCF_TYPE OCF_RESOURCE_INSTANCE -ra_execocf "rsc_id=Xinetd" "rsc_type=Xinetd" "provider=heartbeat" $2 "service=$1" +OCF_RESKEY_service=$1; export OCF_RESKEY_service +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/apache.in,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- apache.in 3 Nov 2005 07:45:51 -0000 1.6 +++ apache.in 14 Aug 2006 09:37:21 -0000 1.7 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: apache.in,v 1.6 2005/11/03 07:45:51 xunsun Exp $ +# $Id: apache.in,v 1.7 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA apache, based on original heartbeat RA. See # OCF RA apache for more information. @@ -14,72 +14,26 @@ # node1 10.0.0.170 apache::/opt/IBMHTTPServer/conf/httpd.conf # node1 10.0.0.170 IBMhttpd # -unset LC_ALL; export LC_ALL -unset LANGUAGE; export LANGUAGE . @HB_RA_DIR@/hto-mapfuncs -WGETNAME=wget - usage() { - mstr=`methods_apache | tr '\012' '|' | sed 's%|$%%' ` - cat <<-! - usage: $0 [config-file-pathname] {$mstr} - - The optional [config-file-pathname] is the pathname to the configuration - file for this web server. Various appropriate defaults are assumed by - the apache OCF RA if no config file is specified, depending on how this - command is invoked. See apache OCF RA for more information. - - start start the web server - - stop stop the web server - - status return the status of the web server - - methods return the set of commands we support - - monitor return TRUE if the web server appears to be working - For this to be supported, you must configure mod_status - and give it a server-status URL. You have to have - installed $WGETNAME for this to work. The monitor operation - won't work if the web server is not configured properly;-) - - $Id: apache.in,v 1.6 2005/11/03 07:45:51 xunsun Exp $ - ! - exit 1 -} - -methods_apache() { - cat <<-! - start - stop - status - methods - ! - if which $WGETNAME > /dev/null 2>&1; then - echo "monitor" - fi + echo "usage: $0 [config-file-pathname] $LEGAL_ACTIONS" + exit 1 } case $# in 1) op=$1 - configfile= ;; - 2) configfile=$1 + 2) OCF_RESKEY_configfile=$1; export OCF_RESKEY_configfile op=$2 ;; *) usage ;; esac -case $op in - start|stop|status|monitor) - ;; - methods) - methods_apache - exit 0;; - *) - usage;; -esac -ra_execocf "rsc_id=apache" "rsc_type=apache" "provider=heartbeat" $op "configfile=$configfile" +OCF_TYPE=apache +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$OCF_RESKEY_configfile +export OCF_TYPE OCF_RESOURCE_INSTANCE + +ra_execocf $op =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/db2.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- db2.in 3 Nov 2005 07:45:51 -0000 1.5 +++ db2.in 14 Aug 2006 09:37:21 -0000 1.6 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: db2.in,v 1.5 2005/11/03 07:45:51 xunsun Exp $ +# $Id: db2.in,v 1.6 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA db2, based on original heartbeat RA. # See OCF RA db2 for more information. @@ -18,70 +18,18 @@ . @HB_RA_DIR@/hto-mapfuncs -unset LC_ALL; export LC_ALL -unset LANGUAGE; export LANGUAGE - usage() { - methods=`db2_methods` - methods=`echo $methods | tr ' ' '|'` - cat <<-! >&1 - usage: $0 db2-database-owner-id {$methods} - usage: $0 methods - - $0 manages a DB2 Universal Database instance as an HA resource. - - The 'start' operation starts the database. - The 'stop' operation stops the database. - The 'status' operation reports whether the database is running - The 'monitor' operation reports whether the database seems to be working - The 'methods' operation reports on the methods $0 supports - - $Id: db2.in,v 1.5 2005/11/03 07:45:51 xunsun Exp $ - ! - exit 1 + echo "usage: $0 db2-database-owner-id $LEGAL_ACTIONS" + exit 1 } -# -# methods: What methods/operations do we support? -# -db2_methods() { - cat <<-! - start - stop - status - monitor - methods - ! -} - -# -# 'main' starts here... -# - -case $# in - 1) if [ "methods" = "$1" ]; then - db2_methods - exit $? - fi;; - 2) ;; - *) usage;; -esac - -if [ "$2" = "methods" ]; then - db2_methods - exit $? +if [ $# != 2 ]; then + usage fi -US=`id -u -n` -US=`echo $US` -if [ $US != root -a $US != $1 ]; then - echo "ERROR: $0 must be run as root or $1" - exit 1 -fi +OCF_TYPE=db2 +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$1 +export OCF_TYPE OCF_RESOURCE_INSTANCE -# What kind of method was invoked? -case "$2" in - start|stop|status|monitor);; - *) usage;; -esac -ra_execocf "rsc_id=db2_$1" "rsc_type=db2" "provider=heartbeat" $2 "instance=$1" +OCF_RESKEY_instance=$1; export OCF_RESKEY_instance +ra_execocf $2 =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/hto-mapfuncs.in,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- hto-mapfuncs.in 11 Feb 2006 13:03:40 -0000 1.17 +++ hto-mapfuncs.in 14 Aug 2006 09:37:21 -0000 1.18 @@ -7,11 +7,14 @@ # #set -x -PARAMETER_SPLIT_SIGN="=" [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ +OCF_RA_VERSION_MAJOR=1 ; export OCF_RA_VERSION_MAJOR +OCF_RA_VERSION_MINOR=0 ; export OCF_RA_VERSION_MINOR +OCF_ROOT=$OCF_ROOT_DIR ; export OCF_ROOT + +LEGAL_ACTIONS="(start|stop|status|usage|meta-data)" log_and_print(){ ha_log "$*" @@ -22,162 +25,74 @@ # rsc_id=rsc1 rsc_type=IPaddr2 provide=heartbeat start ip=192.168.0.1 ..... # ra_execocf(){ - ra_ocfinit $* - shift 4 - ra_setenv $* - - ra_getpathname + if [ "x${1}" = "x" ]; then + log_and_print "ERROR: No action specfied." + usage + exit 1 + fi + + . @hb_libdir@/ocf-shellfuncs + + __ACTION=$1 + __SCRIPT_NAME="${OCF_RA_DIR}/heartbeat/${OCF_TYPE}" + + if [ "x${OCF_TYPE}" = "x" ]; then + log_and_print "ERROR: Internal error. No value for OCF_TYPE specified" + exit 1 + fi + + if [ ! -x $__SCRIPT_NAME ] + then + log_and_print "ERROR: $__SCRIPT_NAME is not an executable file " + exit 1 + fi + + # execute ocf ra and get return value + case $__ACTION in + start) $__SCRIPT_NAME start;; + stop) $__SCRIPT_NAME stop ;; + monitor) $__SCRIPT_NAME monitor;; + status) $__SCRIPT_NAME monitor;; - if [ ! -x $RAOCFPATH ] - then - log_and_print "ERR $RAOCFPATH is not an executable file " - exit 1 - - fi - - # execute ocf ra and get return value - case $OPERATION in - start) $RAOCFPATH start;; - stop) $RAOCFPATH stop ;; - monitor) $RAOCFPATH monitor;; - status) $RAOCFPATH status;; - usage|help) usage;; - *) log_and_print "ERROR: Unknown operation: $OPERATION" + *) log_and_print "ERROR: Unknown operation: $__ACTION" usage exit 1;; - esac - - ocf_return_status=$? - case $ocf_return_status in + esac + + ocf_return_status=$? + case $ocf_return_status in $OCF_SUCCESS) - case $OPERATION in - monitor|status) log_and_print "INFO: $rsc_type Running OK";; - *) log_and_print "INFO: $rsc_type Success";; - esac - ;; + case $__ACTION in + monitor|status) log_and_print "INFO: $rsc_type Running OK";; + *) log_and_print "INFO: $rsc_type Success";; + esac;; $OCF_ERR_GENERIC) - log_and_print "ERROR: $rsc_type Generic error" - ;; + log_and_print "ERROR: $rsc_type Generic error";; $OCF_ERR_ARGS) - log_and_print "ERROR: $rsc_type Incompliant argument" - ;; + log_and_print "ERROR: $rsc_type Incompliant argument";; + $OCF_ERR_UNIMPLEMENTED) - log_and_print "ERROR: $rsc_type Function unimplemented" - ;; + log_and_print "ERROR: $rsc_type Function unimplemented";; + $OCF_ERR_PERM) - log_and_print "ERROR: $rsc_type User had insufficient privilege" - ;; + log_and_print "ERROR: $rsc_type User had insufficient privilege";; + $OCF_ERR_INSTALLED) - log_and_print "ERROR: $rsc_type Program is not installed" - ;; + log_and_print "ERROR: $rsc_type Program is not installed";; + $OCF_ERR_CONFIGURED) - log_and_print "ERROR: $rsc_type Program is not configured" - ;; + log_and_print "ERROR: $rsc_type Program is not configured";; + $OCF_NOT_RUNNING) - log_and_print "INFO: $rsc_type Resource is stopped" - ;; + log_and_print "INFO: $rsc_type Resource is stopped";; *) - echo $? - log_and_print "ERROR: $rsc_type Unknown error" + log_and_print "ERROR: $rsc_type Unknown error: $ocf_return_status" exit 1 ;; esac return $ocf_return_status } - -ra_ocfinit(){ - - RSCIDPAIR=$1 - RSCTYPEPAIR=$2 - - RSCTYPE=`echo "$RSCTYPEPAIR" | cut -d${PARAMETER_SPLIT_SIGN} -f2` - PROVIDERPAIR=$3 - PROVIDER=`echo "$PROVIDERPAIR" | cut -d${PARAMETER_SPLIT_SIGN} -f2` - OPERATION=$4 - - - setup_OCF_env_vars $RSCIDPAIR - setup_OCF_env_vars $RSCTYPEPAIR - setup_OCF_env_vars $PROVIDERPAIR - - OCF_RA_VERSION_MAJOR=1 ; export OCF_RA_VERSION_MAJOR - OCF_RA_VERSION_MINOR=0 ; export OCF_RA_VERSION_MINOR - OCF_ROOT=$OCF_ROOT_DIR ; export OCF_ROOT - - . @hb_libdir@/ocf-shellfuncs -} - -ra_getpathname(){ - BASENAME=`basename $RSCTYPE` - if [ $BASENAME = $RSCTYPE ] - then - RAOCFPATH="${OCF_RA_DIR}${PROVIDER}/${BASENAME}" - else - RAOCFPATH="${RSCTYPE}" - fi -} - -ra_setenv(){ - - lastenvar= - for envar in $* - do - ifvarname=`echo $envar | cut -s -d${PARAMETER_SPLIT_SIGN} -f1` - if [ -z $ifvarname ]; then - envar="$lastenvar $envar" - setup_OCF_prefix $envar - else - setup_OCF_prefix $envar - fi - lastenvar=$envar - done -} - -setup_OCF_prefix(){ - - hbvarname=`echo "$envar" | cut -d${PARAMETER_SPLIT_SIGN} -f1` - hbvarvalue=`echo "$envar" | cut -d${PARAMETER_SPLIT_SIGN} -f2-` - ocfvarname="OCF_RESKEY_${hbvarname}" - - eval $ocfvarname='$hbvarvalue' - export $ocfvarname -} - -setup_OCF_env_vars(){ - hbvarname=`echo "$1" | cut -d${PARAMETER_SPLIT_SIGN} -f1` - hbvarvalue=`echo "$1" | cut -d${PARAMETER_SPLIT_SIGN} -f2` - - case $hbvarname in - rsc_id) - if [ ! -z "$hbvarvalue" ] - then - ocfvarname="OCF_RESOURCE_INSTANCE" - eval $ocfvarname=$hbvarvalue - export $ocfvarname - fi - ;; - rsc_type) - if [ ! -z "hbvarvalue" ] - then - rsc_type=$hbvarvalue - ocfvarname="OCF_RESOURCE_TYPE" - eval $ocfvarname=$hbvarvalue - export $ocfvarname - fi - ;; - provider) - if [ ! -z "hbvarvalue" ] - then - ocfvarname="OCF_RESOURCE_PROVIDER" - eval $ocfvarname=$hbvarvalue - export $ocfvarname - fi - ;; - *) - ;; - esac -} =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/heartbeat/portblock.in,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- portblock.in 3 Nov 2005 07:45:51 -0000 1.4 +++ portblock.in 14 Aug 2006 09:37:21 -0000 1.5 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: portblock.in,v 1.4 2005/11/03 07:45:51 xunsun Exp $ +# $Id: portblock.in,v 1.5 2006/08/14 09:37:21 andrew Exp $ # # Description: wrapper of OCF RA portblock, based on original heartbeat RA. # See OCF RA portblock for more information. @@ -12,47 +12,23 @@ # . @HB_RA_DIR@/hto-mapfuncs -CMD=`basename $0` usage() { - cat <<-!USAGE >&2 - usage: $CMD {udp|tcp} portno,portno {block|unblock} {start|stop|status} - - $CMD is used to temporarily block ports using iptables. - - It can be used to turn off a port before bringing - up an IP address, and enable it after a service is started. - To do that for samba, the following resource line can be used: - - $CMD::tcp::137,138::block \\ - 10.10.10.20 \\ - nmbd smbd \\ - $CMD::tcp::137,138::unblock - - This will do the follwing things: - - - DROP all incoming packets for TCP ports 137 and 138 - - Bring up the IP alias 10.10.10.20 - - start the nmbd and smbd services - - Re-enable TCP ports 137 and 138 - (enable normal firewall rules on those ports) - - This prevents clients from getting ICMP port unreachable - if they try to reconnect to the service after the alias is - enabled but before nmbd and smbd are running. These packets - will cause some clients to give up attempting to reconnect to - the server. - - NOTE: iptables is linux-specific... - - !USAGE - exit 1 + echo "usage: $0 {udp|tcp} portno,portno {block|unblock} $LEGAL_ACTIONS" + exit 1 } -case $4 in - start|stop|status) - ;; - *) - usage;; -esac -ra_execocf "rsc_id=portblock_${1}_$2" "rsc_type=portblock" "provider=heartbeat" $4 "protocol=$1" "portno=$2" "action=$3" +if [ $# != 3 ]; then + usage +fi + +OCF_RESKEY_protocol=$1 +OCF_RESKEY_portno=$2 +OCF_RESKEY_action=$3 +export OCF_RESKEY_action OCF_RESKEY_portno OCF_RESKEY_action + +OCF_TYPE=portblock +OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$1_$2 +export OCF_TYPE OCF_RESOURCE_INSTANCE + +ra_execocf $4 ------------------------------ _______________________________________________ Linux-ha-cvs mailing list Linux-ha-cvs@lists.linux-ha.org http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs End of Linux-ha-cvs Digest, Vol 33, Issue 25 ********************************************