From 92bcf1c475d8497e08a0babf7a7b3434dade7208 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 18 Nov 2010 11:04:52 +1100 Subject: [PATCH] 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 --- config/events.d/50.samba | 11 +++++++++-- config/functions | 14 +++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config/events.d/50.samba b/config/events.d/50.samba index 047f9e0b..5338c927 100755 --- a/config/events.d/50.samba +++ b/config/events.d/50.samba @@ -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 diff --git a/config/functions b/config/functions index 4acfc4ff..a7e3e539 100755 --- a/config/functions +++ b/config/functions @@ -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 "$service_name" appears in $t - [ "${t#* ${service_name} }" != "${t}" ] + # Returns 0 if "$_service_name" 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 -- 2.34.1