[SCM] CTDB repository - branch master updated - ctdb-1.10-365-g2086482

Ronnie Sahlberg sahlberg at samba.org
Wed Aug 10 22:01:54 MDT 2011


The branch, master has been updated
       via  20864822372b6d574c545287002a429b273c4bcc (commit)
       via  c45a89418ba733ff91d48340d72bdb6d2ef80051 (commit)
       via  642292d7ba7a95567964b4160c7ee31a4f8985d1 (commit)
       via  21dfcbbdccd906fcd6ab7bba81418ce565bf63aa (commit)
       via  defaec99df8c279d8e315d5010f9146e013afda2 (commit)
       via  de13350c17261032a7468c2cf4d2cf4a8d66a840 (commit)
       via  f928c201b6d0e1cd3e5568ae65186e3cee7c4988 (commit)
       via  01776b9f29af9ad5c8534649ece1bd100e450434 (commit)
       via  5b01b7233515669e995e037205796e265643b176 (commit)
       via  881af7c1417962b9b3ade6565b3e8eb9f9df7a97 (commit)
       via  a9ab1937239761dc32b143c9d225447bc6f090b4 (commit)
       via  f57d1722b6aa082f3f826171acc57d7d796ea95c (commit)
       via  6da7095192fb172a06b434cfb02f4bfa6221b343 (commit)
       via  05a8fcfbac3da2b5843b31e0fe258255cc761190 (commit)
       via  beabf506a5eb68fc50fdbf8772c1d2bb0f7951e3 (commit)
       via  0f003f05e28037eefdce3a686fcb52cd2289af9d (commit)
       via  7c070b0bc86b3b9a91a9dc263b72c0567934535c (commit)
       via  cc4c5c19af7efe01c48f73bb5ec5e607ed79db4c (commit)
       via  da3aedd1a472b430b75989d3c157efedd382e327 (commit)
       via  51c45b1c4751af41e5f9fd252763e0025f8cce3a (commit)
       via  15d4111d0761d82f57d5d4f0b1227812d14e4d7c (commit)
       via  8675744cbd90b5a5095ed6fff7b36ae82004a457 (commit)
       via  86e4aefed9fd1028660c98e3ea758c2b75ffc1d8 (commit)
       via  b14f18649f42aab80ce0336c15ab6159f241c9af (commit)
       via  758f4667c60089e09a0439c1eb74f5e426ca5e2e (commit)
       via  538902fbc1e74134a03987b36b3733ad641f8971 (commit)
       via  d8f0f8948abd340088720718fef7dc858661ba23 (commit)
       via  257a2e350280c0b76ed2fac588cad167381fda52 (commit)
      from  8de5513b3ad89711da845c7588d35b32e2f2acb6 (commit)

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


- Log -----------------------------------------------------------------
commit 20864822372b6d574c545287002a429b273c4bcc
Merge: 8de5513b3ad89711da845c7588d35b32e2f2acb6 c45a89418ba733ff91d48340d72bdb6d2ef80051
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Aug 11 14:01:02 2011 +1000

    Merge remote branch 'martins/eventscript_infrastructure'

