6 # description: Activates/Deactivates InfiniBand Subnet Manager
12 # Copyright (c) 2008 Voltaire, Inc. All rights reserved.
13 # Copyright (c) 2006 Mellanox Technologies. All rights reserved.
15 # This Software is licensed under one of the following licenses:
17 # 1) under the terms of the "Common Public License 1.0" a copy of which is
18 # available from the Open Source Initiative, see
19 # http://www.opensource.org/licenses/cpl.php.
21 # 2) under the terms of the "The BSD License" a copy of which is
22 # available from the Open Source Initiative, see
23 # http://www.opensource.org/licenses/bsd-license.php.
25 # 3) under the terms of the "GNU General Public License (GPL) Version 2" a
26 # copy of which is available from the Open Source Initiative, see
27 # http://www.opensource.org/licenses/gpl-license.php.
29 # Licensee has the right to choose one of the above licenses.
31 # Redistributions of source code must retain the above copyright
32 # notice and one of the license notices.
34 # Redistributions in binary form must reproduce both the above copyright
35 # notice, one of the license notices in the documentation
36 # and/or other materials provided with the distribution.
39 # $Id: openib-1.0-opensm.init,v 1.5 2006/08/02 18:18:23 dledford Exp $
41 # processname: @sbindir@/opensm
42 # config: @sysconfdir@/sysconfig/opensm
43 # pidfile: /var/run/opensm.pid
46 exec_prefix=@exec_prefix@
48 . /etc/rc.d/init.d/functions
50 CONFIG=@sysconfdir@/sysconfig/opensm
51 if [ -f $CONFIG ]; then
58 # Handover daemon for updating guid2lid cache file
59 sldd_prog=@sbindir@/sldd.sh
60 sldd_bin=${sldd_prog##*/}
61 sldd_pid_file=/var/run/sldd.pid
65 # Setting OpenSM start parameters
66 PID_FILE=/var/run/${bin}.pid
69 if [[ -n "${OSM_HOSTS}" && $(echo -n ${OSM_HOSTS} | wc -w | tr -d '[:space:]') -gt 1 ]]; then
70 HONORE_GUID2LID="--honor_guid2lid"
73 #########################################################################
77 if [ -f $sldd_pid_file ]; then
79 read line < $sldd_pid_file
81 [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
85 if [ -z "$sldd_pid" ]; then
86 sldd_pid=`pidof -x $sldd_bin`
89 if [ -n "${sldd_pid:-}" ] ; then
90 kill -9 ${sldd_pid} > /dev/null 2>&1
93 $sldd_prog > /dev/null 2>&1 &
96 echo ${sldd_pid} > $sldd_pid_file
97 # Sleep is needed in order to update local gid2lid cache file before running opensm
103 if [ -f $sldd_pid_file ]; then
105 read line < $sldd_pid_file
107 [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
111 if [ -z "$sldd_pid" ]; then
112 sldd_pid=`pidof -x $sldd_bin`
115 if [ -n "${sldd_pid:-}" ] ; then
116 kill -15 ${sldd_pid} > /dev/null 2>&1
127 if [ -f $PID_FILE ]; then
129 read line < $PID_FILE
131 [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
135 if [ -z "$pid" ]; then
136 pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
139 if [ -n "${pid:-}" ] ; then
140 echo $"${bin} (pid $pid) is already running..."
143 if [ -n "${HONORE_GUID2LID}" ]; then
149 echo -n "Starting IB Subnet Manager"
150 $prog --daemon ${HONORE_GUID2LID} ${OPTIONS} > /dev/null
152 while [ $cnt -lt 6 -a $alive -ne 1 ]; do
156 OSM_PID=`pidof $prog`
157 if [ "$OSM_PID" != "" ]; then
163 echo $OSM_PID > $PID_FILE
166 [ $RC -eq 0 ] && echo_success || echo_failure
167 [ $RC -eq 0 ] && touch /var/lock/subsys/opensm
183 if [ -f $PID_FILE ]; then
185 read line < $PID_FILE
187 [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid1="$pid1 $p"
191 pid2=`pidof -o $$ -o $PPID -o %PPID -x $bin`
193 pid=`echo "$pid1 $pid2" | sed -e 's/\ /\n/g' | sort -n | uniq | sed -e 's/\n/\ /g'`
195 if [ -n "${pid:-}" ] ; then
197 echo -n "Stopping IB Subnet Manager."
198 kill -15 $pid > /dev/null 2>&1
200 while [ $cnt -lt 6 -a $alive -ne 0 ]; do
204 if checkpid $p ; then alive=1; echo -n "-"; fi
212 while checkpid $p ; do
213 kill -KILL $p > /dev/null 2>&1
220 [ $RC -eq 0 ] && echo_failure || echo_success
224 echo -n "Stopping IB Subnet Manager."
230 # Remove pid file if any.
232 rm -f /var/lock/subsys/opensm
241 pid=`pidof -o $$ -o $PPID -o %PPID -x ${bin}`
242 if [ -n "$pid" ]; then
243 echo $"${bin} (pid $pid) is running..."
247 # Next try "/var/run/opensm.pid" files
248 if [ -f $PID_FILE ] ; then
250 if [ -n "$pid" ]; then
251 echo $"${bin} dead but pid file $PID_FILE exists"
255 echo $"${bin} is stopped"
276 pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
277 if [ -n "$pid" ]; then
285 echo "Usage: `basename $0` {start|stop|restart|status}"