[SCM] CTDB repository - branch master updated - ctdb-1.0.113-122-g00b249d

Ronnie Sahlberg sahlberg at samba.org
Tue Feb 23 02:47:43 MST 2010


The branch, master has been updated
       via  00b249d9d098d5ed03e21caed404e66336f63629 (commit)
       via  b151a5bf750ffde4845d19a6ef875b4ee6085426 (commit)
       via  c72b637cc838ae6ea1694a476628c3fb4770f63b (commit)
       via  283338275c1e02811ce5062b24cc0da2288f64cc (commit)
       via  5ac32d3152ba11bacfab47c72ba998ac495fac00 (commit)
       via  51a455940464accece218b1a018be444993b3b4b (commit)
       via  4b06665b77cb24d488f4ef03cc9ad5fd5d0feb0e (commit)
       via  3ee225b0b6ed37c22478bd145ced56b1b9b86842 (commit)
       via  ea87185ec9977006ef72d5a68c875154e4c84099 (commit)
       via  624e8878851b4957cc7c02e922ec86926d6927ee (commit)
       via  1493436b6b24eb05a23b7a339071ad85f70de8f4 (commit)
       via  e2bc5c25116747c58505fe1cb3e2d164257377d1 (commit)
       via  2c2cbed4fcbc868a990fa6b32fc96126ffc61bb5 (commit)
       via  e66d6636b80e3614f183366ec92fc3c6d5c323da (commit)
       via  756c8b953fef7132dae74b5b244baeb3108dec54 (commit)
       via  ac97d65f44e8dc8bf2ec8f68e4db3448521755a2 (commit)
       via  e7a6f64cf5bce5abdc47f5db96b286c5a8d66aff (commit)
      from  259054c3632e42bbaa614ee7e888e6e850733d60 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 00b249d9d098d5ed03e21caed404e66336f63629
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 23 10:29:27 2010 +0100

    doc: regenerate ctdb.1*
    
    metze

commit b151a5bf750ffde4845d19a6ef875b4ee6085426
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 23 10:36:46 2010 +0100

    doc/ctdb.1.xml: document "ctdb setifacelink <iface> <status>"
    
    metze

commit c72b637cc838ae6ea1694a476628c3fb4770f63b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 23 10:04:51 2010 +0100

    doc/ctdb.1.xml: document "ctdb ipinfo <ip>"
    
    metze

commit 283338275c1e02811ce5062b24cc0da2288f64cc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 23 10:03:00 2010 +0100

    doc/ctdb.1.xml: update "ctdb ip" documentation
    
    metze

commit 5ac32d3152ba11bacfab47c72ba998ac495fac00
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 23 10:01:50 2010 +0100

    doc/ctdb.1.xml: document "ctdb ifaces"
    
    metze

commit 51a455940464accece218b1a018be444993b3b4b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 23 08:35:08 2010 +0100

    doc/ctdb.1.xml: document PARTIALLYONLINE status
    
    metze

commit 4b06665b77cb24d488f4ef03cc9ad5fd5d0feb0e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 09:54:46 2010 +0100

    config/13.per_ip_routing: fix typo in error message
    
    metze

commit 3ee225b0b6ed37c22478bd145ced56b1b9b86842
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 14:06:40 2010 +0100

    config/13.per_ip_routing: use better names for release_script and setup_script
    
    As the basename of the script will be used for the readd script
    from setup_iface_ip_readd_script, it's know easier to identify
    what script is called by delete_ip_from_iface() while readding
    ips to the interface.
    
    metze

commit ea87185ec9977006ef72d5a68c875154e4c84099
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 09:52:09 2010 +0100

    config/13.per_ip_routing: register the setup script with setup_iface_ip_readd_script()
    
    This is needed because we need to resetup the routing table when
    the delete_ip_from_iface() function readds the ip to the interface.
    
    metze

commit 624e8878851b4957cc7c02e922ec86926d6927ee
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 9 16:34:59 2010 +0100

    config/13.per_ip_routing: add a setup_per_ip_routing() function
    
    This combines the logic into a shell function which can be used by the
    "takeip" and "updateip" hooks.
    
    We check the return values of the "ip" commands now
    instead of ignoring them.
    
    We now create a setup_script.sh similar to the release_script.sh
    which makes it easier to analyze problems.
    
    metze

