install: all
mkdir -p $(DESTDIR)$(bindir)
+ mkdir -p $(DESTDIR)$(sbindir)
mkdir -p $(DESTDIR)$(includedir)
mkdir -p $(DESTDIR)$(etcdir)/ctdb
mkdir -p $(DESTDIR)$(etcdir)/ctdb/events.d
URL: http://ctdb.samba.org/
Source: ctdb-%{version}.tar.bz2
-Source999: ctdb-setup.tar.bz2
Prereq: /sbin/chkconfig /bin/mktemp /usr/bin/killall /usr/bin/nc
Prereq: fileutils sed /etc/init.d
-Requires: initscripts >= 5.54-1
Provides: ctdb = %{version}
Prefix: /usr
%prep
%setup -q
# setup the init script and sysconfig file
-%setup -T -D -a 999 -n ctdb-%{version} -q
+%setup -T -D -n ctdb-%{version} -q
%build
rm -rf $RPM_BUILD_ROOT
# Create the target build directory hierarchy
-mkdir -p $RPM_BUILD_ROOT%{_includedir}
-mkdir -p $RPM_BUILD_ROOT{%{_libdir},%{_includedir}}
-mkdir -p $RPM_BUILD_ROOT%{_prefix}/{bin,sbin}
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/ctdb
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/events.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
make DESTDIR=$RPM_BUILD_ROOT install
-install -m644 setup/ctdb.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ctdb
-install -m755 setup/ctdb.init $RPM_BUILD_ROOT%{initdir}/ctdb
+install -m644 tools/ctdb.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ctdb
+install -m755 packaging/ctdb.init $RPM_BUILD_ROOT%{initdir}/ctdb
# Remove "*.old" files
find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
rm -rf $RPM_BUILD_ROOT
%post
-/sbin/chkconfig --add ctdb
+[ -x /sbin/chkconfig ] && /sbin/chkconfig --add ctdb
%preun
if [ $1 = 0 ] ; then
- /sbin/chkconfig --del ctdb
- /sbin/service ctdb stop >/dev/null 2>&1
+ [ -x /sbin/chkconfig ] && /sbin/chkconfig --del ctdb
fi
exit 0
EXTRA_OPTIONS="$1"
-RHEL="packaging/RHEL"
-
-[ -d ${RHEL} ] || {
+[ -d packaging ] || {
echo "Must run this from the ctdb directory"
exit 1
}
REMOVE_LN=$PWD/ctdb-$VERSION
fi
echo -n "Creating ctdb-${VERSION}.tar.bz2 ... "
-tar --exclude=.bzr --exclude .bzrignore --exclude packaging --exclude="*~" -cf - ctdb-${VERSION}/. | bzip2 > ${SRCDIR}/ctdb-${VERSION}.tar.bz2
+tar --exclude=.bzr --exclude .bzrignore --exclude="*~" -cf - ctdb-${VERSION}/. | bzip2 > ${SRCDIR}/ctdb-${VERSION}.tar.bz2
echo "Done."
if [ $? -ne 0 ]; then
echo "Build failed!"
##
## copy additional source files
##
-(cd packaging/RHEL && tar --exclude=.bzr --exclude="*~" -jcvf - setup) > ${SRCDIR}/ctdb-setup.tar.bz2
-cp -p ${RHEL}/${SPECFILE} ${SPECDIR}
+cp -p packaging/RPM/ctdb.spec ${SPECDIR}
##
## Build
${RPMBUILD} -ba --clean --rmsource $EXTRA_OPTIONS $SPECFILE
echo "$(basename $0): Done."
-[ ${REMOVE_LN} ] && rm $REMOVE_LN
+[ ${REMOVE_LN} ] && /bin/rm -f $REMOVE_LN
+
+exit 0
#!/bin/sh
#
+##############################
+# init info for redhat distros
# chkconfig: - 90 36
# description: Starts and stops the clustered tdb daemon
-#
# pidfile: /var/run/ctdbd/ctdbd.pid
+##############################
+
+##############################
+# SLES/OpenSuSE init info
+### BEGIN INIT INFO
+# Provides: ctdb
+# Required-Start: $network
+# Required-Stop:
+# Default-Start: 3 5
+# Default-Stop:
+# Description: initscript for the ctdb service
+### END INIT INFO
# Source function library.
if [ -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
-else
- exit 0
fi
# Avoid using root's TMPDIR
unset TMPDIR
-# Source networking configuration.
-. /etc/sysconfig/network
+# check networking is up (for redhat)
+[ -f /etc/sysconfig/network ] && {
+ . /etc/sysconfig/network
+ [ ${NETWORKING} = "no" ] && exit 0
+}
CTDB_OPTIONS=""
-# pull in admin specified config
+# pull in admin specified config for ctdb
if [ -f /etc/sysconfig/ctdb ]; then
. /etc/sysconfig/ctdb
fi
-# Check that networking is up.
-[ ${NETWORKING} = "no" ] && exit 0
-
# build up CTDB_OPTIONS variable
[ -z "$LOGFILE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$LOGFILE"
[ -z "$NODES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$NODES"
[ -z "$TRANSPORT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --transport $TRANSPORT"
[ -z "$DEBUGLEVEL" ] || CTDB_OPTIONS="$CTDB_OPTIONS -d $DEBUGLEVEL"
+if [ -x /sbin/startproc ]; then
+ init_style="suse"
+else
+ init_style="redhat"
+fi
+
start() {
- echo -n $"Starting ctdbd services: "
- daemon ctdbd $CTDB_OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || \
- RETVAL=1
- return $RETVAL
+ echo -n $"Starting ctdbd service: "
+ case $init_style in
+ suse)
+ startproc ctdbd $CTDB_OPTIONS
+ rc_status -v
+ ;;
+ redhat)
+ daemon ctdbd $CTDB_OPTIONS
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
+ return $RETVAL
+ ;;
+ esac
}
stop() {
- echo -n $"Shutting down ctdbd services: "
+ echo -n $"Shutting down ctdbd service: "
ctdb shutdown
RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
- echo ""
- return $RETVAL
+ case $init_style in
+ suse)
+ rc_status -v
+ ;;
+ redhat)
+ echo
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
+ echo ""
+ return $RETVAL
+ ;;
+ esac
}
restart() {
start
}
-rhstatus() {
+status() {
ctdb status
- if [ $? -ne 0 ] ; then
- return 1
- fi
}
-# Allow status as non-root.
-if [ "$1" = status ]; then
- rhstatus
- exit $?
-fi
-
case "$1" in
start)
start
rhstatus
;;
condrestart)
- [ -f /var/lock/subsys/ctdb ] && restart || :
+ ctdb status > /dev/null && restart || :
;;
*)
echo $"Usage: $0 {start|stop|restart|status|condrestart}"
struct ctdb_event_script_state *state =
talloc_get_type(p, struct ctdb_event_script_state);
int status = -1;
+ void (*callback)(struct ctdb_context *, int, void *) = state->callback;
+ void *private_data = state->private_data;
+ struct ctdb_context *ctdb = state->ctdb;
+
waitpid(state->child, &status, 0);
if (status != -1) {
status = WEXITSTATUS(status);
}
- state->callback(state->ctdb, status, state->private_data);
talloc_set_destructor(state, NULL);
talloc_free(state);
+ callback(ctdb, status, private_data);
}
/*
case $cmd in
startup)
# wait for the Samba tcp ports to become available
- smb_ports=`testparm -stv 2> /dev/null | egrep '\s*smb ports =' | cut -d= -f2"`
+ smb_ports=`testparm -stv 2> /dev/null | egrep '\s*smb ports =' | cut -d= -f2`
ctdb_wait_tcp_ports "Samba" $smb_ports
# wait for all shared directories to become available
;;
shutdown)
+ # shutdown Samba cleanly when ctdb goes down
/etc/init.d/smb stop
/etc/init.d/winbind stop
;;
while [ $all_ok -eq 0 ]; do
all_ok=1
for p in $wait_ports; do
- /usr/bin/nc -z 127.0.0.1 $p || all_ok=0
+ if [ -x /usr/bin/netcat ]; then
+ /usr/bin/netcat -z 127.0.0.1 $p || all_ok=0
+ elif [ -x /usr/bin/nc ]; then
+ /usr/bin/nc -z 127.0.0.1 $p || all_ok=0
+ else
+ echo "`date` netcat not found - cannot check tcp ports"
+ return
+ fi
done
[ $all_ok -eq 1 ] || sleep 1
/usr/bin/ctdb status > /dev/null 2>&1 || {
;;
notify)
# restart the local lock manager and statd
- /sbin/service nfslock stop > /dev/null 2>&1
- /sbin/service nfslock start > /dev/null 2>&1
+ /etc/init.d/nfslock stop > /dev/null 2>&1
+ /etc/init.d/nfslock start > /dev/null 2>&1
# send out notifications to any additional ips we now serve
for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do
ip=`/bin/basename $f`