commit c45a89418ba733ff91d48340d72bdb6d2ef80051
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 16:00:05 2011 +1000

    Eventscripts: in 60.nfs move statd-notify code to service_reconfigure().
    
    This means that it now occurs on every reconfigure event.  As a result
    the ipreallocated event is removed.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 642292d7ba7a95567964b4160c7ee31a4f8985d1
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 11 13:55:02 2011 +1000

    Eventscripts - 60.nfs should define service_reconfigure().
    
    Not $service_reconfigure.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 21dfcbbdccd906fcd6ab7bba81418ce565bf63aa
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 14 09:31:56 2011 +1100

    Evenscripts: improvements to ctdb_service_check_reconfigure().
    
    * Make this function applicable to "ipreallocated" event too.
    
    * Monitor event should not always succeed just because we reconfigure.
    
      If the service was unhealthy before the reconfigure and we end the
      reconfigure with "exit 0" then we can cause the node's health status
      to flip-flop.
    
      To avoid this we return the status of the service from the previous
      monitor event.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit defaec99df8c279d8e315d5010f9146e013afda2
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 27 14:37:37 2011 +1000

    Eventscripts: 50.samba - only start/stop nmbd if $CTDB_SERVICE_NMB set.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit de13350c17261032a7468c2cf4d2cf4a8d66a840
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 15:37:09 2011 +1000

    Eventscripts: 50.samba needs null service_reconfigure() function.
    
    Samba doesn't need to do anything for configuration changes.  It will
    notice configuration changes and reload automatically.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit f928c201b6d0e1cd3e5568ae65186e3cee7c4988
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 14 09:42:18 2011 +1100

    Eventscripts: 40.vsftpd service_stop() no longer /dev/null's output.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 01776b9f29af9ad5c8534649ece1bd100e450434
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 14 09:43:01 2011 +1100

    Eventscripts: improvements to 41.httpd.
    
    * Reduce the failure counts so that restart attempts happen sooner.
    
    * Use service_start() and service_stop() for the restart.
      ctdb_service_start() resets the failure count, which isn't very
      useful in this context.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 5b01b7233515669e995e037205796e265643b176
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Dec 17 16:10:56 2010 +1100

    Eventscript functions: new function ctdb_check_counter().
    
    This should eventually be able to replace ctdb_check_counter_limit()
    and ctdb_check_counter_equal(), although it doesn't issue warnings
    like the former.
    
    It takes 4 optional arguments:
    
    1. _msg - If "error" then over limit causes an error message and and
       exit 1.  Anything else fails silently but the function returns 1.
       Default is "error".
    
    2. _op - An integer operator supported by test (e.g. -eq, -ge, -gt).
       Default is -ge.
    
    3. _limit - Limit for the counter to be used in comparison.  Default is
       $service_fail_limit.
    
    4. _service_name - Used to identify the counter.  Default is
       $service_name.
    
    For example:
    
      ctdb_check_counter error -ge 5 foo
    
    will print a message and exit 1 if the counter for foo is >= 5,
    whereas
    
      ctdb_check_counter check -ge 5 foo
    
    will just return 1 if the counter for foo is >= 5, and
    
      ctdb_counter_check
    
    with print a message and exit 1 if the counter for $service_name is >=
    $service_fail_limit.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 881af7c1417962b9b3ade6565b3e8eb9f9df7a97
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 28 14:57:11 2011 +1000

    Eventscripts: remove unused remove_ip() function.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit a9ab1937239761dc32b143c9d225447bc6f090b4
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 14 09:31:05 2011 +1100

    Eventscripts: startstop_nfs stop no longer redirects output to /dev/null.
    
    When stopping (as opposed to restarting) it is useful to see this
    information.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit f57d1722b6aa082f3f826171acc57d7d796ea95c
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 14 09:29:16 2011 +1100

    Eventscripts: fix typo in _ctdb_counter_common().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 6da7095192fb172a06b434cfb02f4bfa6221b343
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 14 09:30:21 2011 +1100

    Eventscripts: improve log messages in ctdb_start_stop_service().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 05a8fcfbac3da2b5843b31e0fe258255cc761190
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 16 10:11:33 2010 +1100

    Eventscript functions: fix counter regression.
    
    d362be7d32079ac1390d67056ce107bfbca2c937 wasn't well thought out.
    Subsequent commits depend on ctdb_counter_init() taking an argument,
    so this makes those cases work.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit beabf506a5eb68fc50fdbf8772c1d2bb0f7951e3
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 16 09:50:44 2010 +1100

    Eventscript functions: ctdb_service_check-reconfigure() acts only on monitor.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 0f003f05e28037eefdce3a686fcb52cd2289af9d
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Dec 17 16:29:21 2010 +1100

    Eventscripts: make 50.samba use $service_state_dir.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 7c070b0bc86b3b9a91a9dc263b72c0567934535c
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 16 09:45:28 2010 +1100

    Evenscripts: update 60.nfs to use ctdb_service_check_reconfigure.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit cc4c5c19af7efe01c48f73bb5ec5e607ed79db4c
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 16 08:57:46 2010 +1100

    Evenscripts: update 60.nfs to use ctdb_setup_service_state_dir.
    
    The state directory basename becomes "nfs" rather than "statd".  One
    line of code i moved from the "startup" event to service_start().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit da3aedd1a472b430b75989d3c157efedd382e327
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 16 09:48:25 2010 +1100

    Evenscripts: update 40.vsftpd to use ctdb_service_check_reconfigure.
    
    To simplify we also remove the reconfigure from the recovered event
    because the monitor event will handle this very quickly anyway.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 51c45b1c4751af41e5f9fd252763e0025f8cce3a
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 16 09:47:10 2010 +1100

    Evenscripts: update 41.httpd to use ctdb_service_check_reconfigure.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 15d4111d0761d82f57d5d4f0b1227812d14e4d7c
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 15 19:19:21 2010 +1100

    Eventscripts: rejig the reconfigure infrastructure.
    
    * Add an optional service name argument to existing reconfigure
      functions.
    
    * User function service_reconfigure() instead of variable
      $service_reconfigure to specify how a service is reconfigured.
    
    * New function ctdb_service_check_reconfigure() reconfigures a service
      if it is flagged for reconfigure.
    
    * Remove $service_reconfigure settings from 40.vsftpd and 41.httpd -
      they're the defaults.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 8675744cbd90b5a5095ed6fff7b36ae82004a457
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 15 16:34:00 2010 +1100

    Eventscript functions: move flagging of managed services.
    
    Move flagging of managed or unmanaged services into
    ctdb_service_start() and ctdb_service_stop().  That way services will
    be correctly flagged if they are started from the startup and shutdown
    events.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 86e4aefed9fd1028660c98e3ea758c2b75ffc1d8
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 11 09:39:25 2011 +1000

    Eventscript function: change service_start into a function.
    
    service_start is currently a variable.  This makes passing arguments
    hard.  We change it to be a function and put default definitions into
    the functions file.
    
    We use a convention that if a service name argument is passed to a
    redefined version of service_start() or service_stop() then it will
    act unconditionally.  If no argument is passed then it can use
    internal logic to decide if services should really be started.  This
    is useful when a single eventscript handles multiple services.
    
    This is a cherry-pick of ae38895 that needed to be reset mid-stream.
    There is still some breakage following this commit.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit b14f18649f42aab80ce0336c15ab6159f241c9af
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 15 10:48:00 2010 +1100

    Eventscript functions: add optional event name argument to fail count functions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 758f4667c60089e09a0439c1eb74f5e426ca5e2e
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Nov 18 16:19:45 2010 +1100

    Eventscript functions - optimise is_ctdb_managed_service().
    
    This function generates a lot of trace when running under "set -x".
    This is due to the backward compatibility code.
    
    This adds 3 optimisations:
    
    1. Before invoking the backward compatiblity code,
       is_ctdb_managed_service() returns early if the service is listed in
       $CTDB_MANAGED_SERVICES.
    
    2. ctdb_compat_managed_service() actually now updates
       $CTDB_MANAGED_SERVICES instead of temporary variable $t.
    
       This means that a subsequent call to is_ctdb_managed_service() will
       short circuit due to optimisation (1).
    
    3. ctdb_compat_managed_service() only adds a service to
       $CTDB_MANAGED_SERVICES if it is the service being checked by
       is_ctdb_managed_service().
    
       This stops irrelevant services being added to
       $CTDB_MANAGED_SERVICES multiple times by multiple calls to
       is_ctdb_managed_service().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 538902fbc1e74134a03987b36b3733ad641f8971
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Nov 18 16:03:47 2010 +1100

    50.samba eventscript should use is_ctdb_managed_service "winbind".
    
    Currently it checks $CTDB_MANAGES_WINBIND directly in several places.
    This doesn't work when someone sets $CTDB_MANAGED_SERVICES directly.
    
    This modifies check_ctdb_manages_winbind() so that it return a
    condition rather than modifying $CTDB_MANAGES_WINBIND.  This makes
    some code more readable.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit d8f0f8948abd340088720718fef7dc858661ba23
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Nov 18 14:34:48 2010 +1100

    50.samba eventscript should use is_ctdb_managed_service "samba".
    
    Currently it checks $CTDB_MANAGES_SAMBA directly.  This doesn't work
    when someone sets $CTDB_MANAGED_SERVICES directly.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 257a2e350280c0b76ed2fac588cad167381fda52
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Nov 18 11:04:52 2010 +1100

    50.samba eventscript should stop/start services when they become (un)managed.
    
    When the value of $CTDB_MANAGES_SAMBA or $CTDB_MANAGES_WINBIND (or
    corresponding changes are made to $CTDB_MANAGED_VERSIONS), the
    associated service should be started or stopped as necessary.
    
    This add calls to ctdb_start_stop_service() to manage
    starting/stopping samba and winbind.
    
    An associated cleanup is made to the initial checks that one of
    $CTDB_MANAGES_SAMBA or $CTDB_MANAGES_WINBIND is set, replacing them
    with calls to is_ctdb_managed_service().
    
    To handle the winbind cases ctdb_start_stop_service() and
    is_ctdb_managed_service() are updated to take an optional service name
    parameter.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    Conflicts:
    
    	config/events.d/50.samba
    
    	Most of this merged elsewhere.  This just removes a check that
    	this is the monitor event.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 config/events.d/31.clamd  |    7 +-
 config/events.d/40.vsftpd |   28 +++----
 config/events.d/41.httpd  |   32 +++++----
 config/events.d/50.samba  |  127 +++++++++++++++++++-------------
 config/events.d/60.nfs    |   55 +++++++-------
 config/functions          |  178 ++++++++++++++++++++++++++++++++-------------
 6 files changed, 265 insertions(+), 162 deletions(-)
 mode change 100644 => 100755 config/events.d/31.clamd


