1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

make the packaging much more portable - tested on SLES9 and RHEL4

(This used to be ctdb commit 9521e3eee42b11303a2d6e0f5c05d0c0de4292d8)
This commit is contained in:
Andrew Tridgell 2007-06-01 23:25:33 +10:00
parent 1fa2600c8b
commit dff9a6ecd1
9 changed files with 83 additions and 57 deletions

View File

@ -116,6 +116,7 @@ distclean: clean
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

View File

@ -12,12 +12,10 @@ Group: System Environment/Daemons
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
@ -32,7 +30,7 @@ ctdb is the clustered database used by samba
%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
@ -54,18 +52,13 @@ make
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 {} \;
@ -74,12 +67,11 @@ 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

View File

@ -15,9 +15,7 @@
EXTRA_OPTIONS="$1"
RHEL="packaging/RHEL"
[ -d ${RHEL} ] || {
[ -d packaging ] || {
echo "Must run this from the ctdb directory"
exit 1
}
@ -62,7 +60,7 @@ if [ ! -d ctdb-${VERSION} ]; then
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!"
@ -76,8 +74,7 @@ popd
##
## 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
@ -87,4 +84,6 @@ cd ${SPECDIR}
${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

View File

@ -1,35 +1,46 @@
#!/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"
@ -41,24 +52,44 @@ fi
[ -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() {
@ -66,20 +97,11 @@ 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
@ -94,7 +116,7 @@ case "$1" in
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/ctdb ] && restart || :
ctdb status > /dev/null && restart || :
;;
*)
echo $"Usage: $0 {start|stop|restart|status|condrestart}"

View File

@ -324,13 +324,17 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
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);
}
/*

View File

@ -12,7 +12,7 @@ shift
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
@ -34,6 +34,7 @@ case $cmd in
;;
shutdown)
# shutdown Samba cleanly when ctdb goes down
/etc/init.d/smb stop
/etc/init.d/winbind stop
;;

View File

@ -15,7 +15,14 @@ ctdb_wait_tcp_ports() {
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 || {

View File

@ -25,8 +25,8 @@ case "$1" in
;;
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`