[Pkg-samba-maint] r3923 - trunk/ctdb/debian

sathieu at alioth.debian.org sathieu at alioth.debian.org
Wed Sep 28 07:22:19 UTC 2011


Author: sathieu
Date: 2011-09-28 07:22:18 +0000 (Wed, 28 Sep 2011)
New Revision: 3923

Modified:
   trunk/ctdb/debian/ctdb.init
Log:
ctdb.init: sync with upstream:

- warn for tdbtool or tdbdump
- make sure we drop any ips that might still be held if previous instance of ctdb got killed with -9 or similar
- fix missing shell escape

Modified: trunk/ctdb/debian/ctdb.init
===================================================================
--- trunk/ctdb/debian/ctdb.init	2011-09-27 07:01:16 UTC (rev 3922)
+++ trunk/ctdb/debian/ctdb.init	2011-09-28 07:22:18 UTC (rev 3923)
@@ -19,7 +19,6 @@
 # Description:         initscript for the ctdb service
 ### END INIT INFO
 
-
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
 NAME=ctdb
@@ -78,7 +77,7 @@
     . /etc/rc.d/init.d/functions
 fi
 
-#gettext
+# gettext
 if [ -f /usr/bin/gettext.sh ] ; then
     . /usr/bin/gettext.sh
 fi
@@ -88,6 +87,7 @@
     }
 fi
 
+# rc.status
 [ -f /etc/rc.status ] && {
     . /etc/rc.status
     rc_reset
@@ -180,13 +180,11 @@
 check_tdb () {
 	local PDBASE=$1
 
-	local TDBTOOL_HAS_CHECK=`echo "help" | /usr/bin/tdbtool | grep check | wc -l`
-
 	test x"$TDBTOOL_HAS_CHECK" = x"1" && {
 		#
 		# Note tdbtool always exits with 0
 		#
-		local OK=`/usr/bin/tdbtool $PDBASE check | grep "Database integrity is OK" | wc -l`
+		local OK=`tdbtool $PDBASE check | grep "Database integrity is OK" | wc -l`
 		test x"$OK" = x"1" || {
 			return 1;
 		}
@@ -194,7 +192,7 @@
 		return 0;
 	}
 
-	/usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
+	tdbdump $PDBASE >/dev/null 2>/dev/null || {
 		return $?;
 	}
 
@@ -215,6 +213,44 @@
     test x"$ERRCOUNT" != x"0" && {
 	return 0;
     }
+
+    if command -v tdbtool >/dev/null 2>&1; then
+        HAVE_TDBTOOL=1
+    else
+        HAVE_TDBTOOL=0
+    fi
+
+    if test x"$HAVE_TDBTOOL" = x"1" ; then
+        TDBTOOL_HAS_CHECK=`echo "help" | tdbtool | grep check | wc -l`
+    else
+        TDBTOOL_HAS_CHECK=0
+    fi
+
+    if command -v tdbdump >/dev/null 2>&1; then
+        HAVE_TDBDUMP=1
+    else
+        HAVE_TDBDUMP=0
+    fi
+
+    if test x"$HAVE_TDBDUMP" = x"0" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
+        echo "WARNING: Cannot check persistent databases since"
+        echo "neither 'tdbdump' nor 'tdbtool check' is available."
+        echo "Consider installing tdbtool or at least tdbdump!"
+        return 0
+    fi
+
+    if test x"$HAVE_TDBDUMP" = x"1" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
+        if test x"$HAVE_TDBTOOL" = x"0"; then
+            echo "WARNING: 'tdbtool' is not available. Using 'tdbdump' to"
+            echo "check the persistent databases."
+            echo "Consider installing a recent 'tdbtool' for better checks!"
+        else
+            echo "WARNING: The installed 'tdbtool' does not offer the 'check'"
+            echo "subcommand. Using 'tdbdump' for persistent database checks."
+            echo "Consider updating 'tdbtool' for better checks!"
+        fi
+    fi
+
     for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
 	check_tdb $PDBASE || {
 	    echo "Persistent database $PDBASE is corrupted! CTDB will not start."
@@ -250,6 +286,16 @@
     done
 }
 
+drop_all_public_ips() {
+    [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
+	return
+    }
+
+    cat $CTDB_PUBLIC_ADDRESSES | while read IP IFACE REST; do
+	ip addr del $IP dev $IFACE >/dev/null 2>/dev/null
+    done
+}
+
 running() {
     pkill -0 -f $ctdbd || return 1
     return 0
@@ -258,6 +304,10 @@
 start_server() {
     build_ctdb_options
 
+    # make sure we drop any ips that might still be held if previous
+    # instance of ctdb got killed with -9 or similar
+    drop_all_public_ips
+
     check_persistent_databases || return $?
 
     if [ "$CTDB_SUPPRESS_COREFILE" = "yes" ]; then
@@ -419,7 +469,7 @@
         fi
         ;;
     *)
-        eval_gettext "Usage: $0 {start|stop|restart|status|cron|condrestart}" >&2
+        eval_gettext "Usage: \$0 {start|stop|restart|status|cron|condrestart}" >&2
         echo >&2
         exit 1
         ;;





More information about the Pkg-samba-maint mailing list