commit 1493436b6b24eb05a23b7a339071ad85f70de8f4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 11:24:08 2010 +0100

    server: add "setup" event
    
    This is needed because the "init" event can't use 'ctdb' commands.
    
    metze

commit e2bc5c25116747c58505fe1cb3e2d164257377d1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 11:25:26 2010 +0100

    config/10.interface: use delete_ip_from_iface also in the "init" event
    
    metze

commit 2c2cbed4fcbc868a990fa6b32fc96126ffc61bb5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 10:33:54 2010 +0100

    config/11.natgw: use delete_ip_from_iface() instead of remove_ip()
    
    This also initializes the variables correctly for the
    shutdown|removenatgw code path to delete_all.
    
    metze

commit e66d6636b80e3614f183366ec92fc3c6d5c323da
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 10:24:44 2010 +0100

    config: make remove_ip() a wrapper of delete_ip_from_iface()
    
    metze

commit 756c8b953fef7132dae74b5b244baeb3108dec54
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 10:23:17 2010 +0100

    config: interface_modify states in a $CTDB_BASE/state/interface_modify directory
    
    metze

commit ac97d65f44e8dc8bf2ec8f68e4db3448521755a2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 09:48:01 2010 +0100

    config: add setup_iface_ip_readd_script() helper function
    
    This adds a generic infrastructure to register scripts which will
    be called when the delete_ip_from_iface() funtion needs to readd
    secondary ips to an interface.
    
    metze

commit e7a6f64cf5bce5abdc47f5db96b286c5a8d66aff
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Feb 12 09:55:28 2010 +0100

    config: readd ips with a broadcast address in delete_ip_from_iface()
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 common/ctdb_util.c                |    1 +
 config/events.d/00.ctdb           |    8 +-
 config/events.d/10.interface      |    2 +-
 config/events.d/11.natgw          |    7 +-
 config/events.d/13.per_ip_routing |  120 +++++---
 config/events.d/README            |    9 +
 config/functions                  |   74 ++++--
 config/interface_modify.sh        |   72 +++++-
 config/notify.sh                  |    5 +-
 doc/ctdb.1                        |  599 ++++++++++++++++++++++++-------------
 doc/ctdb.1.html                   |  221 +++++++++-----
 doc/ctdb.1.xml                    |  101 ++++++-
 include/ctdb.h                    |    1 +
 server/ctdb_daemon.c              |   34 ++-
 server/eventscript.c              |    2 +
 tests/events.d/00.test            |    4 +
 16 files changed, 884 insertions(+), 376 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index 7fa5743..63abc02 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -660,6 +660,7 @@ void ctdb_lockdown_memory(struct ctdb_context *ctdb)
 
 const char *ctdb_eventscript_call_names[] = {
 	"init",
+	"setup",
 	"startup",
 	"startrecovery",
 	"recovered",
diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb
index 03310b7..5255617 100755
--- a/config/events.d/00.ctdb
+++ b/config/events.d/00.ctdb
@@ -16,8 +16,14 @@ case "$1" in
      init)
         # make sure we have a blank state directory for the scripts to work with
 	/bin/rm -rf $CTDB_BASE/state
-	/bin/mkdir -p $CTDB_BASE/state
+	/bin/mkdir -p $CTDB_BASE/state || {
+	    ret=$?
+	    echo "/bin/mkdir -p $CTDB_BASE/state - failed - $ret"
+	    exit $ret
+	}
+	;;
 
+     setup)
 	# set any tunables from the config file
 	set | grep ^CTDB_SET_ | cut -d_ -f3- | 
 	while read v; do
diff --git a/config/events.d/10.interface b/config/events.d/10.interface
index 9365106..d7abc18 100755
--- a/config/events.d/10.interface
+++ b/config/events.d/10.interface
@@ -136,7 +136,7 @@ case "$1" in
 			_IFACE=`echo $_IP_HELD | sed -e "s/.*\s//"`
 			_NM=`echo $_IP_HELD | sed -e "s/.*$_IP\///" -e "s/\s.*//"`
 			echo "Removing public address $_IP/$_NM from device $_IFACE"