Changeset truncated at 500 lines:

diff --git a/config/events.d/31.clamd b/config/events.d/31.clamd
old mode 100644
new mode 100755
index 73454d7..53739e2
--- a/config/events.d/31.clamd
+++ b/config/events.d/31.clamd
@@ -16,8 +16,11 @@ case $CTDB_INIT_STYLE in
 		;;
 esac
 
-service_start="service $service_name stop > /dev/null 2>&1 ; service $service_name start"
-service_stop="service $service_name stop"
+service_start ()
+{
+    service $service_name stop > /dev/null 2>&1
+    service $service_name start
+}
 
 loadconfig
 
diff --git a/config/events.d/40.vsftpd b/config/events.d/40.vsftpd
index 72190db..e6d58c8 100755
--- a/config/events.d/40.vsftpd
+++ b/config/events.d/40.vsftpd
@@ -5,9 +5,16 @@
 
 service_name="vsftpd"
 # make sure the service is stopped first
-service_start="service $service_name stop > /dev/null 2>&1 ; service $service_name start"
-service_stop="service $service_name stop > /dev/null 2>&1"
-service_reconfigure="service $service_name restart"
+service_start ()
+{
+    service $service_name stop > /dev/null 2>&1
+    service $service_name start
+}
+service_stop ()
+{
+    service $service_name stop
+}
+
 service_fail_limit=2
 service_tcp_ports=21
 
