2007-05-31 11:09:45 +10:00
#!/bin/sh
2007-06-01 20:54:26 +10:00
# 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
2007-05-31 11:09:45 +10:00
. /etc/sysconfig/ctdb
[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
[ -d $STATD_SHARED_DIRECTORY ] || exit 0
case "$1" in
add-client)
2007-06-01 20:54:26 +10:00
for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do
ip=`/bin/basename $f`
2007-05-31 11:09:45 +10:00
[ -d $STATD_SHARED_DIRECTORY/$ip ] || /bin/mkdir $STATD_SHARED_DIRECTORY/$ip
2007-06-01 20:54:26 +10:00
/bin/touch $STATD_SHARED_DIRECTORY/$ip/sm/$2
2007-05-31 11:09:45 +10:00
done
;;
del-client)
2007-06-01 20:54:26 +10:00
for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do
ip=`/bin/basename $f`
/bin/rm -f $STATD_SHARED_DIRECTORY/$ip/sm/$2
2007-05-31 11:09:45 +10:00
done
;;
2007-06-01 13:14:05 +10:00
notify)
# restart the local lock manager and statd
/sbin/service nfslock stop > /dev/null 2>&1
/sbin/service nfslock start > /dev/null 2>&1
# send out notifications to any additional ips we now serve
2007-06-01 20:54:26 +10:00
for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do
ip=`/bin/basename $f`
2007-05-31 11:09:45 +10:00
[ -d $STATD_SHARED_DIRECTORY/$ip ] && {
2007-06-01 13:14:05 +10:00
# we must copy to a different directory since rpc.statd gets
# "upset" if sm-notify touches the files.
/bin/rm -rf /tmp/statd/$ip
/bin/mkdir -p /tmp/statd/$ip
/bin/cp -apr $STATD_SHARED_DIRECTORY/$ip/* /tmp/statd/$ip
2007-06-01 20:54:26 +10:00
[ -x /usr/sbin/sm-notify ] && /usr/sbin/sm-notify -P /tmp/statd/$ip -v $ip -n
2007-05-31 11:09:45 +10:00
}
done
;;
esac