summaryrefslogtreecommitdiff
path: root/scripts/etc-IPaddr2-vyatta
blob: 77d89d00a921b7c5a6bdb80476b5c79f4f23da4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
#
#
# Description:	wrapper of OCF RA IPaddr2, based on original heartbeat RA.
#		See OCF RA IPaddr2 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
#
#	This script manages IP alias IP addresses
#
#	It can add an IP alias, or remove one.
#
#	usage: $0 ip-address[/netmaskbits[/interface[:label][/broadcast]]] \
#	    {start|stop|status|monitor}
#
#	The "start" arg adds an IP alias.
#
#	Surprisingly, the "stop" arg removes one.	:-)
#
unset LANG; export LANG
LC_ALL=C
export LC_ALL

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

# 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 "usage: $0 ip-address[/netmaskbits[/interface[:label][/broadcast]]] $LEGAL_ACTIONS"
}

if [ $# != 2 ]; then
    usage
    exit 1
fi

BASEIP=`echo $1 | sed 's%/.*%%'`
OCF_RESKEY_ip=$BASEIP; export OCF_RESKEY_ip

str=`echo $1 | sed 's%^'$BASEIP'/*%%'`
if [ ! -z "$str" ]; then
    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

OCF_TYPE=IPaddr2-vyatta
OCF_RESKEY_lvs_support=1
OCF_RESOURCE_INSTANCE=${OCF_TYPE}_$BASEIP
export OCF_TYPE OCF_RESOURCE_INSTANCE OCF_RESKEY_lvs_support

ra_execocf $2