-			/sbin/ip addr del $_IP/$_NM dev $_IFACE
+			delete_ip_from_iface $_IFACE $_IP $_NM
 		}
 	done
 	;;
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
index ce1becc..18db3de 100644
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -11,8 +11,11 @@ loadconfig
 [ -z "$CTDB_NATGW_PUBLIC_IFACE" ] && exit 0
 
 delete_all() {
-	remove_ip $CTDB_NATGW_PUBLIC_IP $CTDB_NATGW_PUBLIC_IFACE
-	remove_ip $CTDB_NATGW_PUBLIC_IP_HOST lo
+	local _ip=`echo $CTDB_NATGW_PUBLIC_IP | cut -d '/' -f1`
+	local _maskbits=`echo $CTDB_NATGW_PUBLIC_IP | cut -d '/' -f2`
+
+	delete_ip_from_iface $CTDB_NATGW_PUBLIC_IFACE $_ip $_maskbits
+	delete_ip_from_iface lo $_ip 32
 
 	ip route del 0.0.0.0/0 metric 10 >/dev/null 2>/dev/null
 
diff --git a/config/events.d/13.per_ip_routing b/config/events.d/13.per_ip_routing
index a9fe6cf..b8a1e3e 100755
--- a/config/events.d/13.per_ip_routing
+++ b/config/events.d/13.per_ip_routing
@@ -206,7 +206,8 @@ generate_per_ip_routing()
 	local _ipdir="$CTDB_PER_IP_ROUTING_STATE/ips/$_ip"
 
 	table_id=""
-	release_script="$_ipdir/release_script.sh"
+	release_script="$_ipdir/per_ip_routing_release.sh"
+	setup_script="$_ipdir/per_ip_routing_setup.sh"
 
 	test x"$_readonly" = x"yes" && {
 		test -d $_ipdir || {
@@ -227,12 +228,65 @@ generate_per_ip_routing()
 		generate_auto_link_local $_ip $_maskbits
 	}
 
-	release_script="$_ipdir/release_script.sh"
 	run_release_script_once $release_script
 
+	echo -e "#!/bin/sh\n#\n" > $setup_script
+	chmod +x $setup_script
+
 	return 0;
 }
 
+setup_per_ip_routing()
+{
+	local _ip=$1
+	local _iface=$2
+	local _table_id=$3
+	local _release_script=$4
+	local _setup_script=$5
+
+	local _config=`cat $CTDB_PER_IP_ROUTING_CONF`
+	local _lines=`echo -n "$_config" | grep -n "^$_ip " | cut -d ':' -f1 | xargs`
+
+	local _pref="$CTDB_PER_IP_ROUTING_RULE_PREF"
+
+	test -n "$_lines" && {
+		echo "ip rule del from $_ip pref $_pref table $_table_id" >> $_release_script
+		echo "ip route flush table $_table_id 2>/dev/null" >> $_release_script
+
+		cmd="ip rule del from $_ip pref $_pref 2>/dev/null"
+		echo "$cmd" >> $_setup_script
+
+		cmd="ip route flush table $_table_id 2>/dev/null"
+		echo "$cmd" >> $_setup_script
+
+		cmd="ip rule add from $_ip pref $_pref table $_table_id"
+		echo "$cmd || {" >> $_setup_script
+		echo "    echo \"$cmd - failed \$ret\"" >> $_setup_script
+		echo "    exit \$ret" >> $_setup_script
+		echo "}" >> $_setup_script
+	}
+	local _l
+	for _l in $_lines; do
+		local _line=`echo -n "$_config" | head -n $_l | tail -n 1`
+		local _dest=`echo -n "$_line" | cut -d ' ' -f 2`
+		local _gw=`echo -n "$_line" | cut -d ' ' -f 3`
+
+		local _via=""
+		test -n "$_gw" && {
+			_via="via $_gw"
+		}
+
+		cmd="ip route add $_dest $_via dev $_iface table $_table_id"
+		echo "$cmd || {" >> $_setup_script
+		echo "    echo \"$cmd - failed \$ret\"" >> $_setup_script
+		echo "    exit \$ret" >> $_setup_script
+		echo "}" >> $_setup_script
+	done
+
+	$_setup_script
+	return $?;
+}
+
 case "$1" in
      #############################
      # called when ctdbd starts up
@@ -265,7 +319,7 @@ case "$1" in
 
      shutdown)
 
-	for s in $CTDB_PER_IP_ROUTING_STATE/ips/*/release_script.sh; do
+	for s in $CTDB_PER_IP_ROUTING_STATE/ips/*/per_ip_routing_release.sh; do
 		run_release_script_once "$s"
 	done
 	rm -rf $CTDB_PER_IP_ROUTING_STATE
@@ -298,31 +352,15 @@ case "$1" in
 		exit 1;
 	}
 