@@ -17,6 +24,8 @@ ctdb_start_stop_service
 
 is_ctdb_managed_service || exit 0
 
+ctdb_service_check_reconfigure
+
 case "$1" in 
     startup)
 	ctdb_service_start
@@ -30,20 +39,7 @@ case "$1" in
 	ctdb_service_set_reconfigure
 	;;
 
-    recovered)
-	# if we have taken or released any ips we must 
-	# restart vsftpd to ensure that all tcp connections are reset
-	if ctdb_service_needs_reconfigure ; then
-	    ctdb_service_reconfigure
-	fi
-	;;
-
     monitor)
-	if ctdb_service_needs_reconfigure ; then
-	    ctdb_service_reconfigure
-	    exit 0
-	fi
-
 	if [ -n "$service_tcp_ports" ] ; then
 	    if ctdb_check_tcp_ports $service_tcp_ports ; then
 		ctdb_counter_init
diff --git a/config/events.d/41.httpd b/config/events.d/41.httpd
index e94bde3..6ae5d61 100755
--- a/config/events.d/41.httpd
+++ b/config/events.d/41.httpd
@@ -27,9 +27,16 @@ cleanup_httpd_semaphore_leak() {
 
 ##########
 
-service_start="cleanup_httpd_semaphore_leak; service $service_name start"
-service_stop="service $service_name stop; killall -q -9 $service_name || true"
-service_reconfigure="service $service_name restart"
+service_start ()
+{
+    cleanup_httpd_semaphore_leak
+    service $service_name start
+}
+service_stop ()
+{
+    service $service_name stop
+    killall -q -9 $service_name || true
+}
 
 loadconfig
 
@@ -37,6 +44,8 @@ ctdb_start_stop_service
 
 is_ctdb_managed_service || exit 0
 
+ctdb_service_check_reconfigure
+
 case "$1" in
     startup)
 	ctdb_service_start
