[Pkg-samba-maint] r2094 - trunk/ctdb/debian
mparent-guest at alioth.debian.org
mparent-guest at alioth.debian.org
Fri Aug 1 19:47:08 UTC 2008
Author: mparent-guest
Date: 2008-08-01 19:47:08 +0000 (Fri, 01 Aug 2008)
New Revision: 2094
Modified:
trunk/ctdb/debian/ctdb.init
Log:
One more step to approach upstream init script
Modified: trunk/ctdb/debian/ctdb.init
===================================================================
--- trunk/ctdb/debian/ctdb.init 2008-08-01 18:47:59 UTC (rev 2093)
+++ trunk/ctdb/debian/ctdb.init 2008-08-01 19:47:08 UTC (rev 2094)
@@ -36,12 +36,24 @@
NAME=ctdb # Introduce the short server's name here
DESC="Clustered TDB" # Introduce a short description here
-
test -x $DAEMON || exit 0
test -x $DAEMON_WRAPPER || exit 0
-. /lib/lsb/init-functions
+# Source function library.
+if [ -f /lib/lsb/init-functions ] ; then
+ . /lib/lsb/init-functions
+elif [ -f /etc/init.d/functions ] ; then
+ . /etc/init.d/functions
+elif [ -f /etc/rc.d/init.d/functions ] ; then
+ . /etc/rc.d/init.d/functions
+fi
+[ -f /etc/rc.status ] && {
+ . /etc/rc.status
+ rc_reset
+ LC_ALL=en_US.UTF-8
+}
+
# Avoid using root's TMPDIR
unset TMPDIR
@@ -50,16 +62,12 @@
}
. $CTDB_BASE/functions
+loadconfig network
loadconfig ctdb
-# Default options, these can be overriden by the information
-# at /etc/default/$NAME
-CTDB_OPTIONS="" # Additional options given to the server
+# check networking is up (for redhat)
+[ "${NETWORKING}" = "no" ] && exit 0
-LOGFILE=$LOGDIR/$NAME.log # Server logfile
-#DAEMONUSER=ctdb # Users to run the daemons as. If this value
- # is set start-stop-daemon will chuid the server
-
[ -z "$CTDB_RECOVERY_LOCK" ] && {
echo "You must configure the location of the CTDB_RECOVERY_LOCK"
exit 1
@@ -91,20 +99,18 @@
CTDB_OPTIONS="$CTDB_OPTIONS --lvs"
}
-# Check that the user exists (if we set a user)
-# Does the user exist?
-if [ -n "$DAEMONUSER" ] ; then
- if getent passwd | grep -q "^$DAEMONUSER:"; then
- # Obtain the uid and gid
- DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
- DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
+if [ "$CTDB_VALGRIND" = "yes" ]; then
+ init_style="valgrind"
+else if [ -x /sbin/startproc ]; then
+ init_style="suse"
+else if [ -x /sbin/start-stop-daemon ]; then
+ init_style="debian"
else
- log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
- exit 1
+ init_style="redhat"
fi
fi
+fi
-
set -e
running() {
@@ -113,34 +119,43 @@
}
start() {
- # check all persistent databases that they look ok
- PERSISTENT_DB_DIR="/var/lib/ctdb/persistent"
- [ -z "$CTDB_DBDIR" ] || {
- PERSISTENT_DB_DIR="$CTDB_DBDIR/persistent"
- }
- mkdir -p $PERSISTENT_DB_DIR 2>/dev/null
+ killall -q ctdbd
+
+ # check all persistent databases that they look ok
+ PERSISTENT_DB_DIR="/var/lib/ctdb/persistent"
+ [ -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
- # Start the process using the wrapper
- if [ "$CTDB_VALGRIND" = "yes" ]; then
- valgrind -q --log-file=/var/log/ctdb_valgrind \
- $DAEMON --nosetsched $CTDB_OPTIONS
- else if [ -z "$DAEMONUSER" ] ; then
- start-stop-daemon --start --quiet --background \
- --exec $DAEMON -- $CTDB_OPTIONS
- RETVAL=$?
- else
-# if we are using a daemonuser then change the user id
- start-stop-daemon --start --quiet --background \
- --chuid $DAEMONUSER \
- --exec $DAEMON -- $CTDB_OPTIONS
- RETVAL=$?
- fi
- fi
+ /usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
+ echo "Persistent database $PDBASE is corrupted! CTDB will not start."
+ return 1
+ }
+ done
+
+ case $init_style in
+ valgrind)
+ valgrind -q --log-file=/var/log/ctdb_valgrind /usr/sbin/ctdbd --nosetsched $CTDB_OPTIONS
+ RETVAL=0
+ ;;
+ suse)
+ startproc /usr/sbin/ctdbd $CTDB_OPTIONS
+ rc_status -v
+ RETVAL=$?
+ ;;
+ redhat)
+ daemon ctdbd $CTDB_OPTIONS
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
+ ;;
+ debian)
+ start-stop-daemon --start --quiet --background --exec /usr/sbin/ctdbd -- $CTDB_OPTIONS
+ RETVAL=$?
+ ;;
+ esac
+
sleep 1
# set any tunables from the config file
set | grep ^CTDB_SET_ | cut -d_ -f3- |
@@ -149,30 +164,23 @@
value=`echo $v | cut -d= -f2`
ctdb setvar $varname $value || RETVAL=1
done || exit 1
+
return $RETVAL
-}
+}
stop() {
-# Stop the process using the wrapper
- ctdb shutdown
+ ctdb shutdown
RETVAL=$?
- if [ "$CTDB_VALGRIND" = "yes" ]; then
+ count=0
+ if [ "$init_style" = "valgrind" ]; then
# very crude method
sleep 2
pkill -9 -f valgrind
- else if [ -z "$DAEMONUSER" ] ; then
- start-stop-daemon --stop --quiet \
- --exec $DAEMON
+ else if [ "$init_style" = "debian" ]; then
+ start-stop-daemon --stop --quiet --exec /usr/sbin/ctdbd
RETVAL=$?
- else
-# if we are using a daemonuser then look for process that match
- start-stop-daemon --stop --quiet \
- --user $DAEMONUSER \
- --exec $DAEMON
- RETVAL=$?
fi
fi
- count=0
while killall -q -0 ctdbd; do
sleep 1
count=`expr $count + 1`
@@ -182,10 +190,32 @@
pkill -9 -f $CTDB_BASE/events.d/
}
done
+ case $init_style in
+ suse)
+ rc_status -v
+ ;;
+ redhat)
+ echo
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
+ echo ""
+ return $RETVAL
+ ;;
+ debian)
+ return $RETVAL
+ ;;
+ esac
+}
- return $RETVAL
-}
+restart() {
+ stop
+ start
+}
+status() {
+ ctdb status
+}
+
+
case "$1" in
start)
log_daemon_msg "Starting $DESC " "$NAME"
@@ -233,7 +263,7 @@
if running ; then
log_progress_msg "running"
echo
- ctdb status
+ status
log_end_msg 0
else
log_progress_msg "not running"
More information about the Pkg-samba-maint
mailing list