-	config=`cat $CTDB_PER_IP_ROUTING_CONF`
-	lines=`echo -n "$config" | grep -n "^$ip " | cut -d ':' -f1 | xargs`
-
-	pref="$CTDB_PER_IP_ROUTING_RULE_PREF"
-
-	test -n "$lines" && {
-		echo "ip rule del from $ip pref $pref table $table_id" >> $release_script
-		echo "ip route flush table $table_id 2>/dev/null" >> $release_script
-
-		ip rule del from $ip pref $pref 2>/dev/null
-		ip rule add from $ip pref $pref table $table_id
-		ip route flush table $table_id 2>/dev/null
+	setup_per_ip_routing $ip $iface $table_id $release_script $setup_script || {
+		echo "$0: $1: setup_per_ip_routing $ip $iface $table_id $release_script $setup_script - failed"
+		exit 1;
 	}
-	for l in $lines; do
-		line=`echo -n "$config" | head -n $l | tail -n 1`
-		dest=`echo -n "$line" | cut -d ' ' -f 2`
-		gw=`echo -n "$line" | cut -d ' ' -f 3`
-
-		via=""
-		test -n "$gw" && {
-			via="via $gw"
-		}
 
-		ip route add $dest $via dev $iface table $table_id
-	done
+	setup_iface_ip_readd_script $iface $ip $maskbits $setup_script || {
+		echo "$0: $1: setup_iface_ip_readd_script $iface $ip $maskbits $setup_script - failed"
+		exit 1;
+	}
 
 	# flush our route cache
 	echo 1 > /proc/sys/net/ipv4/route/flush
@@ -357,31 +395,15 @@ case "$1" in
 		exit 1;
 	}
 
-	config=`cat $CTDB_PER_IP_ROUTING_CONF`
-	lines=`echo -n "$config" | grep -n "^$ip " | cut -d ':' -f1 | xargs`
-
-	pref="$CTDB_PER_IP_ROUTING_RULE_PREF"
-
-	test -n "$lines" && {
-		echo "ip rule del from $ip pref $pref table $table_id" >> $release_script
-		echo "ip route flush table $table_id 2>/dev/null" >> $release_script
-
-		ip rule del from $ip pref $pref 2>/dev/null
-		ip rule add from $ip pref $pref table $table_id
-		ip route flush table $table_id 2>/dev/null
+	setup_per_ip_routing $ip $niface $table_id $release_script $setup_script || {
+		echo "$0: $1: setup_per_ip_routing $ip $niface $table_id $release_script $setup_script - failed"
+		exit 1;
 	}
-	for l in $lines; do
-		line=`echo -n "$config" | head -n $l | tail -n 1`
-		dest=`echo -n "$line" | cut -d ' ' -f 2`
-		gw=`echo -n "$line" | cut -d ' ' -f 3`
-
-		via=""
-		test -n "$gw" && {
-			via="via $gw"
-		}
 
-		ip route add $dest $via dev $niface table $table_id
-	done
+	setup_iface_ip_readd_script $niface $ip $maskbits $setup_script || {
+		echo "$0: $1: setup_iface_ip_readd_script $niface $ip $maskbits $setup_script - failed"
+		exit 1;
+	}
 
 	# flush our route cache
 	echo 1 > /proc/sys/net/ipv4/route/flush
diff --git a/config/events.d/README b/config/events.d/README
index f7b476c..ef345b5 100644
--- a/config/events.d/README
+++ b/config/events.d/README
@@ -27,6 +27,15 @@ init
 	This event is only invoked once, when ctdb is starting up.
 	This event is used to do some cleanup work from earlier runs
 	and prepare the basic setup.
+	At this stage 'ctdb' commands won't work.
+
+	Example: 00.ctdb cleans up $CTDB_BASE/state
+
+setup
+	This event does not take any additional arguments.
+	This event is only invoked once, when ctdb is starting up.
+	This event is used to do some cleanup work from earlier runs
+	and prepare the basic setup.
 
 	Example: 00.ctdb cleans up $CTDB_BASE/state
 
diff --git a/config/functions b/config/functions
index 531f859..b70a352 100644
--- a/config/functions
+++ b/config/functions
@@ -421,25 +421,15 @@ startstop_nfslock() {
 }
 
 # better use delete_ip_from_iface() together with add_ip_to_iface
+# remove_ip should be removed in future
 remove_ip() {
-	# the ip tool will delete all secondary IPs if this is the primary.
-	# To work around this _very_ annoying behaviour we have to keep a
-	# record of the secondaries and re-add them afterwards. yuck
-	secondaries=""
-	if ip addr list dev $2 primary | grep -q "inet $1 " ; then
-	    secondaries=`ip addr list dev $2 secondary | grep " inet " | awk '{print $2}'`
-	fi
-	ip addr del $1 dev $2 >/dev/null 2>/dev/null || failed=1
-	[ -z "$secondaries" ] || {
-	    for i in $secondaries; do
-		if ip addr list dev $2 | grep -q "inet $i" ; then
-		    echo "kept secondary $i on dev $2"
-		else 
-		    echo "re-adding secondary address $i to dev $2"
-		    ip addr add $i dev $2 || failed=1		
-		fi
-	    done
-	}
+	local _ip_maskbits=$1
+	local _iface=$2
+	local _ip=`echo "$_ip_maskbits" | cut -d '/' -f1`
+	local _maskbits=`echo "$_ip_maskbits" | cut -d '/' -f2`
+
+	delete_ip_from_iface "$_iface" "$_ip" "$_maskbits"
+	return $?
 }
 
 add_ip_to_iface()
@@ -447,13 +437,21 @@ add_ip_to_iface()
 	local _iface=$1
 	local _ip=$2
 	local _maskbits=$3
-	local _lockfile="$CTDB_BASE/state/interface_modify.$_iface.flock"
+	local _state_dir="$CTDB_BASE/state/interface_modify"
+	local _lockfile="$_state_dir/$_iface.flock"
+	local _readd_base="$_state_dir/$_iface.readd.d"
+
+	mkdir -p $_state_dir || {
+		ret=$?
+		echo "Failed to mkdir -p $_state_dir - $ret"
+		return $ret
+	}
 
 	test -f $_lockfile || {
 		touch $_lockfile
 	}
 
-	flock --timeout 30 $_lockfile $CTDB_BASE/interface_modify.sh add "$_iface" "$_ip" "$_maskbits"
+	flock --timeout 30 $_lockfile $CTDB_BASE/interface_modify.sh add "$_iface" "$_ip" "$_maskbits" "$_readd_base"
 	return $?
 }
 