@@ -47,26 +56,21 @@ case "$1" in
 	;;
 
     monitor)
-	if ctdb_service_needs_reconfigure ; then
-	    ctdb_service_reconfigure
-	    exit 0
-	fi
-
 	if ctdb_check_tcp_ports 80 >/dev/null 2>/dev/null ; then
 	    ctdb_counter_init
 	else
 	    ctdb_counter_incr
 
-	    ctdb_check_counter_equal 5 || {
+	    ctdb_check_counter warn -eq 2 || {
 		echo "HTTPD is not running. Trying to restart HTTPD."
-		ctdb_service_stop
-		ctdb_service_start
+		service_stop
+		service_start
 		exit 0
 	    }
-            ctdb_check_counter_limit 10 quiet|| {
+            ctdb_check_counter warn -ge 5 || {
 		echo "HTTPD is not running. Trying to restart HTTPD."
-		ctdb_service_stop
-		ctdb_service_start
+		service_stop
+		service_start
 		exit 1
 	    }
 	fi
diff --git a/config/events.d/50.samba b/config/events.d/50.samba
index 3e90742..1c68227 100755
--- a/config/events.d/50.samba
+++ b/config/events.d/50.samba
@@ -25,19 +25,23 @@ case $CTDB_INIT_STYLE in
 esac
 
 service_name="samba"
-service_start="start_samba"
-service_stop="stop_samba"
 
 loadconfig
 
-start_samba() {
-	# create the state directory for samba
-	mkdir -p $CTDB_VARDIR/state/samba
+ctdb_setup_service_state_dir
+
+service_start ()
+{
+	# If set then we force-start the relevant service.
+	_service_name="$1"
 
 	# make sure samba is not already started
-	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
+	if [ "$_service_name" = "samba" ] || \
+	    is_ctdb_managed_service "samba" ; then
 		service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1
-		service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
+		if [ -n "$CTDB_SERVICE_NMB" ] ; then
+		    service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
+		fi
 		killall -0 -q smbd && {
 		    sleep 1
 		    # make absolutely sure samba is dead
@@ -49,11 +53,11 @@ start_samba() {
 		    # make absolutely sure samba is dead
 		    killall -q -9 nmbd
 		}
-	}
+	fi
 
 	# make sure winbind is not already started
-	check_ctdb_manages_winbind
-	[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
+	if [ "$_service_name" = "winbind" ] || \
+	    check_ctdb_manages_winbind ; then
 		service "$CTDB_SERVICE_WINBIND" stop > /dev/null 2>&1
 		killall -0 -q winbindd && {
 		    sleep 1
@@ -61,65 +65,78 @@ start_samba() {
 		    killall -q -9 winbindd
 		}
 
-	}
+	fi
 
 	# start the winbind service
-	[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
+	if [ "$_service_name" = "winbind" ] || \
+	    check_ctdb_manages_winbind ; then
 		service "$CTDB_SERVICE_WINBIND" start || {
-			echo failed to start winbind
-			exit 1
+		    echo failed to start winbind
+		    exit 1
 		}
-
-	}
+	fi
 
 	# start Samba service. Start it reniced, as under very heavy load 
 	# the number of smbd processes will mean that it leaves few cycles for
 	# anything else
-	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
+	if [ "$_service_name" = "samba" ] || \
+	    is_ctdb_managed_service "samba" ; then
 		net serverid wipe
 
-		nice_service "$CTDB_SERVICE_NMB" start || {
+		if [ -n "$CTDB_SERVICE_NMB" ] ; then
+		    nice_service "$CTDB_SERVICE_NMB" start || {
 			echo failed to start nmbd
 			exit 1
-		}
-
+		    }
+		fi
 		nice_service "$CTDB_SERVICE_SMB" start || {
 			echo failed to start samba
 			exit 1
 		}
-	}
-	return 0
+	fi
 }
 
-stop_samba() {
+service_stop ()
+{
+	# If set then we force-stop the relevant service.
+	_service_name="$1"
+
 	# shutdown Samba when ctdb goes down
-	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
+	if [ "$_service_name" = "samba" ] || \
+	    is_ctdb_managed_service "samba" ; then
 		service "$CTDB_SERVICE_SMB" stop
-		service "$CTDB_SERVICE_NMB" stop
-	}
+		if [ -n "$CTDB_SERVICE_NMB" ] ; then
+		    service "$CTDB_SERVICE_NMB" stop
+		fi
+	fi
 
 	# stop the winbind service
-	check_ctdb_manages_winbind
-	[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
+	if [ "$_service_name" = "winbind" ] || \
+	    check_ctdb_manages_winbind ; then
 		service "$CTDB_SERVICE_WINBIND" stop
-	}
+	fi
 
 	return 0
 }
 
+service_reconfigure ()
+{
+    # Samba automatically reloads config - no restart needed.
+    :
+}
+
 # set default samba cleanup period - in minutes
 [ -z "$SAMBA_CLEANUP_PERIOD" ] && {
     SAMBA_CLEANUP_PERIOD=10
 }
 
 # we keep a cached copy of smb.conf here
-smbconf_cache="$CTDB_VARDIR/state/samba/smb.conf.cache"
+smbconf_cache="$service_state_dir/smb.conf.cache"
 
 
 #############################################
 # update the smb.conf cache in the foreground
 testparm_foreground_update() {
-    mkdir -p "$CTDB_VARDIR/state/samba" || exit 1
     testparm -s 2> /dev/null | egrep -v 'registry.shares.=|include.=' > "$smbconf_cache"
 }
 
@@ -183,19 +200,27 @@ testparm_cat() {
     testparm -s "$smbconf_cache" "$@" 2>/dev/null
 }
 
-# function to see if ctdb manages winbind
+# function to see if ctdb manages winbind - this overrides with extra
+# logic if $CTDB_MANAGES_WINBIND is not set or null.
 check_ctdb_manages_winbind() {
-  [ -z "$CTDB_MANAGES_WINBIND" ] && {
-    secmode=`testparm_cat --parameter-name=security`
-    case $secmode in
-	ADS|DOMAIN)
-	    CTDB_MANAGES_WINBIND="yes";
-	    ;;
-	*)
-	    CTDB_MANAGES_WINBIND="no";
-	    ;;
-    esac
-  }
+    if is_ctdb_managed_service "winbind" ; then
+	return 0
+    elif [ -n "$CTDB_MANAGES_WINBIND" ] ; then
+	# If this variable is set we want to respect it.  We return
+	# false here because we know it is not set to "yes" - if it
+	# were then the 1st "if" above would have succeeded.
+	return 1
+    else
+	_secmode=`testparm_cat --parameter-name=security`
+	case "$_secmode" in
+	    ADS|DOMAIN)
+		return 0
+		;;
+	    *)
+		return 1
+		;;
+	esac
+    fi
 }
 
 list_samba_shares ()
