[Pkg-samba-maint] r2947 - trunk/ctdb/debian
mparent-guest at alioth.debian.org
mparent-guest at alioth.debian.org
Fri Jul 17 21:05:59 UTC 2009
Author: mparent-guest
Date: 2009-07-17 21:05:58 +0000 (Fri, 17 Jul 2009)
New Revision: 2947
Modified:
trunk/ctdb/debian/changelog
trunk/ctdb/debian/ctdb.init
Log:
New upstream release 1.0.87
- update ctdb.init:
+ use var $ctdb instead of $DAEMON to match upstream
+ Move building of CTDB_OPTIONS to new function build_ctdb_options()
and have it use a helper function for readability (1.0.87)
+ New functions check_persistent_databases() and set_ctdb_variables()
(1.0.87)
+ Make it possible to start the daemon in STOPPED mode (1.0.87)
Modified: trunk/ctdb/debian/changelog
===================================================================
--- trunk/ctdb/debian/changelog 2009-07-17 18:38:20 UTC (rev 2946)
+++ trunk/ctdb/debian/changelog 2009-07-17 21:05:58 UTC (rev 2947)
@@ -1,12 +1,18 @@
-ctdb (1.0.86-1) UNRELEASED; urgency=low
+ctdb (1.0.87-1) UNRELEASED; urgency=low
* new upstream release
- update ctdb.init:
- + allow starting without a reclock file
+ + allow starting without a reclock file (1.0.86)
+ + use var $ctdb instead of $DAEMON to match upstream
+ + Move building of CTDB_OPTIONS to new function build_ctdb_options()
+ and have it use a helper function for readability (1.0.87)
+ + New functions check_persistent_databases() and set_ctdb_variables()
+ (1.0.87)
+ + Make it possible to start the daemon in STOPPED mode (1.0.87)
* 30_outdated-autotools.diff: Correct outdated config.{sub,guess}
(Closes: #536256)
- -- Mathieu Parent <math.parent at gmail.com> Mon, 13 Jul 2009 21:23:58 +0200
+ -- Mathieu Parent <math.parent at gmail.com> Fri, 17 Jul 2009 22:40:21 +0200
ctdb (1.0.85-1) unstable; urgency=low
Modified: trunk/ctdb/debian/ctdb.init
===================================================================
--- trunk/ctdb/debian/ctdb.init 2009-07-17 18:38:20 UTC (rev 2946)
+++ trunk/ctdb/debian/ctdb.init 2009-07-17 21:05:58 UTC (rev 2947)
@@ -22,72 +22,69 @@
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=${CTDBD:-/usr/sbin/ctdbd}
NAME=ctdb
DESC="Clustered TDB"
-test -x $DAEMON || exit 0
-
#LSB
if [ -f /lib/lsb/init-functions ] ; then
. /lib/lsb/init-functions
fi
if ! type 'log_daemon_msg' >/dev/null; then
- log_daemon_msg () {
- if [ -z "${1:-}" ]; then
- return 1
- fi
+ log_daemon_msg () {
+ if [ -z "${1:-}" ]; then
+ return 1
+ fi
- if [ -z "${2:-}" ]; then
- echo -n "$1:"
- return
- fi
-
- echo -n "$1: $2"
- }
+ if [ -z "${2:-}" ]; then
+ echo -n "$1:"
+ return
+ fi
+
+ echo -n "$1: $2"
+ }
fi
if ! type 'log_progress_msg' >/dev/null; then
- log_progress_msg () {
- if [ -z "${1:-}" ]; then
- return 1
- fi
- echo -n " $@"
- }
+ log_progress_msg () {
+ if [ -z "${1:-}" ]; then
+ return 1
+ fi
+ echo -n " $@"
+ }
fi
if ! type 'log_end_msg' >/dev/null; then
- log_end_msg () {
- # If no arguments were passed, return
- if [ -z "${1:-}" ]; then
- return 1
- fi
+ log_end_msg () {
+ # If no arguments were passed, return
+ if [ -z "${1:-}" ]; then
+ return 1
+ fi
- retval=$1
+ retval=$1
- if [ $1 -eq 0 ]; then
- echo "."
- elif [ $1 -eq 255 ]; then
- /bin/echo -e " (warning)."
- else
- /bin/echo -e " failed!"
- fi
- return $retval
- }
+ if [ $1 -eq 0 ]; then
+ echo "."
+ elif [ $1 -eq 255 ]; then
+ /bin/echo -e " (warning)."
+ else
+ /bin/echo -e " failed!"
+ fi
+ return $retval
+ }
fi
# Source function library.
if [ -f /etc/init.d/functions ] ; then
- . /etc/init.d/functions
+ . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
- . /etc/rc.d/init.d/functions
+ . /etc/rc.d/init.d/functions
fi
#gettext
if [ -f /usr/bin/gettext.sh ] ; then
- . /usr/bin/gettext.sh
+ . /usr/bin/gettext.sh
fi
if ! type 'eval_gettext' >/dev/null; then
eval_gettext() {
- echo -n "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1")
+ echo -n "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1")
}
fi
@@ -110,148 +107,175 @@
set -e
-# check networking is up (for redhat)
-[ "${NETWORKING}" = "no" ] && exit 0
-
[ -z "$CTDB_RECOVERY_LOCK" ] && {
echo "No recovery lock specified. Starting CTDB without split brain prevention"
}
-# build up CTDB_OPTIONS variable from optional parameters
-[ -z "$CTDB_RECOVERY_LOCK" ] || CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
-[ -z "$CTDB_LOGFILE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$CTDB_LOGFILE"
-[ -z "$CTDB_NODES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$CTDB_NODES"
-[ -z "$CTDB_SOCKET" ] || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
-[ -z "$CTDB_PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$CTDB_PUBLIC_ADDRESSES"
-[ -z "$CTDB_PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$CTDB_PUBLIC_INTERFACE"
-[ -z "$CTDB_DBDIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$CTDB_DBDIR"
-[ -z "$CTDB_DBDIR_PERSISTENT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir-persistent=$CTDB_DBDIR_PERSISTENT"
-[ -z "$CTDB_EVENT_SCRIPT_DIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script-dir $CTDB_EVENT_SCRIPT_DIR"
-[ -z "$CTDB_TRANSPORT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --transport $CTDB_TRANSPORT"
-[ -z "$CTDB_DEBUGLEVEL" ] || CTDB_OPTIONS="$CTDB_OPTIONS -d $CTDB_DEBUGLEVEL"
-[ -z "$CTDB_NOTIFY_SCRIPT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --notification-script=$CTDB_NOTIFY_SCRIPT"
-[ -z "$CTDB_START_AS_DISABLED" ] || [ "$CTDB_START_AS_DISABLED" != "yes" ] || {
- CTDB_OPTIONS="$CTDB_OPTIONS --start-as-disabled"
-}
-[ -z "$CTDB_CAPABILITY_RECMASTER" ] || [ "$CTDB_CAPABILITY_RECMASTER" != "no" ] || {
- CTDB_OPTIONS="$CTDB_OPTIONS --no-recmaster"
-}
-[ -z "$CTDB_CAPABILITY_LMASTER" ] || [ "$CTDB_CAPABILITY_LMASTER" != "no" ] || {
- CTDB_OPTIONS="$CTDB_OPTIONS --no-lmaster"
-}
-[ -z "$CTDB_LVS_PUBLIC_IP" ] || {
- CTDB_OPTIONS="$CTDB_OPTIONS --lvs --single-public-ip=$CTDB_LVS_PUBLIC_IP"
-}
-[ -z "$CTDB_SCRIPT_LOG_LEVEL" ] || {
- CTDB_OPTIONS="$CTDB_OPTIONS --script-log-level=$CTDB_SCRIPT_LOG_LEVEL"
-}
+# check networking is up (for redhat)
+[ "$NETWORKING" = "no" ] && exit 0
detect_init_style
export CTDB_INIT_STYLE
-if [ "x$CTDB_VALGRIND" = "xyes" ]; then
- init_style="valgrind"
+ctdbd=${CTDBD:-/usr/sbin/ctdbd}
+
+test -x $ctdbd || exit 0
+
+if [ "$CTDB_VALGRIND" = "yes" ]; then
+ init_style="valgrind"
else
- init_style="$CTDB_INIT_STYLE"
+ init_style="$CTDB_INIT_STYLE"
fi
+build_ctdb_options () {
+ [ -z "$CTDB_RECOVERY_LOCK" ] && {
+ echo "You must configure the location of the CTDB_RECOVERY_LOCK"
+ exit 1
+ }
+
+ maybe_set () {
+ # If the 2nd arg is null then return - don't set anything.
+ # Else if the 3rd arg is set and it doesn't match the 2nd arg
+ # then return
+ [ -z "$2" -o \( -n "$3" -a "$3" != "$2" \) ] && return
+
+ val="$2"
+ case "$1" in
+ --*) sep="=" ;;
+ -*) sep=" " ;;
+ esac
+ # For these options we're only passing a value-less flag.
+ [ -n "$3" ] && {
+ val=""
+ sep=""
+ }
+
+ CTDB_OPTIONS="${CTDB_OPTIONS}${CTDB_OPTIONS:+ }${1}${sep}${val}"
+ }
+
+ maybe_set "--reclock" "$CTDB_RECOVERY_LOCK"
+
+ # build up CTDB_OPTIONS variable from optional parameters
+ maybe_set "--logfile" "$CTDB_LOGFILE"
+ maybe_set "--nlist" "$CTDB_NODES"
+ maybe_set "--socket" "$CTDB_SOCKET"
+ maybe_set "--public-addresses" "$CTDB_PUBLIC_ADDRESSES"
+ maybe_set "--public-interface" "$CTDB_PUBLIC_INTERFACE"
+ maybe_set "--dbdir" "$CTDB_DBDIR"
+ maybe_set "--dbdir-persistent" "$CTDB_DBDIR_PERSISTENT"
+ maybe_set "--event-script-dir" "$CTDB_EVENT_SCRIPT_DIR"
+ maybe_set "--transport" "$CTDB_TRANSPORT"
+ maybe_set "-d" "$CTDB_DEBUGLEVEL"
+ maybe_set "--notification-script" "$CTDB_NOTIFY_SCRIPT"
+ maybe_set "--start-as-disabled" "$CTDB_START_AS_DISABLED" "yes"
+ maybe_set "--start-as-stopped " "$CTDB_START_AS_STOPPED" "yes"
+ maybe_set "--no-recmaster" "$CTDB_CAPABILITY_RECMASTER" "no"
+ 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"
+}
+
+check_persistent_databases () {
+ case $init_style in
+ ubuntu) PERSISTENT_DB_DIR="${CTDB_DBDIR:-/var/lib/ctdb}/persistent" ;;
+ *) PERSISTENT_DB_DIR="${CTDB_DBDIR:-/var/ctdb}/persistent" ;;
+ esac
+ mkdir -p $PERSISTENT_DB_DIR 2>/dev/null
+ for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
+ /usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
+ echo "Persistent database $PDBASE is corrupted! CTDB will not start."
+ return 1
+ }
+ done
+}
+
+set_ctdb_variables () {
+ # set any tunables from the config file
+ set | grep ^CTDB_SET_ | cut -d_ -f3- |
+ while read v; do
+ varname=`echo $v | cut -d= -f1`
+ value=`echo $v | cut -d= -f2`
+ ctdb setvar $varname $value || RETVAL=1
+ done || exit 1
+}
+
set_retval() {
- return $1
+ return $1
}
running() {
- pkill -0 -f $DAEMON || return 1
+ pkill -0 -f $ctdbd || return 1
return 0
}
start_server() {
- # check all persistent databases that they look ok
- case $init_style in
- ubuntu)
- PERSISTENT_DB_DIR="/var/lib/ctdb/persistent"
+ build_ctdb_options
+
+ check_persistent_databases || return $?
+
+ case $init_style in
+ valgrind)
+ valgrind -q --log-file=/var/log/ctdb_valgrind \
+ $ctdbd --nosetsched $CTDB_OPTIONS
+ RETVAL=$?
+ echo
;;
- *)
- PERSISTENT_DB_DIR="/var/ctdb/persistent"
+ suse)
+ startproc $ctdbd $CTDB_OPTIONS
+ rc_status -v
+ RETVAL=$?
;;
- esac
- [ -z "$CTDB_DBDIR" ] || {
- PERSISTENT_DB_DIR="$CTDB_DBDIR/persistent"
- }
- mkdir -p $PERSISTENT_DB_DIR 2>/dev/null
- for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
- /usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
- echo "Persistent database $PDBASE is corrupted! CTDB will not start."
- return 1
- }
- done
+ redhat)
+ daemon $ctdbd $CTDB_OPTIONS
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
+ ;;
+ ubuntu)
+ start-stop-daemon --start --quiet --background \
+ --exec $ctdbd -- $CTDB_OPTIONS
+ RETVAL=$?
+ ;;
+ esac
- case $init_style in
- valgrind)
- valgrind -q --log-file=/var/log/ctdb_valgrind \
- $DAEMON --nosetsched $CTDB_OPTIONS
- RETVAL=0
- ;;
- suse)
- startproc $DAEMON $CTDB_OPTIONS
- rc_status -v
- RETVAL=$?
- ;;
- redhat)
- daemon $DAEMON $CTDB_OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
- ;;
- ubuntu)
- start-stop-daemon --start --quiet --background \
- --exec $DAEMON -- $CTDB_OPTIONS
- RETVAL=$?
- ;;
- esac
+ sleep 1
- sleep 1
- # set any tunables from the config file
- set | grep ^CTDB_SET_ | cut -d_ -f3- |
- while read v; do
- varname=`echo $v | cut -d= -f1`
- value=`echo $v | cut -d= -f2`
- ctdb setvar $varname $value || RETVAL=1
- done || exit 1
+ set_ctdb_variables
- return $RETVAL
+ return $RETVAL
}
stop_server() {
- ctdb shutdown >/dev/null 2>&1
- RETVAL=$?
- count=0
- if [ "$init_style" = "ubuntu" ]; then
- start-stop-daemon --stop --quiet --exec $DAEMON
- RETVAL=$?
- fi
- while pkill -0 -f $DAEMON ; do
- sleep 1
- count=`expr $count + 1`
- [ $count -gt 10 ] && {
- eval_gettext "killing ctdbd "
- pkill -9 -f $DAEMON
- pkill -9 -f $CTDB_BASE/events.d/
- }
- done
- case $init_style in
- suse)
- # re-set the return code to the recorded RETVAL
- # in order to print the correct status message
- set_retval $RETVAL
- rc_status -v
- ;;
- redhat)
- echo
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
- echo ""
- ;;
- esac
- return $RETVAL
+ ctdb shutdown >/dev/null 2>&1
+ RETVAL=$?
+ count=0
+ if [ "$init_style" = "ubuntu" ]; then
+ start-stop-daemon --stop --quiet --exec $ctdbd
+ RETVAL=$?
+ fi
+ while pkill -0 -f $ctdbd ; do
+ sleep 1
+ count=`expr $count + 1`
+ [ $count -gt 10 ] && {
+ eval_gettext "killing ctdbd "
+ pkill -9 -f $ctdbd
+ pkill -9 -f $CTDB_BASE/events.d/
+ }
+ done
+ case $init_style in
+ suse)
+ # re-set the return code to the recorded RETVAL in order
+ # to print the correct status message
+ set_retval $RETVAL
+ rc_status -v
+ ;;
+ redhat)
+ echo
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
+ echo ""
+ ;;
+ esac
+ return $RETVAL
}
case "$1" in
@@ -271,7 +295,7 @@
# after we did
log_end_msg 1
fi
- ;;
+ ;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if running ; then
@@ -284,20 +308,20 @@
log_end_msg 0
exit 0
fi
- ;;
+ ;;
restart|reload|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
running && stop_server
start_server
running
log_end_msg $?
- ;;
+ ;;
status)
log_daemon_msg "Checking status of $DESC" "$NAME"
if running ; then
log_progress_msg "running"
- echo
- ctdb status
+ echo
+ ctdb status
log_end_msg 0
else
log_progress_msg "not running"
@@ -312,7 +336,7 @@
start_server
log_end_msg $?
fi
- ;;
+ ;;
cron)
# used from cron to auto-restart ctdb
if ! running ; then
@@ -328,10 +352,10 @@
fi
;;
*)
- eval_gettext "Usage: $0 {start|stop|restart|status|cron|condrestart}" >&2
- echo >&2
- exit 1
- ;;
+ eval_gettext "Usage: $0 {start|stop|restart|status|cron|condrestart}" >&2
+ echo >&2
+ exit 1
+ ;;
esac
exit $?
More information about the Pkg-samba-maint
mailing list