From 2f5af51c5392f82ce5cae60df0976a24d8885e11 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Jun 2007 18:51:05 +1000 Subject: [PATCH] add an easy way to setup ctdb to start/stop samba (This used to be ctdb commit b0d9f427d83aff5b9a5c54b7b7c9d45d418e2352) --- ctdb/packaging/ctdb.init | 8 ++++++-- ctdb/tools/ctdb.sysconfig | 25 ++++++++++++++----------- ctdb/tools/events.d/nfs | 4 ++-- ctdb/tools/events.d/samba | 9 ++++++++- ctdb/tools/functions | 14 ++++++++++++++ 5 files changed, 44 insertions(+), 16 deletions(-) diff --git a/ctdb/packaging/ctdb.init b/ctdb/packaging/ctdb.init index 519334f6665..5852d826a95 100755 --- a/ctdb/packaging/ctdb.init +++ b/ctdb/packaging/ctdb.init @@ -119,13 +119,17 @@ case "$1" in restart ;; status) - rhstatus + status ;; condrestart) ctdb status > /dev/null && restart || : ;; + cron) + # used from cron to auto-restart ctdb + ctdb status > /dev/null || start + ;; *) - echo $"Usage: $0 {start|stop|restart|status|condrestart}" + echo $"Usage: $0 {start|stop|restart|status|cron|condrestart}" exit 1 esac diff --git a/ctdb/tools/ctdb.sysconfig b/ctdb/tools/ctdb.sysconfig index b9909f0c078..91ff955ad8b 100644 --- a/ctdb/tools/ctdb.sysconfig +++ b/ctdb/tools/ctdb.sysconfig @@ -5,6 +5,20 @@ # there is no default # CTDB_RECOVERY_LOCK="/some/place/on/shared/storage" +# should ctdb do IP takeover? If it should, then specify a file +# containing the list of public IP addresses that ctdb will manage +# Note that these IPs must be different from those in $NODES above +# there is no default +# PUBLIC_ADDRESSES=/etc/ctdb/public_addresses + +# when doing IP takeover you also must specify what network interface +# to use for the public addresses +# there is no default +# PUBLIC_INTERFACE=eth0 + +# should ctdb manage starting/stopping the Samba service for you? +# default is to not manage Samba +# CTDB_MANAGES_SAMBA=yes # the NODES file must be specified or ctdb won't start # it should contain a list of IPs that ctdb will use @@ -29,17 +43,6 @@ # defaults to tcp # TRANSPORT="tcp" -# should ctdb do IP takeover? If it should, then specify a file -# containing the list of public IP addresses that ctdb will manage -# Note that these IPs must be different from those in $NODES above -# there is no default -# PUBLIC_ADDRESSES=/etc/ctdb/public_addresses - -# when doing IP takeover you also must specify what network interface -# to use for the public addresses -# there is no default -# PUBLIC_INTERFACE=eth0 - # where to log messages # the default is /var/log/log.ctdb # LOGFILE=/var/log/log.ctdb diff --git a/ctdb/tools/events.d/nfs b/ctdb/tools/events.d/nfs index 23ad504d100..10b4fc9e5a2 100644 --- a/ctdb/tools/events.d/nfs +++ b/ctdb/tools/events.d/nfs @@ -33,8 +33,8 @@ case $cmd in # restart NFS to ensure that all TCP connections to the released ip # are closed [ -f /etc/ctdb/state/nfs/restart ] && { - ( /sbin/service nfs status > /dev/null 2>&1 && - /sbin/service nfs restart > /dev/null 2>&1 ) & + ( service nfs status > /dev/null 2>&1 && + service nfs restart > /dev/null 2>&1 ) & } > /dev/null 2>&1 /bin/rm -f /etc/ctdb/state/nfs/restart ;; diff --git a/ctdb/tools/events.d/samba b/ctdb/tools/events.d/samba index 188ef6d9ccd..0abbed76dbf 100644 --- a/ctdb/tools/events.d/samba +++ b/ctdb/tools/events.d/samba @@ -9,8 +9,14 @@ PATH=/bin:/usr/bin:$PATH cmd="$1" shift +[ "$CTDB_MANAGES_SAMBA" = "yes" ] || exit 0 + case $cmd in startup) + # start Samba service + service smb start + service winbind start + # wait for the Samba tcp ports to become available smb_ports=`testparm -stv 2> /dev/null | egrep '\s*smb ports =' | cut -d= -f2` ctdb_wait_tcp_ports "Samba" $smb_ports @@ -35,7 +41,8 @@ case $cmd in shutdown) # shutdown Samba when ctdb goes down - killall -q smbd nmbd winbindd + service smb stop + service winbind stop ;; esac diff --git a/ctdb/tools/functions b/ctdb/tools/functions index 5342dff7bd1..4eb8f4a3d62 100644 --- a/ctdb/tools/functions +++ b/ctdb/tools/functions @@ -1,6 +1,20 @@ # utility functions for ctdb event scripts +###################################################### +# simulate /sbin/service on platforms that don't have it +service() { + service_name="$1" + op="$2" + if [ -x /sbin/service ]; then + /sbin/service "$service_name" "$op" + elif [ -x /etc/init.d/$service_name ]; then + /etc/init.d/$service_name "$op" + elif [ -x /etc/rc.d/init.d/$service_name ]; then + /etc/init.d/$service_name "$op" + fi +} + ###################################################### # wait for a set of tcp ports # usage: ctdb_wait_tcp_ports SERICE_NAME -- 2.47.3