mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
e763874872
(This used to be ctdb commit 65f3e2bc722e314b2c51c3bfdc544b408a8a64cf)
47 lines
1.4 KiB
Bash
Executable File
47 lines
1.4 KiB
Bash
Executable File
#!/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)
|
|
# restart the local lock manager and statd
|
|
/etc/init.d/nfslock stop > /dev/null 2>&1
|
|
/etc/init.d/nfslock start > /dev/null 2>&1
|
|
# 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 ] && {
|
|
# 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
|
|
[ -x /usr/sbin/sm-notify ] && /usr/sbin/sm-notify -P /tmp/statd/$ip -v $ip -n
|
|
}
|
|
done
|
|
;;
|
|
esac
|