@@ -217,10 +242,8 @@ periodic_cleanup() {
 
 ###########################
 
-[ "$1" = "monitor" ] && {
 ctdb_start_stop_service
 ctdb_start_stop_service "winbind"
-}
 
 is_ctdb_managed_service || is_ctdb_managed_service "winbind" || exit 0
 
@@ -238,16 +261,17 @@ case "$1" in
      monitor)
 	# Create a dummy file to track when we need to do periodic cleanup
 	# of samba databases
-	[ -f $CTDB_VARDIR/state/samba/periodic_cleanup ] || {
-		touch $CTDB_VARDIR/state/samba/periodic_cleanup
+	periodic_cleanup_file="$service_state_dir/periodic_cleanup"
+	[ -f "$periodic_cleanup_file" ] || {
+		touch "$periodic_cleanup_file"
 	}
-	[ `find $CTDB_VARDIR/state/samba/periodic_cleanup -mmin +$SAMBA_CLEANUP_PERIOD | wc -l` -eq 1 ] && {
+	[ `find "$periodic_cleanup_file" -mmin +$SAMBA_CLEANUP_PERIOD | wc -l` -eq 1 ] && {
 		# Cleanup the databases
 	    	periodic_cleanup
-		touch $CTDB_VARDIR/state/samba/periodic_cleanup
+		touch "$periodic_cleanup_file"
 	}
 
-	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
+	is_ctdb_managed_service "samba" && {
 		[ "$CTDB_SAMBA_SKIP_SHARE_CHECK" = "yes" ] || {
 			testparm_background_update
 
@@ -275,8 +299,7 @@ case "$1" in
 	}
 
 	# check winbind is OK
-	check_ctdb_manages_winbind
-	[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
+	check_ctdb_manages_winbind && {
 		ctdb_check_command "winbind" "wbinfo -p"
 	}
 	;;
diff --git a/config/events.d/60.nfs b/config/events.d/60.nfs
index c0207ee..e778048 100755
--- a/config/events.d/60.nfs
+++ b/config/events.d/60.nfs
@@ -1,37 +1,49 @@
 #!/bin/sh
 # script to manage nfs in a clustered environment
 
-start_nfs() {
-	mkdir -p $CTDB_VARDIR/state/nfs
-	mkdir -p $CTDB_VARDIR/state/statd/ip
-	startstop_nfs stop
-	startstop_nfs start
-	set_proc "sys/net/ipv4/tcp_tw_recycle" 1
-}
-
 . $CTDB_BASE/functions
 
 service_name="nfs"
-service_start="start_nfs"
-service_stop="startstop_nfs stop"
-service_reconfigure="startstop_nfs restart"
+service_start ()
+{
+    startstop_nfs stop
+    startstop_nfs start
+    set_proc "sys/net/ipv4/tcp_tw_recycle" 1
+    touch "$service_state_dir/update-trigger"
+}
+service_stop ()
+{
+    startstop_nfs stop
+}
+service_reconfigure ()
+{
+    startstop_nfs restart
+
+    # if the ips have been reallocated, we must restart the lockmanager
+    # across all nodes and ping all statd listeners
+    [ -x $CTDB_BASE/statd-callout ] && {
+	$CTDB_BASE/statd-callout notify &
+    } >/dev/null 2>&1
+}
 
 loadconfig
 
 [ "$NFS_SERVER_MODE" != "GANESHA" ] || exit 0
 
+ctdb_setup_service_state_dir
+
 ctdb_start_stop_service
 
 is_ctdb_managed_service || exit 0
 
+ctdb_service_check_reconfigure
+
 case "$1" in 
      init)
 	# read statd from persistent database
 	;;
      startup)
 	ctdb_service_start
-	mkdir -p $CTDB_VARDIR/state/statd
-	touch $CTDB_VARDIR/state/statd/update-trigger
 	;;
 
      shutdown)
@@ -54,11 +66,6 @@ case "$1" in
 	    ctdb_check_directories
 	} || exit $?
 
