The branch, master has been updated via 1cdaaa0a3f53d1b075340a33dfdc42b534e99187 (commit) via a9831070344a6dcf46c55250f9d74a5870f37dfe (commit) from 3044d07da2a58260fa06bf489890b279bcf3ec39 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 1cdaaa0a3f53d1b075340a33dfdc42b534e99187 Author: Ronnie Sahlberg <ronniesahlb...@gmail.com> Date: Thu Apr 22 14:02:11 2010 +1000 add an example script that can be called from crontab to cleanup and release public ip addresses if ctdbd is no longer running commit a9831070344a6dcf46c55250f9d74a5870f37dfe Author: Ronnie Sahlberg <ronniesahlb...@gmail.com> Date: Thu Apr 22 14:22:46 2010 +1000 add a missing || to make the 10.interface script not fail with a syntax error ----------------------------------------------------------------------- Summary of changes: Makefile.in | 1 + config/ctdb-crash-cleanup.sh | 35 +++++++++++++++++++++++++++++++++++ config/events.d/10.interface | 2 +- packaging/RPM/ctdb.spec.in | 1 + 4 files changed, 38 insertions(+), 1 deletions(-) create mode 100755 config/ctdb-crash-cleanup.sh Changeset truncated at 500 lines: diff --git a/Makefile.in b/Makefile.in index ad34f68..d9ecfa7 100755 --- a/Makefile.in +++ b/Makefile.in @@ -236,6 +236,7 @@ install: all if [ -f doc/ctdbd.1 ];then ${INSTALLCMD} -m 644 doc/ctdbd.1 $(DESTDIR)$(mandir)/man1; fi if [ -f doc/onnode.1 ];then ${INSTALLCMD} -m 644 doc/onnode.1 $(DESTDIR)$(mandir)/man1; fi if [ ! -f $(DESTDIR)$(etcdir)/ctdb/notify.sh ];then ${INSTALLCMD} -m 755 config/notify.sh $(DESTDIR)$(etcdir)/ctdb; fi + if [ ! -f $(DESTDIR)$(etcdir)/ctdb/ctdb-crash-cleanup.sh ];then ${INSTALLCMD} -m 755 config/ctdb-crash-cleanup.sh $(DESTDIR)$(etcdir)/ctdb; fi test: all tests/run_tests.sh diff --git a/config/ctdb-crash-cleanup.sh b/config/ctdb-crash-cleanup.sh new file mode 100755 index 0000000..ca6a838 --- /dev/null +++ b/config/ctdb-crash-cleanup.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# This script can be called from a cronjob to automatically drop/release +# all public ip addresses if CTDBD has crashed or stopped running. +# + +[ -z "$CTDB_BASE" ] && { + CTDB_BASE=/etc/ctdb +} + +[ -z "$CTDB_PUBLIC_ADDRESSES" ] && { + CTDB_PUBLIC_ADDRESSES=$CTDB_BASE/public_addresses +} + +[ ! -f "$CTDB_PUBLIC_ADDRESSES" ] && { + echo "No public addresses file found. Cant cleanup." + exit 1 +} + +# if ctdb is running, just return +ctdb status 2>/dev/null && { + exit 0 +} + +cat "$CTDB_PUBLIC_ADDRESSES" | cut -d/ -f1 | while read _IP; do + _IP_HELD=`/sbin/ip addr show | grep "inet $_IP/"` + [ -z "$_IP_HELD" ] || { + _IFACE=`echo $_IP_HELD | sed -e "s/.*\s//"` + _NM=`echo $_IP_HELD | sed -e "s/.*$_IP\///" -e "s/\s.*//"` + logger "Removing public address $_IP/$_NM from device $_IFACE" + /sbin/ip addr del $_IP/$_NM dev $_IFACE + } +done + + diff --git a/config/events.d/10.interface b/config/events.d/10.interface index fdb1557..1e7f94b 100755 --- a/config/events.d/10.interface +++ b/config/events.d/10.interface @@ -80,7 +80,7 @@ monitor_interfaces() # we dont know how to test ib links ;; *) - [ -z "$IFACE" ] { + [ -z "$IFACE" ] || { [ "$(basename $(readlink /sys/class/net/$IFACE/device/driver))" = virtio_net ] || ethtool $IFACE | grep -q 'Link detected: yes' || { # On some systems, this is not successful when a diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in index 1c82285..f23943f 100644 --- a/packaging/RPM/ctdb.spec.in +++ b/packaging/RPM/ctdb.spec.in @@ -88,6 +88,7 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) %{_sysconfdir}/sysconfig/ctdb %config(noreplace) %{_sysconfdir}/ctdb/notify.sh +%config(noreplace) %{_sysconfdir}/ctdb/ctdb-crash-cleanup.sh %config(noreplace) %{_sysconfdir}/ctdb/functions %attr(755,root,root) %{initdir}/ctdb -- CTDB repository