X-Git-Url: http://git.samba.org/?p=metze%2Fctdb%2Fwip.git;a=blobdiff_plain;f=config%2Fctdb.init;h=7dfdd26639c70cb4fe29a30cf5a28a05cb630d70;hp=67747fd149da73f95a2d84d146b5fa4d1249cbdf;hb=dc2d0d0e559308ad2676f9ad973746c147d65eb9;hpb=ffb911896704ddf6bd5a66e43ba2ae8c382e68de diff --git a/config/ctdb.init b/config/ctdb.init index 67747fd1..7dfdd266 100755 --- a/config/ctdb.init +++ b/config/ctdb.init @@ -65,7 +65,7 @@ build_ctdb_options () { # then return [ -z "$2" -o \( -n "$3" -a "$3" != "$2" \) ] && return - val="$2" + val="'$2'" case "$1" in --*) sep="=" ;; -*) sep=" " ;; @@ -102,14 +102,48 @@ build_ctdb_options () { maybe_set "--no-lmaster" "$CTDB_CAPABILITY_LMASTER" "no" maybe_set "--lvs --single-public-ip" "$CTDB_LVS_PUBLIC_IP" maybe_set "--script-log-level" "$CTDB_SCRIPT_LOG_LEVEL" + maybe_set "--log-ringbuf-size" "$CTDB_LOG_RINGBUF_SIZE" maybe_set "--syslog" "$CTDB_SYSLOG" "yes" + maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS" +} + +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` + test x"$OK" = x"1" || { + return 1; + } + + return 0; + } + + /usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || { + return $?; + } + + return 0; } check_persistent_databases () { PERSISTENT_DB_DIR="${CTDB_DBDIR:-/var/ctdb}/persistent" mkdir -p $PERSISTENT_DB_DIR 2>/dev/null + local ERRCOUNT=$CTDB_MAX_PERSISTENT_CHECK_ERRORS + + test -z "$ERRCOUNT" && { + ERRCOUNT="0" + } + test x"$ERRCOUNT" != x"0" && { + return 0; + } for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do - /usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || { + check_tdb $PDBASE || { echo "Persistent database $PDBASE is corrupted! CTDB will not start." return 1 } @@ -137,14 +171,14 @@ start() { ctdb ping >/dev/null 2>&1 && { echo $"CTDB is already running" - return 1 + return 0 } build_ctdb_options check_persistent_databases || return $? - if [ yes == "$CTDB_SUPPRESS_COREFILE" ]; then + if [ "$CTDB_SUPPRESS_COREFILE" = "yes" ]; then ulimit -c 0 else ulimit -c unlimited @@ -152,25 +186,26 @@ start() { case $init_style in valgrind) - valgrind -q --log-file=/var/log/ctdb_valgrind \ - $ctdbd --nosetsched $CTDB_OPTIONS + eval valgrind -q --log-file=/var/log/ctdb_valgrind \ + $ctdbd --valgrinding "$CTDB_OPTIONS" RETVAL=$? echo ;; suse) - startproc $ctdbd $CTDB_OPTIONS + eval startproc $ctdbd "$CTDB_OPTIONS" rc_status -v RETVAL=$? ;; redhat) - daemon $ctdbd $CTDB_OPTIONS + eval $ctdbd "$CTDB_OPTIONS" RETVAL=$? + [ $RETVAL -eq 0 ] && success || failure echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1 ;; debian) - start-stop-daemon --start --quiet --background \ - --exec $ctdbd -- $CTDB_OPTIONS + eval start-stop-daemon --start --quiet --background \ + --exec $ctdbd -- "$CTDB_OPTIONS" RETVAL=$? ;; esac @@ -180,7 +215,7 @@ start() { set_ctdb_variables return $RETVAL -} +} stop() { echo -n $"Shutting down ctdbd service: " @@ -227,7 +262,7 @@ stop() { restart() { stop start -} +} status() { echo -n $"Checking for ctdbd service: " @@ -240,7 +275,13 @@ status() { rc_status -v ;; redhat) - echo "" + if [ -f /var/lock/subsys/ctdb ]; then + echo $"ctdb dead but subsys locked" + RETVAL=2 + else + echo $"ctdb is stopped" + RETVAL=3 + fi ;; esac return $RETVAL @@ -257,13 +298,13 @@ case "$1" in stop) stop ;; - restart|reload) + restart|reload|force-reload) restart ;; status) status ;; - condrestart) + condrestart|try-restart) ctdb status > /dev/null && restart || : ;; cron) @@ -271,7 +312,7 @@ case "$1" in ctdb status > /dev/null || restart ;; *) - echo $"Usage: $0 {start|stop|restart|status|cron|condrestart}" + echo $"Usage: $0 {start|stop|restart|reload|force-reload|status|cron|condrestart|try-restart}" exit 1 esac