-	if ctdb_service_needs_reconfigure ; then
-	    ctdb_service_reconfigure
-	    exit 0
-	fi
-
 	update_tickles 2049
 
 	# check that statd responds to rpc requests
@@ -181,23 +188,15 @@ case "$1" in
 
 	# once every 600 seconds, update the statd state database for which
 	# clients need notifications
-	LAST_UPDATE=`stat --printf="%Y" $CTDB_VARDIR/state/statd/update-trigger 2>/dev/null`
+	LAST_UPDATE=`stat --printf="%Y" "$service_state_dir/update-trigger"`
 	CURRENT_TIME=`date +"%s"`
 	[ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
-	    mkdir -p $CTDB_VARDIR/state/statd
-	    touch $CTDB_VARDIR/state/statd/update-trigger
+	    touch "$service_state_dir/update-trigger"
 	    $CTDB_BASE/statd-callout updatelocal &
 	    $CTDB_BASE/statd-callout updateremote &
 	}
        	;;
 
-    ipreallocated)
-	# if the ips have been reallocated, we must restart the lockmanager
-	# across all nodes and ping all statd listeners
-	[ -x $CTDB_BASE/statd-callout ] && {
-		$CTDB_BASE/statd-callout notify &
-	} >/dev/null 2>&1
-	;;
     *)
 	ctdb_standard_event_handler "$@"
 	;;
diff --git a/config/functions b/config/functions
index 32f11f0..2668531 100755
--- a/config/functions
+++ b/config/functions
@@ -355,8 +355,8 @@ startstop_nfs() {
 			service nfs start
 			;;
 		stop)
-			service nfs stop > /dev/null 2>&1
-			service nfslock stop > /dev/null 2>&1
+			service nfs stop
+			service nfslock stop
 			;;
 		restart)
 			set_proc "fs/nfsd/threads" 0
@@ -425,18 +425,6 @@ startstop_nfslock() {
 	esac
 }
 
-# better use delete_ip_from_iface() together with add_ip_to_iface
-# remove_ip should be removed in future


-- 
CTDB repository


More information about the samba-cvs mailing list