]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
split out the basic interface handling, and run event scripts in a deterministic...
authorAndrew Tridgell <tridge@samba.org>
Mon, 4 Jun 2007 05:09:03 +0000 (15:09 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 4 Jun 2007 05:09:03 +0000 (15:09 +1000)
(This used to be ctdb commit 399e993a4a233a5953e1e7264141e5c7c8c8c711)

ctdb/Makefile.in
ctdb/config/events
ctdb/config/events.d/10.interface [new file with mode: 0755]
ctdb/config/events.d/50.samba [moved from ctdb/config/events.d/samba with 100% similarity, mode: 0755]
ctdb/config/events.d/59.nfslock [moved from ctdb/config/events.d/nfslock with 93% similarity, mode: 0755]
ctdb/config/events.d/60.nfs [moved from ctdb/config/events.d/nfs with 91% similarity, mode: 0755]
ctdb/packaging/RPM/ctdb.spec
ctdb/tools/ctdb_control.c

index 2770f8794f4cc1fe6d8ef48b234a41b2f44b3766..b475f528cc89695e56b75ae6f431f711ddfd13e4 100644 (file)
@@ -111,9 +111,10 @@ install: all
        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
index 9b0126d35d2a91d4c3d5f31dd9c266a5f7ec30c5..24b018446d6199072bbbf34f6ab966a2c5996ea7 100755 (executable)
@@ -1,87 +1,34 @@
 #!/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
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
new file mode 100755 (executable)
index 0000000..ea28eb7
--- /dev/null
@@ -0,0 +1,78 @@
+#!/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
old mode 100644 (file)
new mode 100755 (executable)
similarity index 100%
rename from ctdb/config/events.d/samba
rename to ctdb/config/events.d/50.samba
old mode 100644 (file)
new mode 100755 (executable)
similarity index 93%
rename from ctdb/config/events.d/nfslock
rename to ctdb/config/events.d/59.nfslock
index 72279b2..b030ab5
@@ -4,8 +4,7 @@
 . /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
 
old mode 100644 (file)
new mode 100755 (executable)
similarity index 91%
rename from ctdb/config/events.d/nfs
rename to ctdb/config/events.d/60.nfs
index 9651996..d0e8926
@@ -4,8 +4,7 @@
 . /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
index ab6a0e3c9e4c1690c414a1ed371b5a7ea0a5a76c..500f636566abbf0320843bb41d2aa681186c3230 100644 (file)
@@ -93,9 +93,10 @@ fi
 
 %{_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
index 6720d5119389de097a16a03209fe8b7787a0748c..bfaa689009c0f07e962d2000413bfab3343fc463 100644 (file)
@@ -301,7 +301,7 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
 
        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",