docs on how to use statd-callout
[vlendec/samba-autobuild/.git] / ctdb / config / statd-callout
1 #!/bin/sh
2
3 # this script needs to be installed so that statd points to it with the -H 
4 # command line argument. The easiest way to do that is to put something like this in 
5 # /etc/sysconfig/nfs:
6 #   STATD_HOSTNAME="myhostname -H /etc/ctdb/statd-callout"
7
8
9 . /etc/sysconfig/nfs
10
11 [ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
12
13 [ -d $STATD_SHARED_DIRECTORY ] || exit 0
14
15 case "$1" in
16   add-client)
17         for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do
18             ip=`/bin/basename $f`
19             [ -d $STATD_SHARED_DIRECTORY/$ip ] || /bin/mkdir $STATD_SHARED_DIRECTORY/$ip
20             /bin/touch $STATD_SHARED_DIRECTORY/$ip/sm/$2
21         done
22         ;;
23   del-client)
24         for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do
25             ip=`/bin/basename $f`
26             /bin/rm -f $STATD_SHARED_DIRECTORY/$ip/sm/$2
27         done
28         ;;
29   notify)
30         # restart the local lock manager and statd
31         /etc/init.d/nfslock stop > /dev/null 2>&1 
32         /etc/init.d/nfslock start > /dev/null 2>&1 
33         # send out notifications to any additional ips we now serve
34         for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do
35             ip=`/bin/basename $f`
36             [ -d $STATD_SHARED_DIRECTORY/$ip ] && {
37                 # we must copy to a different directory since rpc.statd gets
38                 # "upset" if sm-notify touches the files.
39                 /bin/rm -rf /tmp/statd/$ip
40                 /bin/mkdir -p /tmp/statd/$ip
41                 /bin/cp -apr $STATD_SHARED_DIRECTORY/$ip/* /tmp/statd/$ip
42                 [ -x /usr/sbin/sm-notify ] && /usr/sbin/sm-notify -P /tmp/statd/$ip -v $ip -n
43             }
44         done
45         ;;
46 esac