50.samba eventscript should stop/start services when they become (un)managed.
authorMartin Schwenke <martin@meltin.net>
Thu, 18 Nov 2010 00:04:52 +0000 (11:04 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 18 Nov 2010 01:05:47 +0000 (12:05 +1100)
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@meltin.net>
config/events.d/50.samba
config/functions

index 047f9e0bb44fec6286d1a49870613530f7e7d22b..5338c927e012cd1a76eccd05b92fef16cc2a6ba5 100755 (executable)
@@ -30,8 +30,6 @@ service_stop="stop_samba"
 
 loadconfig
 
-[ "$CTDB_MANAGES_SAMBA" = "yes" ] || [ "$CTDB_MANAGES_WINBIND" = "yes" ] || exit 0
-
 start_samba() {
        # create the state directory for samba
        /bin/mkdir -p $CTDB_VARDIR/state/samba
@@ -203,6 +201,15 @@ periodic_cleanup() {
     smbstatus -np > /dev/null 2>&1 &
 }
 
+###########################
+
+ctdb_start_stop_service
+ctdb_start_stop_service "windbind"
+
+is_ctdb_managed_service || is_ctdb_managed_service "winbind" || exit 0
+
+###########################
+
 case "$1" in 
      startup)
        ctdb_service_start
index 4acfc4ffab3f4347dce18f23be6a2e1f0e8c4be9..a7e3e539110273a2feb071d886f267b133449b8d 100755 (executable)
@@ -662,6 +662,8 @@ ctdb_compat_managed_service ()
 
 is_ctdb_managed_service ()
 {
+    _service_name="${1:-${service_name}}"
+
     t=" $CTDB_MANAGED_SERVICES "
 
     ctdb_compat_managed_service "$CTDB_MANAGES_VSFTPD"   "vsftpd"
@@ -673,17 +675,19 @@ is_ctdb_managed_service ()
     ctdb_compat_managed_service "$CTDB_MANAGES_CLAMD"    "clamd"
     ctdb_compat_managed_service "$CTDB_MANAGES_NFS"      "nfs"
 
-    # Returns 0 if "<space>$service_name<space>" appears in $t
-    [ "${t#* ${service_name} }" != "${t}" ]
+    # Returns 0 if "<space>$_service_name<space>" appears in $t
+    [ "${t#* ${_service_name} }" != "${t}" ]
 }
 
 ctdb_start_stop_service ()
 {
-    _active="$ctdb_active_dir/$service_name"
+    _service_name="${1:-${service_name}}"
+
+    _active="$ctdb_active_dir/$_service_name"
 
     if is_ctdb_managed_service ; then
        if ! [ -e "$_active" ] ; then
-           echo "Starting service $service_name"
+           echo "Starting service $_service_name"
            ctdb_service_start || exit $?
            mkdir -p "$ctdb_active_dir"
            touch "$_active"
@@ -691,7 +695,7 @@ ctdb_start_stop_service ()
        fi
     elif ! is_ctdb_managed_service ; then
        if [ -e "$_active" ] ; then
-           echo "Stopping service $service_name"
+           echo "Stopping service $_service_name"
            ctdb_service_stop || exit $?
            rm -f "$_active"
        fi