install -m755 config/events $(DESTDIR)$(etcdir)/ctdb
install -m755 config/functions $(DESTDIR)$(etcdir)/ctdb
install -m755 config/statd-callout $(DESTDIR)$(etcdir)/ctdb
- install -m755 config/events.d/samba $(DESTDIR)$(etcdir)/ctdb/events.d
- install -m755 config/events.d/nfs $(DESTDIR)$(etcdir)/ctdb/events.d
- install -m755 config/events.d/nfslock $(DESTDIR)$(etcdir)/ctdb/events.d
+ install -m755 config/events.d/10.interface $(DESTDIR)$(etcdir)/ctdb/events.d
+ install -m755 config/events.d/50.samba $(DESTDIR)$(etcdir)/ctdb/events.d
+ install -m755 config/events.d/59.nfslock $(DESTDIR)$(etcdir)/ctdb/events.d
+ install -m755 config/events.d/60.nfs $(DESTDIR)$(etcdir)/ctdb/events.d
install -m755 tools/onnode.ssh $(DESTDIR)$(bindir)
install -m755 tools/onnode.rsh $(DESTDIR)$(bindir)
cd $(DESTDIR)$(bindir) && ln -sf onnode.ssh onnode
#!/bin/sh
############################
# main event script for ctdb
+#
+# This script is called with one of the following sets of arguments
+# startup : called when ctdb starts
+# shutdown : called when ctdb shuts down
+# takeip
. /etc/ctdb/functions
loadconfig ctdb
+# ensure we have /bin and /usr/bin in the path
+PATH=/bin:/usr/bin:$PATH
+
cmd="$1"
shift
case $cmd in
- #############################
- # called when ctdbd starts up
startup)
+ # make sure we have a blank state directory for the scripts to work with
/bin/rm -rf /etc/ctdb/state
/bin/mkdir -p /etc/ctdb/state
;;
-
-
- ################################################
- # called when ctdbd wants to claim an IP address
- takeip)
- if [ $# != 3 ]; then
- echo "must supply interface, IP and maskbits"
- exit 1
- fi
- iface=$1
- ip=$2
- maskbits=$3
-
- /sbin/ip link set $iface up || {
- echo "`/bin/date` Failed to bringup interface $iface"
- exit 1
- }
- /sbin/ip addr add $ip/$maskbits dev $iface || {
- echo "`/bin/date` Failed to add $ip/$maskbits on dev $iface"
- exit 1
- }
-
- # flush our route cache
- echo 1 > /proc/sys/net/ipv4/route/flush
- ;;
-
-
- ##################################################
- # called when ctdbd wants to release an IP address
- releaseip)
- if [ $# != 3 ]; then
- echo "`/bin/date` must supply interface, IP and maskbits"
- exit 1
- fi
- iface=$1
- ip=$2
- maskbits=$3
- /sbin/ip addr del $ip dev $iface || {
- echo "`/bin/date` Failed to del $ip on dev $iface"
- exit 1
- }
-
- # flush our route cache
- echo 1 > /proc/sys/net/ipv4/route/flush
- ;;
-
-
- ###########################################
- # called when ctdbd has finished a recovery
- recovered)
- ;;
-
- ####################################
- # called when ctdbd is shutting down
- shutdown)
- ;;
-
- *)
- echo "`/bin/date` Invalid ctdb event command $cmd"
- exit 1
- ;;
esac
#######################################
-# call all application specific scripts
+# call all application or local scripts
[ -d /etc/ctdb/events.d ] && {
- /bin/ls /etc/ctdb/events.d | /bin/grep -v '~' |
+ # only accept scripts of the form NN.name
+ /bin/ls /etc/ctdb/events.d | /bin/grep '^[0-9]*\.\w*$' | sort -n |
while read SCRIPT; do
[ -x /etc/ctdb/events.d/$SCRIPT ] && {
/etc/ctdb/events.d/$SCRIPT $cmd "$1" "$2" "$3" || exit 1
--- /dev/null
+#!/bin/sh
+
+#################################
+# interface event script for ctdb
+# this adds/removes IPs from your
+# public interface
+
+. /etc/ctdb/functions
+
+cmd="$1"
+shift
+
+case $cmd in
+ #############################
+ # called when ctdbd starts up
+ startup)
+ ;;
+
+
+ ################################################
+ # called when ctdbd wants to claim an IP address
+ takeip)
+ if [ $# != 3 ]; then
+ echo "must supply interface, IP and maskbits"
+ exit 1
+ fi
+ iface=$1
+ ip=$2
+ maskbits=$3
+
+ # we make sure the interface is up first
+ /sbin/ip link set $iface up || {
+ echo "`/bin/date` Failed to bringup interface $iface"
+ exit 1
+ }
+ /sbin/ip addr add $ip/$maskbits dev $iface || {
+ echo "`/bin/date` Failed to add $ip/$maskbits on dev $iface"
+ exit 1
+ }
+
+ # flush our route cache
+ echo 1 > /proc/sys/net/ipv4/route/flush
+ ;;
+
+
+ ##################################################
+ # called when ctdbd wants to release an IP address
+ releaseip)
+ if [ $# != 3 ]; then
+ echo "`/bin/date` must supply interface, IP and maskbits"
+ exit 1
+ fi
+ iface=$1
+ ip=$2
+ maskbits=$3
+ /sbin/ip addr del $ip dev $iface || {
+ echo "`/bin/date` Failed to del $ip on dev $iface"
+ exit 1
+ }
+
+ # flush our route cache
+ echo 1 > /proc/sys/net/ipv4/route/flush
+ ;;
+
+
+ ###########################################
+ # called when ctdbd has finished a recovery
+ recovered)
+ ;;
+
+ ####################################
+ # called when ctdbd is shutting down
+ shutdown)
+ ;;
+
+esac
+
+exit 0
. /etc/ctdb/functions
loadconfig nfs
-[ -z $CTDB_MANAGES_NFS ] && exit 0
-[ $CTDB_MANAGES_NFS != "yes" ] && exit 0
+[ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
. /etc/ctdb/functions
loadconfig nfs
-[ -z $CTDB_MANAGES_NFS ] && exit 0
-[ $CTDB_MANAGES_NFS != "yes" ] && exit 0
+[ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
cmd="$1"
shift
%{_sysconfdir}/ctdb/events
%{_sysconfdir}/ctdb/functions
-%{_sysconfdir}/ctdb/events.d/samba
-%{_sysconfdir}/ctdb/events.d/nfslock
-%{_sysconfdir}/ctdb/events.d/nfs
+%{_sysconfdir}/ctdb/events.d/10.interface
+%{_sysconfdir}/ctdb/events.d/50.samba
+%{_sysconfdir}/ctdb/events.d/59.nfslock
+%{_sysconfdir}/ctdb/events.d/60.nfs
%{_sysconfdir}/ctdb/statd-callout
%{_sbindir}/ctdbd
%{_bindir}/ctdb
printf("Number of nodes:%d\n", nodemap->num);
for(i=0;i<nodemap->num;i++){
- printf("vnn:%d %16s %s%s\n", nodemap->nodes[i].vnn,
+ printf("vnn:%d %-16s %s%s\n", nodemap->nodes[i].vnn,
inet_ntoa(nodemap->nodes[i].sin.sin_addr),
nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED?
"CONNECTED":"UNAVAILABLE",