[lttng-tools/el6: 3/3] Create an old style initscript for EPEL
Yannick Brosseau
greenscientist at fedoraproject.org
Wed Oct 24 07:03:40 UTC 2012
commit 1046cca7478acba1baa031471bc35f5ca391ebde
Author: Yannick Brosseau <yannick.brosseau at gmail.com>
Date: Wed Oct 24 03:02:46 2012 -0400
Create an old style initscript for EPEL
lttng-sessiond.init | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++
lttng-tools.spec | 30 ++++++-----
2 files changed, 148 insertions(+), 14 deletions(-)
---
diff --git a/lttng-sessiond.init b/lttng-sessiond.init
new file mode 100755
index 0000000..0e781c9
--- /dev/null
+++ b/lttng-sessiond.init
@@ -0,0 +1,132 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: lttng-sessiond
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: The LTTng session daemon
+# Description: Main daemon for trace session registry for UST and LTTng
+### END INIT INFO
+
+# Inspired by Debian init script done by Jon Bernard <jbernard at debian.org>
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC=lttng-sessiond # Introduce a short description here
+NAME=lttng-sessiond # Introduce the short server's name here
+DAEMON=/usr/local/bin/lttng-sessiond # Introduce the server's location here
+DAEMON_ARGS="-d" # Arguments to run the daemon with
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x $DAEMON ] || exit 0
+
+if [ -e /etc/sysconfig/lttng-sessiond ]; then
+ . /etc/sysconfig/lttng-sessiond
+fi
+
+# source function library
+. /etc/rc.d/init.d/functions
+
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+
+ start_daemon $DAEMON $DAEMON_ARGS
+ RETVAL=$?
+ echo
+ return $RETVAL
+
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ #start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
+ # || return 1
+ #start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS \
+ # || return 2
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ killproc $NAME -TERM
+ RETVAL=$?
+ echo
+ return $RETVAL
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ killproc $NAME -HUP
+ return 0
+}
+
+case "$1" in
+
+ start)
+ MSG="Starting $DESC "
+ do_start
+ case "$?" in
+ 0|1) log_success_msg $MSG ;;
+ 2) log_failure $MSG ;;
+ esac
+ ;;
+
+ stop)
+ MSG="Stopping $DESC"
+ do_stop
+ case "$?" in
+ 0|1) log_success_msg $MSG ;;
+ *) log_failure_msg $MSG ;;
+ esac
+ ;;
+
+ status)
+ status "$DAEMON" && exit 0 || exit $?
+ ;;
+
+ restart|force-reload)
+ echo "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
diff --git a/lttng-tools.spec b/lttng-tools.spec
index 6b25e1e..63b047b 100644
--- a/lttng-tools.spec
+++ b/lttng-tools.spec
@@ -1,19 +1,19 @@
Name: lttng-tools
Version: 2.0.4
-Release: 1%{?dist}
+Release: 2%{?dist}
License: GPLv2 and LGPLv2
URL: http://lttng.org/lttng2.0
Group: Development/Tools
Summary: LTTng control and utility programs
Source0: http://lttng.org/files/lttng-tools/%{name}-%{version}.tar.bz2
-Source1: lttng-sessiond.service
+Source1: lttng-sessiond.init
-BuildRequires: libuuid-devel popt-devel lttng-ust-devel libtool systemd-units
+BuildRequires: libuuid-devel popt-devel lttng-ust-devel libtool
BuildRequires: userspace-rcu-devel >= 0.6.6
-Requires(pre): shadow-utils
-Requires(post): systemd-units
-Requires(preun): systemd-units
-Requires(postun): systemd-units
+Requires(post): chkconfig /sbin/service
+Requires(pre): shadow-utils
+Requires(preun): chkconfig shadow-utils /sbin/service
+Requires(postun): chkconfig /sbin/service
%description
This package provides the unified interface to control both the LTTng kernel
@@ -47,7 +47,7 @@ make %{?_smp_mflags} V=1
%install
make DESTDIR=%{buildroot} install
rm -vf %{buildroot}%{_libdir}/*.la
-install -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/lttng-sessiond.service
+install -Dpm 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/lttng-sessiond
# Install upstream bash auto completion for lttng
install -D -m644 extras/lttng-bash_completion %{buildroot}%{_sysconfdir}/bash_completion.d/lttng
@@ -60,22 +60,21 @@ exit 0
if [ $1 -eq 1 ] ; then
# Initial installation
- /bin/systemctl enable lttng-sessiond.service >/dev/null 2>&1 || :
+ /sbin/chkconfig --add lttng-sessiond
fi
%preun
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
- /bin/systemctl --no-reload disable lttng-sessiond.service > /dev/null 2>&1 || :
- /bin/systemctl stop lttng-sessiond.service > /dev/null 2>&1 || :
+ /sbin/service lttng-sessiond stop > /dev/null 2>&1
+ /sbin/chkconfig --del lttng-sessiond
fi
%postun
/sbin/ldconfig
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
- /bin/systemctl try-restart lttng-sessiond.service >/dev/null 2>&1 || :
+ /sbin/service lttng-sessiond condrestart > /dev/null 2>&1
fi
@@ -93,7 +92,7 @@ fi
%{_docdir}/%{name}/LICENSE
%{_docdir}/%{name}/quickstart.txt
%doc README
-%{_unitdir}/lttng-sessiond.service
+%{_initrddir}/lttng-sessiond
%{_sysconfdir}/bash_completion.d/
@@ -102,6 +101,9 @@ fi
%{_libdir}/*.so
%changelog
+* Tue Oct 23 2012 Yannick Brosseau <yannick.brosseau at gmail.com> - 2.0.4-2
+- Change systemd to init script for EPEL
+
* Tue Oct 23 2012 Yannick Brosseau <yannick.brosseau at gmail.com> - 2.0.4-1
- New upstream version
More information about the scm-commits
mailing list