linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] /etc/init.d/opensmd: Improve systemd integration
@ 2012-09-14 16:07 Bart Van Assche
       [not found] ` <50535650.6050306-HInyCGIudOg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2012-09-14 16:07 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Alex Netes

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. Also, prevent that the opensm process is
started twice and drop /var/lock/subsys/opensm.

Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
---
 scripts/opensm.init.in |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/scripts/opensm.init.in b/scripts/opensm.init.in
index 01d2bb9..7a9f8ec 100644
--- a/scripts/opensm.init.in
+++ b/scripts/opensm.init.in
@@ -45,11 +45,18 @@ exec_prefix=@exec_prefix@
 
 # 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 +68,13 @@ if [[ -s $CONFIG ]]; then
 fi
 
 start () {
+    if [ -e /var/run/opensm.pid ]; then
+	echo Already started
+	return 1
+    fi
     echo -n "Starting opensm: "
-    @sbindir@/opensm --daemon $OPTIONS > /dev/null
+    @sbindir@/opensm --daemon --pidfile /var/run/opensm.pid $OPTIONS > /dev/null
     if [[ $RETVAL -eq 0 ]]; then
-        touch /var/lock/subsys/opensm
         success
     else
         failure
@@ -76,7 +86,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 +123,7 @@ case "$1" in
 	restart
 	;;
     try-restart | condrestart)
-	[ -e /var/lock/subsys/opensm ] && restart
+	[ -e /var/run/opensm.pid ] && restart
 	;;
     resweep)
 	killall -HUP opensm
-- 
1.7.7

--
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-16 12:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-14 16:07 [PATCH] /etc/init.d/opensmd: Improve systemd integration Bart Van Assche
     [not found] ` <50535650.6050306-HInyCGIudOg@public.gmane.org>
2012-09-16  9:31   ` Alex Netes
2012-09-16 12:22     ` Bart Van Assche

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).