Add systemd support
Sumit Bose
sbose at redhat.com
Thu Feb 2 07:53:52 MST 2012
Hi David,
On Wed, Feb 01, 2012 at 05:46:07PM +0100, David Disseldorp wrote:
> Hi Sumit,
>
> The changes look good. One minor comment:
thank you for review.
>
> --- /dev/null
> +++ b/config/ctdb.service
> @@ -0,0 +1,19 @@
> ...
> +[Service]
> +Type=forking
> +LimitCORE=infinity
>
> config/systemd/ctdb.systemd sets the core file size limit via ulimit,
> are both LimitCORE and ulimit settings needed?
you're right I removed it. New version of the patch attached.
> It may also be worth considering a LimitNOFILE setting, ctdbd requires
> one fd per client, exceeding the default limit under heavy load results
> in a busy EMFILE loop around accept() (at least it did in ctdb-1.0.112).
Please have a look at the new patch 0001, is this what you thought of?
bye,
Sumit
>
> Cheers, David
-------------- next part --------------
>From e567744916fe1af850d0edb353f8f34c0abde713 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Thu, 2 Feb 2012 14:40:13 +0100
Subject: [PATCH 1/3] Add CTDB_MAX_OPEN_FILES config option
---
config/ctdb.init | 4 ++++
config/ctdb.sysconfig | 2 ++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/config/ctdb.init b/config/ctdb.init
index d6493bd..2aeb4ce 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -251,6 +251,10 @@ start() {
ulimit -c unlimited
fi
+ if [ "0$CTDB_MAX_OPEN_FILES" -gt 0 ]; then
+ ulimit -n $CTDB_MAX_OPEN_FILES
+ fi
+
case $init_style in
valgrind)
eval valgrind -q --log-file=/var/log/ctdb_valgrind \
diff --git a/config/ctdb.sysconfig b/config/ctdb.sysconfig
index 1f2edc4..93820a4 100644
--- a/config/ctdb.sysconfig
+++ b/config/ctdb.sysconfig
@@ -311,3 +311,5 @@ CTDB_SERVICE_AUTOSTARTSTOP=yes
# any other options you might want. Run ctdbd --help for a list
# CTDB_OPTIONS=
+# Set maximum number of open file descriptors
+# CTDB_MAX_OPEN_FILES=4096
--
1.7.7.6
-------------- next part --------------
>From e30df635b3fc7d7bcfdb69f017a6d94704c56b01 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Tue, 10 Jan 2012 11:06:47 +0100
Subject: [PATCH 2/3] Extract some init functions into a separate file
---
Makefile.in | 1 +
config/ctdb.init | 163 +-------------------------------------------
config/init_functions | 163 ++++++++++++++++++++++++++++++++++++++++++++
packaging/RPM/ctdb.spec.in | 1 +
4 files changed, 166 insertions(+), 162 deletions(-)
create mode 100644 config/init_functions
diff --git a/Makefile.in b/Makefile.in
index 5fa9e98..bc43074 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -244,6 +244,7 @@ install: all
${INSTALLCMD} -m 644 include/ctdb_private.h $(DESTDIR)$(includedir) # for samba3
${INSTALLCMD} -m 644 include/ctdb_typesafe_cb.h $(DESTDIR)$(includedir)
${INSTALLCMD} -m 644 config/functions $(DESTDIR)$(etcdir)/ctdb
+ ${INSTALLCMD} -m 644 config/init_functions $(DESTDIR)$(etcdir)/ctdb
${INSTALLCMD} -m 755 config/statd-callout $(DESTDIR)$(etcdir)/ctdb
${INSTALLCMD} -m 755 config/interface_modify.sh $(DESTDIR)$(etcdir)/ctdb
${INSTALLCMD} -m 644 config/events.d/README $(DESTDIR)$(docdir)/ctdb/README.eventscripts
diff --git a/config/ctdb.init b/config/ctdb.init
index 2aeb4ce..223aad5 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -44,6 +44,7 @@ unset TMPDIR
}
. $CTDB_BASE/functions
+. $CTDB_BASE/init_functions
loadconfig network
loadconfig ctdb
@@ -61,174 +62,12 @@ else
init_style="$CTDB_INIT_STYLE"
fi
-build_ctdb_options () {
-
- 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}"
- }
-
- [ -z "$CTDB_RECOVERY_LOCK" ] && {
- echo "No recovery lock specified. Starting CTDB without split brain prevention"
- }
- 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"
- 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
-
- 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;
- }
-
- if test -x /usr/bin/tdbtool ; then
- HAVE_TDBTOOL=1
- else
- HAVE_TDBTOOL=0
- fi
-
- if test x"$HAVE_TDBTOOL" = x"1" ; then
- TDBTOOL_HAS_CHECK=`echo "help" | /usr/bin/tdbtool | grep check | wc -l`
- else
- TDBTOOL_HAS_CHECK=0
- fi
-
- if test -x /usr/bin/tdbdump ; then
- HAVE_TDBDUMP=1
- else
- HAVE_TDBDUMP=0
- fi
-
- if test x"$HAVE_TDBDUMP" = x"0" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
- echo "WARNING: Cannot check persistent databases since"
- echo "neither 'tdbdump' nor 'tdbtool check' is available."
- echo "Consider installing tdbtool or at least tdbdump!"
- return 0
- fi
-
- if test x"$HAVE_TDBDUMP" = x"1" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
- if test x"$HAVE_TDBTOOL" = x"0"; then
- echo "WARNING: 'tdbtool' is not available. Using 'tdbdump' to"
- echo "check the persistent databases."
- echo "Consider installing a recent 'tdbtool' for better checks!"
- else
- echo "WARNING: The installed 'tdbtool' does not offer the 'check'"
- echo "subcommand. Using 'tdbdump' for persistent database checks."
- echo "Consider updating 'tdbtool' for better checks!"
- fi
- fi
-
- for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
- check_tdb $PDBASE || {
- 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
}
-wait_until_ready () {
- _timeout="${1:-10}" # default is 10 seconds
-
- _count=0
- while ! ctdb ping >/dev/null 2>&1 ; do
- if [ $_count -ge $_timeout ] ; then
- return 1
- fi
- sleep 1
- _count=$(($_count + 1))
- done
-}
-
ctdbd=${CTDBD:-/usr/sbin/ctdbd}
-drop_all_public_ips() {
- [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
- return
- }
-
- cat $CTDB_PUBLIC_ADDRESSES | while read IP IFACE REST; do
- ip addr del $IP dev $IFACE >/dev/null 2>/dev/null
- done
-}
-
start() {
echo -n $"Starting ctdbd service: "
diff --git a/config/init_functions b/config/init_functions
new file mode 100644
index 0000000..6d3e789
--- /dev/null
+++ b/config/init_functions
@@ -0,0 +1,163 @@
+# Shared init functions used by SysV and systemd init systems
+
+build_ctdb_options () {
+
+ 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}"
+ }
+
+ [ -z "$CTDB_RECOVERY_LOCK" ] && {
+ echo "No recovery lock specified. Starting CTDB without split brain prevention"
+ }
+ 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"
+ 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
+
+ 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;
+ }
+
+ if test -x /usr/bin/tdbtool ; then
+ HAVE_TDBTOOL=1
+ else
+ HAVE_TDBTOOL=0
+ fi
+
+ if test x"$HAVE_TDBTOOL" = x"1" ; then
+ TDBTOOL_HAS_CHECK=`echo "help" | /usr/bin/tdbtool | grep check | wc -l`
+ else
+ TDBTOOL_HAS_CHECK=0
+ fi
+
+ if test -x /usr/bin/tdbdump ; then
+ HAVE_TDBDUMP=1
+ else
+ HAVE_TDBDUMP=0
+ fi
+
+ if test x"$HAVE_TDBDUMP" = x"0" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
+ echo "WARNING: Cannot check persistent databases since"
+ echo "neither 'tdbdump' nor 'tdbtool check' is available."
+ echo "Consider installing tdbtool or at least tdbdump!"
+ return 0
+ fi
+
+ if test x"$HAVE_TDBDUMP" = x"1" -a x"$TDBTOOL_HAS_CHECK" = x"0" ; then
+ if test x"$HAVE_TDBTOOL" = x"0"; then
+ echo "WARNING: 'tdbtool' is not available. Using 'tdbdump' to"
+ echo "check the persistent databases."
+ echo "Consider installing a recent 'tdbtool' for better checks!"
+ else
+ echo "WARNING: The installed 'tdbtool' does not offer the 'check'"
+ echo "subcommand. Using 'tdbdump' for persistent database checks."
+ echo "Consider updating 'tdbtool' for better checks!"
+ fi
+ fi
+
+ for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
+ check_tdb $PDBASE || {
+ 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
+}
+
+wait_until_ready () {
+ _timeout="${1:-10}" # default is 10 seconds
+
+ _count=0
+ while ! ctdb ping >/dev/null 2>&1 ; do
+ if [ $_count -ge $_timeout ] ; then
+ return 1
+ fi
+ sleep 1
+ _count=$(($_count + 1))
+ done
+}
+
+drop_all_public_ips() {
+ [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
+ return
+ }
+
+ cat $CTDB_PUBLIC_ADDRESSES | while read IP IFACE REST; do
+ ip addr del $IP dev $IFACE >/dev/null 2>/dev/null
+ done
+}
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index 08719d0..53c6080 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -112,6 +112,7 @@ rm -rf $RPM_BUILD_ROOT
%{_sysconfdir}/ctdb/events.d/91.lvs
%{_sysconfdir}/ctdb/statd-callout
%{_sysconfdir}/ctdb/interface_modify.sh
+%{_sysconfdir}/ctdb/init_functions
%{_sbindir}/ctdbd
%{_bindir}/ctdb
%{_bindir}/smnotify
--
1.7.7.6
-------------- next part --------------
>From 93d3eac923d608b3930af675e7f454947160bb1b Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Tue, 10 Jan 2012 10:20:35 +0100
Subject: [PATCH 3/3] Add systemd support
---
config/ctdb.service | 17 +++++++++
config/systemd/ctdb.systemd | 37 ++++++++++++++++++++
config/systemd/ctdb_check_persistent_databases.pre | 20 +++++++++++
config/systemd/ctdb_drop_all_public_ips | 22 ++++++++++++
config/systemd/ctdb_set_ctdb_variables.post | 26 ++++++++++++++
packaging/RPM/ctdb.spec.in | 22 +++++++++++-
6 files changed, 143 insertions(+), 1 deletions(-)
create mode 100644 config/ctdb.service
create mode 100755 config/systemd/ctdb.systemd
create mode 100755 config/systemd/ctdb_check_persistent_databases.pre
create mode 100644 config/systemd/ctdb_drop_all_public_ips
create mode 100644 config/systemd/ctdb_set_ctdb_variables.post
diff --git a/config/ctdb.service b/config/ctdb.service
new file mode 100644
index 0000000..f01a57f
--- /dev/null
+++ b/config/ctdb.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=CTDB
+After=network.target
+
+[Service]
+Type=forking
+ExecStartPre=/etc/ctdb/systemd/ctdb_drop_all_public_ips
+ExecStartPre=/etc/ctdb/systemd/ctdb_check_persistent_databases.pre
+ExecStart=/etc/ctdb/systemd/ctdb.systemd
+ExecStartPost=/etc/ctdb/systemd/ctdb_set_ctdb_variables.post
+ExecStop=/usr/bin/ctdb shutdown
+ExecStopPost=-/etc/ctdb/systemd/ctdb_drop_all_public_ips
+KillMode=control-group
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/systemd/ctdb.systemd b/config/systemd/ctdb.systemd
new file mode 100755
index 0000000..a3ca46a
--- /dev/null
+++ b/config/systemd/ctdb.systemd
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+
+# Avoid using root's TMPDIR
+unset TMPDIR
+
+[ -z "$CTDB_BASE" ] && {
+ export CTDB_BASE="/etc/ctdb"
+}
+
+[ -z "$CTDB_VARDIR" ] && {
+ export CTDB_VARDIR="/var/ctdb"
+}
+
+. $CTDB_BASE/functions
+. $CTDB_BASE/init_functions
+
+. /etc/sysconfig/ctdb
+
+ctdbd=${CTDBD:-/usr/sbin/ctdbd}
+
+if [ "$CTDB_SUPPRESS_COREFILE" = "yes" ]; then
+ ulimit -c 0
+else
+ ulimit -c unlimited
+fi
+
+if [ "0$CTDB_MAX_OPEN_FILES" -gt 0 ]; then
+ ulimit -n $CTDB_MAX_OPEN_FILES
+fi
+
+
+build_ctdb_options
+
+exec $ctdbd "$CTDB_OPTIONS" >/dev/null 2>&1 </dev/null
+
+exit 1
diff --git a/config/systemd/ctdb_check_persistent_databases.pre b/config/systemd/ctdb_check_persistent_databases.pre
new file mode 100755
index 0000000..7659225
--- /dev/null
+++ b/config/systemd/ctdb_check_persistent_databases.pre
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+
+# Avoid using root's TMPDIR
+unset TMPDIR
+
+[ -z "$CTDB_BASE" ] && {
+ export CTDB_BASE="/etc/ctdb"
+}
+
+[ -z "$CTDB_VARDIR" ] && {
+ export CTDB_VARDIR="/var/ctdb"
+}
+
+. $CTDB_BASE/functions
+. $CTDB_BASE/init_functions
+
+. /etc/sysconfig/ctdb
+
+check_persistent_databases || exit 1
diff --git a/config/systemd/ctdb_drop_all_public_ips b/config/systemd/ctdb_drop_all_public_ips
new file mode 100644
index 0000000..7a05c6f
--- /dev/null
+++ b/config/systemd/ctdb_drop_all_public_ips
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+
+# Avoid using root's TMPDIR
+unset TMPDIR
+
+[ -z "$CTDB_BASE" ] && {
+ export CTDB_BASE="/etc/ctdb"
+}
+
+[ -z "$CTDB_VARDIR" ] && {
+ export CTDB_VARDIR="/var/ctdb"
+}
+
+. $CTDB_BASE/functions
+. $CTDB_BASE/init_functions
+
+. /etc/sysconfig/ctdb
+
+drop_all_public_ips
+
+exit 0
diff --git a/config/systemd/ctdb_set_ctdb_variables.post b/config/systemd/ctdb_set_ctdb_variables.post
new file mode 100644
index 0000000..f02ca5d
--- /dev/null
+++ b/config/systemd/ctdb_set_ctdb_variables.post
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+
+# Avoid using root's TMPDIR
+unset TMPDIR
+
+[ -z "$CTDB_BASE" ] && {
+ export CTDB_BASE="/etc/ctdb"
+}
+
+[ -z "$CTDB_VARDIR" ] && {
+ export CTDB_VARDIR="/var/ctdb"
+}
+
+. $CTDB_BASE/functions
+. $CTDB_BASE/init_functions
+
+. /etc/sysconfig/ctdb
+
+if wait_until_ready ; then
+ set_ctdb_variables
+else
+ exit 1
+fi
+
+exit 0
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index 53c6080..a7ef034 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -1,3 +1,4 @@
+%define with_systemd 0
%define initdir %{_sysconfdir}/init.d
Name: ctdb
Summary: Clustered TDB
@@ -62,12 +63,23 @@ rm -rf $RPM_BUILD_ROOT
# Create the target build directory hierarchy
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d
make DESTDIR=$RPM_BUILD_ROOT docdir=%{_docdir} install
install -m644 config/ctdb.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ctdb
+
+%if %{with_systemd}
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/systemd
+install -m 755 config/systemd/ctdb_check_persistent_databases.pre $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/systemd
+install -m 755 config/systemd/ctdb_set_ctdb_variables.post $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/systemd
+install -m 755 config/systemd/ctdb_drop_all_public_ips $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/systemd
+install -m 755 config/systemd/ctdb.systemd $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/systemd
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
+install -m 755 config/ctdb.service $RPM_BUILD_ROOT%{_unitdir}
+%else
+mkdir -p $RPM_BUILD_ROOT%{initdir}
install -m755 config/ctdb.init $RPM_BUILD_ROOT%{initdir}/ctdb
+%endif
mkdir -p $RPM_BUILD_ROOT%{_docdir}/ctdb/tests/bin
install -m755 tests/bin/ctdb_transaction $RPM_BUILD_ROOT%{_docdir}/ctdb/tests/bin
@@ -90,7 +102,15 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) %{_sysconfdir}/ctdb/notify.sh
%config(noreplace) %{_sysconfdir}/ctdb/ctdb-crash-cleanup.sh
%config(noreplace) %{_sysconfdir}/ctdb/functions
+%if %{with_systemd}
+%{_sysconfdir}/ctdb/systemd/ctdb_check_persistent_databases.pre
+%{_sysconfdir}/ctdb/systemd/ctdb_set_ctdb_variables.post
+%{_sysconfdir}/ctdb/systemd/ctdb_drop_all_public_ips
+%{_sysconfdir}/ctdb/systemd/ctdb.systemd
+%{_unitdir}/ctdb.service
+%else
%attr(755,root,root) %{initdir}/ctdb
+%endif
%{_docdir}/ctdb/README.eventscripts
%{_docdir}/ctdb/recovery-process.txt
--
1.7.7.6
More information about the samba-technical
mailing list