From patchwork Fri Sep 14 16:07:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 1459661 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 18822402E1 for ; Fri, 14 Sep 2012 16:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753453Ab2INQdM (ORCPT ); Fri, 14 Sep 2012 12:33:12 -0400 Received: from [178.239.52.149] ([178.239.52.149]:39825 "EHLO wimaserver10.be" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752357Ab2INQdK (ORCPT ); Fri, 14 Sep 2012 12:33:10 -0400 Received: from 178-119-64-133.access.telenet.be ([178.119.64.133] helo=[192.168.1.101]) by wimaserver10.be with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1TCYX7-0005Jo-B3; Fri, 14 Sep 2012 18:14:21 +0200 Message-ID: <50535650.6050306@acm.org> Date: Fri, 14 Sep 2012 18:07:44 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: "linux-rdma@vger.kernel.org" , Alex Netes Subject: [PATCH] /etc/init.d/opensmd: Improve systemd integration X-Enigmail-Version: 1.4.4 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org 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 --- 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