@@ -462,13 +460,45 @@ delete_ip_from_iface()
 	local _iface=$1
 	local _ip=$2
 	local _maskbits=$3
-	local _lockfile="$CTDB_BASE/state/interface_modify.$_iface.flock"
+	local _state_dir="$CTDB_BASE/state/interface_modify"
+	local _lockfile="$_state_dir/$_iface.flock"
+	local _readd_base="$_state_dir/$_iface.readd.d"
+
+	mkdir -p $_state_dir || {
+		ret=$?
+		echo "Failed to mkdir -p $_state_dir - $ret"
+		return $ret
+	}
+
+	test -f $_lockfile || {
+		touch $_lockfile
+	}
+
+	flock --timeout 30 $_lockfile $CTDB_BASE/interface_modify.sh delete "$_iface" "$_ip" "$_maskbits" "$_readd_base"
+	return $?
+}
+
+setup_iface_ip_readd_script()
+{
+	local _iface=$1
+	local _ip=$2
+	local _maskbits=$3
+	local _readd_script=$4
+	local _state_dir="$CTDB_BASE/state/interface_modify"
+	local _lockfile="$_state_dir/$_iface.flock"
+	local _readd_base="$_state_dir/$_iface.readd.d"
+
+	mkdir -p $_state_dir || {
+		ret=$?
+		echo "Failed to mkdir -p $_state_dir - $ret"
+		return $ret
+	}
 
 	test -f $_lockfile || {
 		touch $_lockfile
 	}
 
-	flock --timeout 30 $_lockfile $CTDB_BASE/interface_modify.sh delete "$_iface" "$_ip" "$_maskbits"
+	flock --timeout 30 $_lockfile $CTDB_BASE/interface_modify.sh readd_script "$_iface" "$_ip" "$_maskbits" "$_readd_base" "$_readd_script"
 	return $?
 }
 
diff --git a/config/interface_modify.sh b/config/interface_modify.sh
index 3ac7fe8..738530b 100755
--- a/config/interface_modify.sh
+++ b/config/interface_modify.sh
@@ -5,12 +5,16 @@ OP=$1
 IFACE=$2
 IP=$3
 MASKBITS=$4
