add an easy way to setup ctdb to start/stop samba
authorAndrew Tridgell <tridge@samba.org>
Sat, 2 Jun 2007 08:51:05 +0000 (18:51 +1000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 2 Jun 2007 08:51:05 +0000 (18:51 +1000)
(This used to be ctdb commit b0d9f427d83aff5b9a5c54b7b7c9d45d418e2352)

ctdb/packaging/ctdb.init
ctdb/tools/ctdb.sysconfig
ctdb/tools/events.d/nfs
ctdb/tools/events.d/samba
ctdb/tools/functions

index 519334f666594d9c412df28aaadc9a6edc04bd48..5852d826a9577297f95623c384b7397553794880 100755 (executable)
@@ -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
 
index b9909f0c078d7e5c77770d2e0532715d1d6f8377..91ff955ad8be5d8890c7f0d3cc348de0e3b9504e 100644 (file)
@@ -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
 # 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
index 23ad504d10010a8eb724c90982e3dfd8f2711d4b..10b4fc9e5a26d2ecb1ae844c67a86582fc1b9c0b 100644 (file)
@@ -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
        ;;
index 188ef6d9ccdc0f7dc3e1bb65d2d44c2bb2bab787..0abbed76dbf3e5706c38e2316f2e10951abad37d 100644 (file)
@@ -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
 
index 5342dff7bd1911cdaa2b5c7b56855caf84b50329..4eb8f4a3d62c139c79d40ee50feabf9716a7192e 100644 (file)
@@ -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 <ports...>