first step in health monitoring of cluster nodes. When not healthy they will be marke...
[metze/ctdb/wip.git] / config / events.d / 50.samba
1 #!/bin/sh
2 # ctdb event script for Samba
3
4 PATH=/bin:/usr/bin:$PATH
5
6 . /etc/ctdb/functions
7 loadconfig ctdb
8
9 cmd="$1"
10 shift
11
12 [ "$CTDB_MANAGES_SAMBA" = "yes" ] || exit 0
13
14 case $cmd in 
15      startup)
16         # wait for all shared directories to become available
17         smb_dirs=`testparm -st 2> /dev/null | egrep '^\s*path = '  | cut -d= -f2`
18         ctdb_wait_directories "Samba" $smb_dirs 
19
20         # make sure samba is not already started
21         service smb stop > /dev/null 2>&1
22         service winbind stop > /dev/null 2>&1
23
24         # start Samba service. Start it reniced, as under very heavy load 
25         # the number of smbd processes will mean that it leaves few cycles for
26         # anything else
27         nice service smb start
28         service winbind start
29
30         # wait for the Samba tcp ports to become available
31         smb_ports=`testparm -stv 2> /dev/null | egrep '\s*smb ports =' | cut -d= -f2`
32         ctdb_wait_tcp_ports "Samba" $smb_ports
33         ;;
34         
35      takeip)
36         # nothing special for Samba
37         ;;
38
39      releaseip)
40         # nothing special for Samba
41         ;;
42
43      recovered)
44         # nothing special for Samba
45         exit 0
46         ;;
47
48      shutdown)
49         # shutdown Samba when ctdb goes down
50         service smb stop
51         service winbind stop
52         ;;
53 esac
54
55 # ignore unknown commands
56 exit 0