#!/bin/sh # this script needs to be installed so that statd points to it with the -H # command line argument. The easiest way to do that is to put something like this in # /etc/sysconfig/nfs: # STATD_HOSTNAME="myhostname -H /etc/ctdb/statd-callout" . /etc/ctdb/functions loadconfig nfs [ -z "$STATD_SHARED_DIRECTORY" ] && exit 0 [ -d $STATD_SHARED_DIRECTORY ] || exit 0 case "$1" in add-client) for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do ip=`/bin/basename $f` [ -d $STATD_SHARED_DIRECTORY/$ip ] || /bin/mkdir $STATD_SHARED_DIRECTORY/$ip /bin/touch $STATD_SHARED_DIRECTORY/$ip/sm/$2 done ;; del-client) for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do ip=`/bin/basename $f` /bin/rm -f $STATD_SHARED_DIRECTORY/$ip/sm/$2 done ;; notify) # send out notifications to any additional ips we now serve for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do ip=`/bin/basename $f` [ -d $STATD_SHARED_DIRECTORY/$ip ] && [ -x /usr/bin/smnotify ] && { /bin/rm -rf /tmp/statd/$ip /bin/mkdir -p /tmp/statd/$ip /bin/cp $STATD_SHARED_DIRECTORY/$ip/sm/* /tmp/statd/$ip for g in `/bin/ls /tmp/statd/$ip/*`; do client=`/bin/basename $g` # send the notifications twice so we force the other # end to recognice a state change has occured and that # it MUST reclaim the locks. # /usr/bin/smnotify --client=$client --ip=$ip --server=$ip --stateval=4 /usr/bin/smnotify --client=$client --ip=$ip --server=$ip --stateval=5 done } done ;; esac