events 50.samba: also support suse and ubuntu/debain systems
authorMichael Adam <obnox@samba.org>
Fri, 16 Jan 2009 12:33:13 +0000 (13:33 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 16 Jan 2009 12:33:13 +0000 (13:33 +0100)
for managing samba and winbind

This uses CTDB_INIT_STYLE as exported by ctdb.init.

suse systems usually have separate init scripts for
smb for smbd and nmb for nmbd, and the ubuntu/debian
start script for smbd and nmbd is called samba instead
of smb (on redhat).

Michael

(This used to be ctdb commit 5fe84f96f3f79baba1f44ba57ce217f501b3c1f8)

ctdb/config/events.d/50.samba

index 9ec5f1c2d830f554cafce773fe943b737f42b842..add77985539efc9712ac42c1c76058609cd3aa16 100755 (executable)
@@ -7,6 +7,32 @@ PATH=/bin:/usr/bin:$PATH
 loadconfig ctdb
 loadconfig samba
 
+detect_init_style
+
+case $CTDB_INIT_STYLE in
+       suse)
+               CTDB_SERVICE_SMB="smb"
+               CTDB_SERVICE_NMB="nmb"
+               CTDB_SERVICE_WINBIND="winbind"
+               ;;
+       ubuntu)
+               CTDB_SERVICE_SMB="samba"
+               CTDB_SERVICE_NMB=""
+               CTDB_SERVICE_WINBIND="winbind"
+               ;;
+       redhat)
+               CTDB_SERVICE_SMB="smb"
+               CTDB_SERVICE_NMB=""
+               CTDB_SERVICE_WINBIND="winbind"
+               ;;
+       *)
+               # should not happen, but for now use redhat style as default:
+               CTDB_SERVICE_SMB="smb"
+               CTDB_SERVICE_NMB=""
+               CTDB_SERVICE_WINBIND="winbind"
+               ;;
+esac
+
 cmd="$1"
 shift
 
@@ -118,29 +144,37 @@ case $cmd in
        /bin/mkdir -p $CTDB_BASE/state/samba
 
        # make sure samba is not already started
-       service smb stop > /dev/null 2>&1
+       service $CTDB_SERVICE_SMB stop > /dev/null 2>&1
+       service $CTDB_SERVICE_NMB stop > /dev/null 2>&1
        killall -0 -q smbd && {
            sleep 1
            # make absolutely sure samba is dead
            killall -q -9 smbd
        }
 
+       killall -0 -q nmbd && {
+           sleep 1
+           # make absolutely sure samba is dead
+           killall -q -9 nmbd
+       }
+
        # restart the winbind service
        check_ctdb_manages_winbind
        [ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
-               service winbind stop > /dev/null 2>&1
+               service $CTDB_SERVICE_WINBIND stop > /dev/null 2>&1
                killall -0 -q winbindd && {
                    sleep 1
                    # make absolutely sure winbindd is dead
                    killall -q -9 winbindd
                }
-               service winbind start
+               service $CTDB_SERVICE_WINBIND start
        }
 
        # 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
-       nice_service smb start
+       nice_service $CTDB_SERVICE_NMB start
+       nice_service $CTDB_SERVICE_SMB start
        ;;
        
      takeip)
@@ -158,12 +192,13 @@ case $cmd in
 
      shutdown)
        # shutdown Samba when ctdb goes down
-       service smb stop
+       service $CTDB_SERVICE_SMB stop
+       service $CTDB_SERVICE_NMB stop
 
        # stop the winbind service
        check_ctdb_manages_winbind
        [ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
-               service winbind stop
+               service $CTDB_SERVICE_WINBIND stop
        }
        ;;