+READD_BASE=$5
+READD_SCRIPT=$6
 
 add_ip_to_iface()
 {
 	local _iface=$1
 	local _ip=$2
 	local _maskbits=$3
+	local _readd_base=$4
+	local _script_dir="$_readd_base/$_ip.$_maskbits"
 
 	# we make sure the interface is up first
 	/sbin/ip link set $_iface up || {
@@ -22,6 +26,13 @@ add_ip_to_iface()
 		return 1;
 	}
 
+	mkdir -p $_script_dir || {
+		echo "Failed to mkdir -p $_script_dir"
+		return 1;
+	}
+
+	rm -f $_script_dir/*
+
 	return 0;
 }
 
@@ -30,6 +41,8 @@ delete_ip_from_iface()
 	local _iface=$1
 	local _ip=$2
 	local _maskbits=$3
+	local _readd_base=$4
+	local _script_dir="$_readd_base/$_ip.$_maskbits"
 
 	# the ip tool will delete all secondary IPs if this is the primary. To work around
 	# this _very_ annoying behaviour we have to keep a record of the secondaries and re-add
@@ -47,10 +60,29 @@ delete_ip_from_iface()
 		    echo "kept secondary $_i on dev $_iface"
 		else
 		    echo "re-adding secondary address $_i to dev $_iface"
-		    /sbin/ip addr add $_i dev $_iface || _failed=1
+		    /sbin/ip addr add $_i brd + dev $_iface || _failed=1
 		fi
+		local _s_ip=`echo "$_i" | cut -d '/' -f1`
+		local _s_maskbits=`echo "$_i" | cut -d '/' -f2`
+		local _s_script_dir="$_readd_base/$_s_ip.$_s_maskbits"
+
+		local _s_script=""
+		for _s_script in $_s_script_dir/*; do
+			$_s_script "$_iface" "$_s_ip" "$_s_maskbits" || {
+				ret=$?
+				echo "$_s_script '$_iface' '$_s_ip' '$_s_maskbits' - failed - $ret"
+				_failed=1
+			}
+			echo "call $_s_script '$_iface' '$_s_ip' '$_s_maskbits'"
+		done
+
 	    done
 	}
+
+	test -d $_script_dir && {
+		rm -f $_script_dir/*
+	}
+
 	[ $_failed = 0 ] || {
 		echo "Failed to del $_ip on dev $_iface"
 		return 1;
@@ -58,13 +90,47 @@ delete_ip_from_iface()
 	return 0;
 }
 
+setup_iface_ip_readd_script()
+{
+	local _iface=$1
+	local _ip=$2
+	local _maskbits=$3
+	local _readd_base=$4
+	local _readd_script=$5
+	local _script_dir="$_readd_base/$_ip.$_maskbits"
+
+	test -x "$_readd_script" || {
+		echo "Script '$_readd_script' isn't executable"
+		return 1;
+	}
+
+	local _readd_basename=`basename $_readd_script`
+	local _readd_final="$_script_dir/$_readd_basename"
+
+	mkdir -p $_script_dir || {
+		echo "Failed to mkdir -p $_script_dir"
+		return 1;
+	}
+
+	cp -a $_readd_script $_readd_final || {
+		echo "Failed to - cp -a $_readd_script $_readd_final"
+		return 1;
+	}
+
+	return 0
+}
+
 case "$OP" in
 	add)
-		add_ip_to_iface $IFACE $IP $MASKBITS
+		add_ip_to_iface $IFACE $IP $MASKBITS $READD_BASE
 		exit $?
 		;;
 	delete)
-		delete_ip_from_iface $IFACE $IP $MASKBITS
+		delete_ip_from_iface $IFACE $IP $MASKBITS $READD_BASE
+		exit $?
+		;;
+	readd_script)
+		setup_iface_ip_readd_script $IFACE $IP $MASKBITS $READD_BASE $READD_SCRIPT
 		exit $?
 		;;
 esac
diff --git a/config/notify.sh b/config/notify.sh
index 890b2fb..8d3eb87 100755
--- a/config/notify.sh
+++ b/config/notify.sh
@@ -37,10 +37,13 @@ case $event in
 	#		recovery?
 		;;
 
+	setup)
+	#		do some extra magic when ctdb has setup itself?
+		;;
+
 	init)
 	#		do some extra magic when ctdb has started?


-- 
CTDB repository


More information about the samba-cvs mailing list