linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Alex Netes <alexne-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 3/4 for opensm] /etc/init.d/opensmd: Improve systemd integration
Date: Fri, 21 Sep 2012 16:44:20 +0200	[thread overview]
Message-ID: <505C7D44.9060500@acm.org> (raw)

On recent SLES and openSUSE systems it is necessary to read the
file /lib/lsb/init-functions instead of /etc/rc.status for proper
integration with systemd. Certain implementations of killproc
need a pidfile so make sure that one gets created. Also, correct
the opensm service dependency list.

Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 configure.in                  |    6 ++++++
 scripts/opensm.init.in        |   26 ++++++++++++++++++--------
 scripts/redhat-opensm.init.in |    2 ++
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/configure.in b/configure.in
index f660a5b..4515ae2 100644
--- a/configure.in
+++ b/configure.in
@@ -11,6 +11,12 @@ AM_INIT_AUTOMAKE
 AC_SUBST(RELEASE, ${RELEASE:-unknown})
 AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz})
 
+default_rdma_service=openibd
+AC_ARG_WITH([rdma_service],
+    AC_HELP_STRING([--with-rdma-service=name],
+                   [name of the RDMA service: "rdma" when using /etc/init.d/rdma to start RDMA services; "openibd" when using /etc/init.d/openibd to start RDMA services [default=${default_rdma_service}]]))
+AC_SUBST(RDMA_SERVICE, ${with_rdma_service:-${default_rdma_service}})
+
 if { rpm -q sles-release || rpm -q openSUSE-release; } >/dev/null 2>&1; then
    default_start="2 3 5"
    default_stop="0 1 4 6"
diff --git a/scripts/opensm.init.in b/scripts/opensm.init.in
index 007dae4..ddd1d6b 100644
--- a/scripts/opensm.init.in
+++ b/scripts/opensm.init.in
@@ -7,8 +7,8 @@
 #
 ### BEGIN INIT INFO
 # Provides: opensm
-# Required-Start: $syslog
-# Required-Stop:
+# Required-Start: $syslog @RDMA_SERVICE@
+# Required-Stop: $syslog @RDMA_SERVICE@
 # Default-Start: @DEFAULT_START@
 # Default-Stop: @DEFAULT_STOP@
 # Description:  Manage OpenSM
@@ -42,14 +42,22 @@
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
+pidfile=/var/run/opensm.pid
 
 # Source function library.
 if [[ -s /etc/init.d/functions ]]; then
+    # RHEL / CentOS / SL / Fedora.
     . /etc/init.d/functions
     rc_status() { :; }
     rc_exit() { exit $RETVAL; }
-fi
-if [[ -s /etc/rc.status ]]; then
+elif [[ -s /lib/lsb/init-functions ]]; then
+    # SLES / openSuSE / Debian.
+    . /lib/lsb/init-functions
+    rc_exit() { exit $RETVAL; }
+    success() { log_success_msg; }
+    failure() { log_failure_msg; }
+elif [[ -s /etc/rc.status ]]; then
+    # Older SuSE systems.
     . /etc/rc.status
     failure() { rc_status -v; }
     success() { rc_status -v; }
@@ -61,10 +69,13 @@ if [[ -s $CONFIG ]]; then
 fi
 
 start () {
+    if [ -e $pidfile ]; then
+	echo Already started
+	return 1
+    fi
     echo -n "Starting opensm: "
-    @sbindir@/opensm --daemon $OPTIONS > /dev/null
+    @sbindir@/opensm --daemon --pidfile $pidfile $OPTIONS > /dev/null
     if [[ $RETVAL -eq 0 ]]; then
-        touch /var/lock/subsys/opensm
         success
     else
         failure
@@ -76,7 +87,6 @@ stop () {
     echo -n "Shutting down opensm: "
     killproc opensm
     if [[ $RETVAL -eq 0 ]]; then
-        rm -f /var/lock/subsys/opensm
         success
     else
         failure
@@ -114,7 +124,7 @@ case "$1" in
 	restart
 	;;
     try-restart | condrestart)
-	[ -e /var/lock/subsys/opensm ] && restart
+	[ -e $pidfile ] && restart
 	;;
     resweep)
 	killall -HUP opensm
diff --git a/scripts/redhat-opensm.init.in b/scripts/redhat-opensm.init.in
index bea0f0d..415ab2f 100755
--- a/scripts/redhat-opensm.init.in
+++ b/scripts/redhat-opensm.init.in
@@ -7,6 +7,8 @@
 #
 ### BEGIN INIT INFO
 # Provides:       opensm
+# Required-Start: $syslog @RDMA_SERVICE@
+# Required-Stop: $syslog @RDMA_SERVICE@
 # Default-Start: @DEFAULT_START@
 # Default-Stop: @DEFAULT_STOP@
 # Description:  Manage OpenSM
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2012-09-21 14:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-21 14:44 Bart Van Assche [this message]
     [not found] ` <505C7D44.9060500-HInyCGIudOg@public.gmane.org>
2012-10-24 13:27   ` [PATCH 3/4 for opensm] /etc/init.d/opensmd: Improve systemd integration Alex Netes
2012-10-24 14:33     ` Doug Ledford
     [not found]       ` <5087FC29.4030303-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-10-24 14:45         ` Bart Van Assche
     [not found]           ` <5087FF1F.20907-HInyCGIudOg@public.gmane.org>
2012-10-24 14:48             ` Doug Ledford
2012-10-24 14:40     ` Bart Van Assche
     [not found]       ` <5087FDE5.30603-HInyCGIudOg@public.gmane.org>
2012-10-24 16:13         ` Alex Netes
2012-10-25  9:59           ` [PATCH 3/4 v2 " Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=505C7D44.9060500@acm.org \
    --to=bvanassche-hinycgiudog@public.gmane.org \
    --cc=alexne-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).