diff options
author | Martin Schwenke <martin@meltin.net> | 2012-07-17 15:39:50 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2012-07-26 21:14:58 +1000 |
commit | 05359689f68221933976aff8b6839c09b5130382 (patch) | |
tree | 600f3dbc8b9ca893232b9c3f511bcd3b150f383c | |
parent | e7325ebcd562f10024e9ce777b37daa3836ffe8c (diff) | |
download | samba-05359689f68221933976aff8b6839c09b5130382.tar.gz samba-05359689f68221933976aff8b6839c09b5130382.tar.xz samba-05359689f68221933976aff8b6839c09b5130382.zip |
Eventscripts: Retrieve and build NAT gateway details better in 11.natgw
* "ctdb natgw" is run twice when it doesn't need to be.
* Tweak the parsing of "ctdb natgw" output so that it is done by the
shell instead of a bunch of external processes.
* Make default NAT gateway be -1, even on error. If the process
failed entirely then it could previously be empty.
* Streamline the error handling using die() for when there is no NAT
gateway.
* Downcase script-local variable names.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 630cfe6451ba23d959fa4907fbba42702337ed3b)
-rwxr-xr-x | ctdb/config/events.d/11.natgw | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/ctdb/config/events.d/11.natgw b/ctdb/config/events.d/11.natgw index 8537a8cc0a..dae16dba6d 100755 --- a/ctdb/config/events.d/11.natgw +++ b/ctdb/config/events.d/11.natgw @@ -45,18 +45,17 @@ case "$1" in ;; recovered|updatenatgw|ipreallocated) - MYPNN=`ctdb pnn | cut -d: -f2` - NATGWMASTER=`ctdb natgwlist | head -1 | sed -e "s/ .*//"` - NATGWIP=`ctdb natgwlist | head -1 | sed -e "s/^[^ ]* *//"` + mypnn=$(ctdb pnn | cut -d: -f2) - if [ "$NATGWMASTER" = "-1" ]; then - echo "There is no NATGW master node" - exit 1 - fi + set -- $(ctdb natgwlist) + natgwmaster="${1:--1}" # Default is -1 if natgwlist fails + natgwip="$2" + + [ "$natgwmaster" = "-1" ] && die "There is no NATGW master node" delete_all - if [ "$MYPNN" = "$NATGWMASTER" ]; then + if [ "$mypnn" = "$natgwmaster" ]; then # This is the first node, set it up as the NAT GW echo 1 >/proc/sys/net/ipv4/ip_forward iptables -A POSTROUTING -t nat -s $CTDB_NATGW_PRIVATE_NETWORK ! -d $CTDB_NATGW_PRIVATE_NETWORK -j MASQUERADE @@ -75,7 +74,7 @@ case "$1" in # We do this so that the ip address will exist on a # non-loopback interface so that samba may send it along in the # KDC requests. - ip route add 0.0.0.0/0 via $NATGWIP metric 10 + ip route add 0.0.0.0/0 via $natgwip metric 10 # Make sure winbindd does not stay bound to this address # if we are no longer natgwmaster smbcontrol winbindd ip-dropped $CTDB_NATGW_PUBLIC_IP >/dev/null 2>/dev/null |