[ofa-general] [PATCH] opensm/scripts: rename all opensm scripts as *.in

Sasha Khapyorsky sashak at voltaire.com
Sun Feb 24 10:24:34 PST 2008


Rename all OpenSM scripts as *.in, add this to configure's
AC_CONFIG_FILES.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/configure.in                  |    2 +-
 opensm/scripts/opensm.init           |  121 ---------
 opensm/scripts/opensm.init.in        |  121 +++++++++
 opensm/scripts/opensmd               |  466 ----------------------------------
 opensm/scripts/opensmd.in            |  466 ++++++++++++++++++++++++++++++++++
 opensm/scripts/redhat-opensm.init    |  382 ----------------------------
 opensm/scripts/redhat-opensm.init.in |  382 ++++++++++++++++++++++++++++
 opensm/scripts/sldd.sh               |  249 ------------------
 opensm/scripts/sldd.sh.in            |  249 ++++++++++++++++++
 9 files changed, 1219 insertions(+), 1219 deletions(-)
 delete mode 100644 opensm/scripts/opensm.init
 create mode 100644 opensm/scripts/opensm.init.in
 delete mode 100755 opensm/scripts/opensmd
 create mode 100755 opensm/scripts/opensmd.in
 delete mode 100755 opensm/scripts/redhat-opensm.init
 create mode 100755 opensm/scripts/redhat-opensm.init.in
 delete mode 100755 opensm/scripts/sldd.sh
 create mode 100755 opensm/scripts/sldd.sh.in

diff --git a/opensm/configure.in b/opensm/configure.in
index 3663d8d..5d2c267 100644
--- a/opensm/configure.in
+++ b/opensm/configure.in
@@ -176,7 +176,7 @@ OPENIB_APP_OSMV_CHECK_LIB
 # overrides.
 CFLAGS=$ac_env_CFLAGS_value
 
-AC_CONFIG_FILES([man/opensm.8])
+AC_CONFIG_FILES([man/opensm.8 scripts/opensm.init scripts/redhat-opensm.init scripts/opensmd scripts/sldd.sh])
 
 dnl Create the following Makefiles
 AC_OUTPUT([include/opensm/osm_version.h Makefile include/Makefile complib/Makefile libvendor/Makefile opensm/Makefile osmeventplugin/Makefile osmtest/Makefile opensm.spec])
diff --git a/opensm/scripts/opensm.init b/opensm/scripts/opensm.init
deleted file mode 100644
index d717279..0000000
--- a/opensm/scripts/opensm.init
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/bash
-#
-# opensm:		Manage OpenSM
-#
-# chkconfig: - 09 91
-# description:  Manage OpenSM
-#
-### BEGIN INIT INFO
-# Provides: opensm
-# Required-Start: $syslog
-# Default-Start:  2 3 5
-# Default-Stop: 0 1 6
-# Description:  Manage OpenSM
-### END INIT INFO
-#
-# Copyright 2006 PathScale, Inc.  All Rights Reserved.
-#
-# This Software is licensed under one of the following licenses:
-#
-# 1) under the terms of the "Common Public License 1.0" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/cpl.php.
-#
-# 2) under the terms of the "The BSD License" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/bsd-license.php.
-#
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
-#    copy of which is available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/gpl-license.php.
-#
-# Licensee has the right to choose one of the above licenses.
-#
-# Redistributions of source code must retain the above copyright
-# notice and one of the license notices.
-#
-# Redistributions in binary form must reproduce both the above copyright
-# notice, one of the license notices in the documentation
-# and/or other materials provided with the distribution.
-
-# Source function library.
-if [[ -s /etc/init.d/functions ]]; then
-    . /etc/init.d/functions
-    rc_status() { :; }
-    rc_exit() { exit $RETVAL; }
-fi
-if [[ -s /etc/rc.status ]]; then
-    . /etc/rc.status
-    failure() { rc_status -v; }
-    success() { rc_status -v; }
-fi
-if [[ -s /etc/sysconfig/opensm ]]; then
-    . /etc/sysconfig/opensm
-fi
-
-start () {
-    echo -n "Starting opensm: "
-    /usr/sbin/opensm -B $OPTIONS > /dev/null
-    if [[ $RETVAL -eq 0 ]]; then
-        touch /var/lock/subsys/opensm
-        success
-    else
-        failure
-    fi
-    echo
-}
-
-stop () {
-    echo -n "Shutting down opensm: "
-    killproc opensm
-    if [[ $RETVAL -eq 0 ]]; then
-        rm -f /var/lock/subsys/opensm
-        success
-    else
-        failure
-    fi
-    echo
-}
-
-Xstatus () {
-    status opensm
-}
-
-restart() {
-    stop
-    start
-}
-
-# See how we were called.
-case "$1" in
-    start)
-	start
-	;;
-    stop)
-	stop
-	;;
-    status)
-        Xstatus
-	;;
-    restart | force-reload | reload)
-	restart
-	;;
-    try-restart | condrestart)
-	[ -e /var/lock/subsys/opensm ] && restart
-	;;
-    resweep)
-	killall -HUP opensm
-        RETVAL=$?
-	;;
-    rotatelog)
-	killall -USR1 opensm
-        RETVAL=$?
-	;;
-    *)
-	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|resweep|rotatelog}"
-	RETVAL=1
-	;;
-esac
-
-_rc_status_all=$RETVAL
-rc_exit
diff --git a/opensm/scripts/opensm.init.in b/opensm/scripts/opensm.init.in
new file mode 100644
index 0000000..d717279
--- /dev/null
+++ b/opensm/scripts/opensm.init.in
@@ -0,0 +1,121 @@
+#!/bin/bash
+#
+# opensm:		Manage OpenSM
+#
+# chkconfig: - 09 91
+# description:  Manage OpenSM
+#
+### BEGIN INIT INFO
+# Provides: opensm
+# Required-Start: $syslog
+# Default-Start:  2 3 5
+# Default-Stop: 0 1 6
+# Description:  Manage OpenSM
+### END INIT INFO
+#
+# Copyright 2006 PathScale, Inc.  All Rights Reserved.
+#
+# This Software is licensed under one of the following licenses:
+#
+# 1) under the terms of the "Common Public License 1.0" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/cpl.php.
+#
+# 2) under the terms of the "The BSD License" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/bsd-license.php.
+#
+# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
+#    copy of which is available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/gpl-license.php.
+#
+# Licensee has the right to choose one of the above licenses.
+#
+# Redistributions of source code must retain the above copyright
+# notice and one of the license notices.
+#
+# Redistributions in binary form must reproduce both the above copyright
+# notice, one of the license notices in the documentation
+# and/or other materials provided with the distribution.
+
+# Source function library.
+if [[ -s /etc/init.d/functions ]]; then
+    . /etc/init.d/functions
+    rc_status() { :; }
+    rc_exit() { exit $RETVAL; }
+fi
+if [[ -s /etc/rc.status ]]; then
+    . /etc/rc.status
+    failure() { rc_status -v; }
+    success() { rc_status -v; }
+fi
+if [[ -s /etc/sysconfig/opensm ]]; then
+    . /etc/sysconfig/opensm
+fi
+
+start () {
+    echo -n "Starting opensm: "
+    /usr/sbin/opensm -B $OPTIONS > /dev/null
+    if [[ $RETVAL -eq 0 ]]; then
+        touch /var/lock/subsys/opensm
+        success
+    else
+        failure
+    fi
+    echo
+}
+
+stop () {
+    echo -n "Shutting down opensm: "
+    killproc opensm
+    if [[ $RETVAL -eq 0 ]]; then
+        rm -f /var/lock/subsys/opensm
+        success
+    else
+        failure
+    fi
+    echo
+}
+
+Xstatus () {
+    status opensm
+}
+
+restart() {
+    stop
+    start
+}
+
+# See how we were called.
+case "$1" in
+    start)
+	start
+	;;
+    stop)
+	stop
+	;;
+    status)
+        Xstatus
+	;;
+    restart | force-reload | reload)
+	restart
+	;;
+    try-restart | condrestart)
+	[ -e /var/lock/subsys/opensm ] && restart
+	;;
+    resweep)
+	killall -HUP opensm
+        RETVAL=$?
+	;;
+    rotatelog)
+	killall -USR1 opensm
+        RETVAL=$?
+	;;
+    *)
+	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|resweep|rotatelog}"
+	RETVAL=1
+	;;
+esac
+
+_rc_status_all=$RETVAL
+rc_exit
diff --git a/opensm/scripts/opensmd b/opensm/scripts/opensmd
deleted file mode 100755
index 848d1cd..0000000
--- a/opensm/scripts/opensmd
+++ /dev/null
@@ -1,466 +0,0 @@
-#!/bin/bash
-
-#
-# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
-#
-# This Software is licensed under one of the following licenses:
-#
-# 1) under the terms of the "Common Public License 1.0" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/cpl.php.
-#
-# 2) under the terms of the "The BSD License" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/bsd-license.php.
-#
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
-#    copy of which is available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/gpl-license.php.
-#
-# Licensee has the right to choose one of the above licenses.
-#
-# Redistributions of source code must retain the above copyright
-# notice and one of the license notices.
-#
-# Redistributions in binary form must reproduce both the above copyright
-# notice, one of the license notices in the documentation
-# and/or other materials provided with the distribution.
-#
-#
-# processname: /usr/sbin/opensm
-# config: /etc/opensm.conf
-# pidfile: /var/run/opensm.pid
-
-if [ ! -f /etc/opensm.conf ]; then
-    exit 0
-fi
-
-. /etc/opensm.conf
-
-CONFIG=/etc/opensm.conf
-
-prog=/usr/sbin/opensm
-bin=${prog##*/}
-
-# Handover daemon for updating guid2lid cache file
-sldd_prog=/usr/sbin/sldd.sh
-sldd_bin=${sldd_prog##*/}
-sldd_pid_file=/var/run/sldd.pid
-
-# Only use ONBOOT option if called by a runlevel directory.
-# Therefore determine the base, follow a runlevel link name ...
-base=${0##*/}
-link=${base#*[SK][0-9][0-9]}
-# ... and compare them
-if [ $link == $base ] ; then
-    ONBOOT=yes
-fi
-
-ACTION=$1
-shift
-
-if [ ! -x  $prog ]; then
-    echo "OpenSM not installed"
-    exit 1
-fi
-
-# Check if OpenSM configured to start automatically
-if [[ -z $ONBOOT || "$ONBOOT" != "yes" ]]; then
-    exit 0
-fi
-
-if ( grep -i 'SuSE Linux' /etc/issue >/dev/null 2>&1 ); then
-    if [ -n "$INIT_VERSION" ] ; then
-        # MODE=onboot
-        if LANG=C egrep -L "^ONBOOT=['\"]?[Nn][Oo]['\"]?" ${CONFIG} > /dev/null ; then
-            exit 0
-        fi
-    fi
-fi
-
-if [ -f /etc/init.d/functions ]; then
-    . /etc/init.d/functions
-fi
-
-# Setting OpenSM start parameters
-PID_FILE=/var/run/${bin}.pid
-touch $PID_FILE
-
-if [[ -z $DEBUG || "$DEBUG" == "none" ]]; then
-    DEBUG_FLAG=""
-else
-    DEBUG_FLAG="-d ${DEBUG}"
-fi
-
-if [[ -z $LMC || "$LMC" == "0" ]]; then
-    LMC_FLAG=""
-else
-    LMC_FLAG="-l ${LMC}"
-fi
-
-if [[ -z $MAXSMPS || "$MAXSMPS" == "4" ]]; then
-    MAXSMPS_FLAG=""
-else
-    MAXSMPS_FLAG="-maxsmps ${MAXSMPS}"
-fi
-
-if [[ -z $REASSIGN_LIDS || "$REASSIGN_LIDS" == "no" ]]; then
-    REASSIGN_LIDS_FLAG=""
-else
-    REASSIGN_LIDS_FLAG="-r"
-fi
-
-if [[ -z $SWEEP || "$SWEEP" == "10" ]]; then
-    SWEEP_FLAG=""
-else
-    SWEEP_FLAG="-s ${SWEEP}"
-fi
-
-if [[ -z $TIMEOUT || "$TIMEOUT" == "100" ]]; then
-    TIMEOUT_FLAG=""
-else
-    TIMEOUT_FLAG="-t ${TIMEOUT}"
-fi
-
-if [[ -z $OSM_LOG || "$OSM_LOG" == "/var/log/osm.log" ]]; then
-    OSM_LOG_FLAG=""
-else
-    OSM_LOG_FLAG="-f ${OSM_LOG}"
-fi
-
-if [[ -z $VERBOSE || "$VERBOSE" == "none" ]]; then
-    VERBOSE_FLAG=""
-else
-    VERBOSE_FLAG="${VERBOSE}"
-fi
-
-if [[ -z $UPDN || "$UPDN" == "off" ]]; then
-    UPDN_FLAG=""
-else
-    UPDN_FLAG="-u"
-fi
-
-if [[ -z $GUID_FILE || "$GUID_FILE" == "none" ]]; then
-    GUID_FILE_FLAG=""
-else
-    GUID_FILE_FLAG="-a ${GUID_FILE}"
-fi
-
-if [[ -z $GUID || "$GUID" == "none" ]]; then
-    GUID_FLAG=""
-else
-    GUID_FLAG="-g ${GUID}"
-fi
-
-if [[ -z $HONORE_GUID2LID || "$HONORE_GUID2LID" == "none" ]]; then
-    HONORE_GUID2LID_FLAG=""
-else
-    HONORE_GUID2LID_FLAG="--honor_guid2lid"
-fi
-
-if [[ -n "${OSM_HOSTS}" && $(echo -n ${OSM_HOSTS} | wc -w | tr -d '[:space:]') -gt 1  ]]; then
-    HONORE_GUID2LID_FLAG="--honor_guid2lid"
-fi
-
-
-if [[ -z $CACHE_OPTIONS || "$CACHE_OPTIONS" == "none" ]]; then
-    CACHE_OPTIONS_FLAG=""
-else
-    CACHE_OPTIONS_FLAG="--cache-options"
-fi
-
-
-if [ -z $PORT_NUM ]; then
-    PORT_FLAG=1
-else
-    PORT_FLAG="${PORT_NUM}"
-fi
-
-
-#########################################################################
-# Get a sane screen width
-[ -z "${COLUMNS:-}" ] && COLUMNS=80
-
-[ -z "${CONSOLETYPE:-}" ] && [ -x /sbin/consoletype ] && CONSOLETYPE="`/sbin/consoletype`"
-
-if [ -f /etc/sysconfig/i18n -a -z "${NOLOCALE:-}" ] ; then
-  . /etc/sysconfig/i18n
-  if [ "$CONSOLETYPE" != "pty" ]; then
-        case "${LANG:-}" in
-                ja_JP*|ko_KR*|zh_CN*|zh_TW*)
-                        export LC_MESSAGES=en_US
-                        ;;
-                *)
-                        export LANG
-                        ;;
-        esac
-  else
-        export LANG
-  fi
-fi
-
-# Read in our configuration
-if [ -z "${BOOTUP:-}" ]; then
-  if [ -f /etc/sysconfig/init ]; then
-      . /etc/sysconfig/init
-  else
-    # This all seem confusing? Look in /etc/sysconfig/init,
-    # or in /usr/doc/initscripts-*/sysconfig.txt
-    BOOTUP=color
-    RES_COL=60
-    MOVE_TO_COL="echo -en \\033[${RES_COL}G"
-    SETCOLOR_SUCCESS="echo -en \\033[1;32m"
-    SETCOLOR_FAILURE="echo -en \\033[1;31m"
-    SETCOLOR_WARNING="echo -en \\033[1;33m"
-    SETCOLOR_NORMAL="echo -en \\033[0;39m"
-    LOGLEVEL=1
-  fi
-  if [ "$CONSOLETYPE" = "serial" ]; then
-      BOOTUP=serial
-      MOVE_TO_COL=
-      SETCOLOR_SUCCESS=
-      SETCOLOR_FAILURE=
-      SETCOLOR_WARNING=
-      SETCOLOR_NORMAL=
-  fi
-fi
-
-if [ "${BOOTUP:-}" != "verbose" ]; then
-   INITLOG_ARGS="-q"
-else
-   INITLOG_ARGS=
-fi
-
-echo_success() {
-  echo -n $@
-  [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
-  echo -n "[  "
-  [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
-  echo -n $"OK"
-  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
-  echo -n "  ]"
-  echo -e "\r"
-  return 0
-}
-
-echo_failure() {
-  echo -n $@
-  [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
-  echo -n "["
-  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
-  echo -n $"FAILED"
-  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
-  echo -n "]"
-  echo -e "\r"
-  return 1
-}
-
-
-#########################################################################
-
-# Check if $pid (could be plural) are running
-checkpid() {
-        local i
-
-        for i in $* ; do
-                [ -d "/proc/$i" ] || return 1
-        done
-        return 0
-}
-
-start_sldd()
-{
-    if [ -f $sldd_pid_file ]; then
-            local line p
-            read line < $sldd_pid_file
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
-            done
-    fi
-
-    if [ -z "$sldd_pid" ]; then
-        sldd_pid=`pidof -x $sldd_bin`
-    fi
-
-    if [ -n "${sldd_pid:-}" ] ; then
-	kill -9 ${sldd_pid} > /dev/null 2>&1
-    fi
-
-    $sldd_prog > /dev/null 2>&1 &
-    sldd_pid=$!
-
-    echo ${sldd_pid} > $sldd_pid_file
-    # Sleep is needed in order to update local gid2lid cache file before running opensm
-    sleep 3
-}
-
-stop_sldd()
-{
-    if [ -f $sldd_pid_file ]; then
-            local line p
-            read line < $sldd_pid_file
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
-            done
-    fi
-
-    if [ -z "$sldd_pid" ]; then
-        sldd_pid=`pidof -x $sldd_bin`
-    fi
-
-    if [ -n "${sldd_pid:-}" ] ; then
-        kill -15 ${sldd_pid} > /dev/null 2>&1
-    fi
-
-}
-
-start()
-{
-    if [ ! -d /sys/class/infiniband ]; then
-        echo
-        echo "Please load Infiniband driver first"
-        echo
-        return 2
-    fi
-
-    local OSM_PID=
-
-    if [ -f $PID_FILE ]; then
-            local line p
-            read line < $PID_FILE
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
-            done
-    fi
-
-    if [ -z "$pid" ]; then
-        pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
-    fi
-
-    if [ -n "${pid:-}" ] ; then
-        echo $"${bin} (pid $pid) is already running..."
-    else
-
-	if [ -n "${HONORE_GUID2LID_FLAG}" ]; then
-		# Run sldd daemod
-		start_sldd
-	fi
-
-        # Start opensm
-        local START_FLAGS=""
-        for flag in "$DEBUG_FLAG" "$LMC_FLAG" "$MAXSMPS_FLAG" "$REASSIGN_LIDS_FLAG" "$SWEEP_FLAG" "$TIMEOUT_FLAG" "$OSM_LOG_FLAG" "$VERBOSE_FLAG" "$UPDN_FLAG" "$GUID_FILE_FLAG" "$GUID_FLAG" "$HONORE_GUID2LID_FLAG" "$CACHE_OPTIONS_FLAG"
-        do
-            [ ! -z "$flag" ] && START_FLAGS="$START_FLAGS $flag"
-        done
-
-        echo $PORT_FLAG | $prog $START_FLAGS > /dev/null 2>&1 &
-        OSM_PID=$!
-        echo $OSM_PID > $PID_FILE
-	sleep 1
-        checkpid $OSM_PID
-        RC=$?
-        [ $RC -eq 0 ] && echo_success "$bin start" || echo_failure "$bin start"
-
-    fi
-return $RC
-}
-
-stop()
-{
-    local pid=
-    local pid1=
-    local pid2=
-
-    # Stop sldd daemon
-    stop_sldd
-
-    if [ -f $PID_FILE ]; then
-            local line p
-            read line < $PID_FILE
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid1="$pid1 $p"
-            done
-    fi
-
-    pid2=`pidof -o $$ -o $PPID -o %PPID -x $bin`
-
-    pid=`echo "$pid1 $pid2" | sed -e 's/\ /\n/g' | sort -n | uniq | sed -e 's/\n/\ /g'`
-
-    if [ -n "${pid:-}" ] ; then
-        # Kill opensm
-        kill -15 $pid > /dev/null 2>&1
-		cnt=0
-        while [ $cnt -lt 6 ]; do echo -n "."; sleep 1; let cnt++;done
-
-        for p in $pid
-        do
-            while checkpid $p ; do
-                kill -KILL $p > /dev/null 2>&1
-                echo -n "."
-                sleep 1
-            done
-        done
-        echo
-        checkpid $pid
-        RC=$?
-        [ $RC -eq 0 ] && echo_failure "$bin shutdown" || echo_success "$bin shutdown"
-        RC=$((! $RC))
-    else
-        echo_failure "$bin shutdown"
-        RC=1
-    fi
-
-    # Remove pid file if any.
-    rm -f $PID_FILE
-return $RC
-}
-
-status()
-{
-    local pid
-
-    # First try "pidof"
-    pid=`pidof -o $$ -o $PPID -o %PPID -x ${bin}`
-    if [ -n "$pid" ]; then
-            echo $"${bin} (pid $pid) is running..."
-            return 0
-    fi
-
-     # Next try "/var/run/opensm.pid" files
-     if [ -f $PID_FILE ] ; then
-             read pid < $PID_FILE
-             if [ -n "$pid" ]; then
-                     echo $"${bin} dead but pid file $PID_FILE exists"
-                     return 1
-             fi
-     fi
-     echo $"${bin} is stopped"
-     return 3
-}
-
-
-
-case $ACTION in
-	start)
-                start
-		;;
-	stop)
-		stop
-		;;
-	restart)
-		stop
-                start
-		;;
-	status)
-		status
-		;;
-	*)
-		echo
-		echo "Usage: `basename $0` {start|stop|restart|status}"
-		echo
-		exit 1
-		;;
-esac
-
-RC=$?
-exit $RC
diff --git a/opensm/scripts/opensmd.in b/opensm/scripts/opensmd.in
new file mode 100755
index 0000000..848d1cd
--- /dev/null
+++ b/opensm/scripts/opensmd.in
@@ -0,0 +1,466 @@
+#!/bin/bash
+
+#
+# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
+#
+# This Software is licensed under one of the following licenses:
+#
+# 1) under the terms of the "Common Public License 1.0" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/cpl.php.
+#
+# 2) under the terms of the "The BSD License" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/bsd-license.php.
+#
+# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
+#    copy of which is available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/gpl-license.php.
+#
+# Licensee has the right to choose one of the above licenses.
+#
+# Redistributions of source code must retain the above copyright
+# notice and one of the license notices.
+#
+# Redistributions in binary form must reproduce both the above copyright
+# notice, one of the license notices in the documentation
+# and/or other materials provided with the distribution.
+#
+#
+# processname: /usr/sbin/opensm
+# config: /etc/opensm.conf
+# pidfile: /var/run/opensm.pid
+
+if [ ! -f /etc/opensm.conf ]; then
+    exit 0
+fi
+
+. /etc/opensm.conf
+
+CONFIG=/etc/opensm.conf
+
+prog=/usr/sbin/opensm
+bin=${prog##*/}
+
+# Handover daemon for updating guid2lid cache file
+sldd_prog=/usr/sbin/sldd.sh
+sldd_bin=${sldd_prog##*/}
+sldd_pid_file=/var/run/sldd.pid
+
+# Only use ONBOOT option if called by a runlevel directory.
+# Therefore determine the base, follow a runlevel link name ...
+base=${0##*/}
+link=${base#*[SK][0-9][0-9]}
+# ... and compare them
+if [ $link == $base ] ; then
+    ONBOOT=yes
+fi
+
+ACTION=$1
+shift
+
+if [ ! -x  $prog ]; then
+    echo "OpenSM not installed"
+    exit 1
+fi
+
+# Check if OpenSM configured to start automatically
+if [[ -z $ONBOOT || "$ONBOOT" != "yes" ]]; then
+    exit 0
+fi
+
+if ( grep -i 'SuSE Linux' /etc/issue >/dev/null 2>&1 ); then
+    if [ -n "$INIT_VERSION" ] ; then
+        # MODE=onboot
+        if LANG=C egrep -L "^ONBOOT=['\"]?[Nn][Oo]['\"]?" ${CONFIG} > /dev/null ; then
+            exit 0
+        fi
+    fi
+fi
+
+if [ -f /etc/init.d/functions ]; then
+    . /etc/init.d/functions
+fi
+
+# Setting OpenSM start parameters
+PID_FILE=/var/run/${bin}.pid
+touch $PID_FILE
+
+if [[ -z $DEBUG || "$DEBUG" == "none" ]]; then
+    DEBUG_FLAG=""
+else
+    DEBUG_FLAG="-d ${DEBUG}"
+fi
+
+if [[ -z $LMC || "$LMC" == "0" ]]; then
+    LMC_FLAG=""
+else
+    LMC_FLAG="-l ${LMC}"
+fi
+
+if [[ -z $MAXSMPS || "$MAXSMPS" == "4" ]]; then
+    MAXSMPS_FLAG=""
+else
+    MAXSMPS_FLAG="-maxsmps ${MAXSMPS}"
+fi
+
+if [[ -z $REASSIGN_LIDS || "$REASSIGN_LIDS" == "no" ]]; then
+    REASSIGN_LIDS_FLAG=""
+else
+    REASSIGN_LIDS_FLAG="-r"
+fi
+
+if [[ -z $SWEEP || "$SWEEP" == "10" ]]; then
+    SWEEP_FLAG=""
+else
+    SWEEP_FLAG="-s ${SWEEP}"
+fi
+
+if [[ -z $TIMEOUT || "$TIMEOUT" == "100" ]]; then
+    TIMEOUT_FLAG=""
+else
+    TIMEOUT_FLAG="-t ${TIMEOUT}"
+fi
+
+if [[ -z $OSM_LOG || "$OSM_LOG" == "/var/log/osm.log" ]]; then
+    OSM_LOG_FLAG=""
+else
+    OSM_LOG_FLAG="-f ${OSM_LOG}"
+fi
+
+if [[ -z $VERBOSE || "$VERBOSE" == "none" ]]; then
+    VERBOSE_FLAG=""
+else
+    VERBOSE_FLAG="${VERBOSE}"
+fi
+
+if [[ -z $UPDN || "$UPDN" == "off" ]]; then
+    UPDN_FLAG=""
+else
+    UPDN_FLAG="-u"
+fi
+
+if [[ -z $GUID_FILE || "$GUID_FILE" == "none" ]]; then
+    GUID_FILE_FLAG=""
+else
+    GUID_FILE_FLAG="-a ${GUID_FILE}"
+fi
+
+if [[ -z $GUID || "$GUID" == "none" ]]; then
+    GUID_FLAG=""
+else
+    GUID_FLAG="-g ${GUID}"
+fi
+
+if [[ -z $HONORE_GUID2LID || "$HONORE_GUID2LID" == "none" ]]; then
+    HONORE_GUID2LID_FLAG=""
+else
+    HONORE_GUID2LID_FLAG="--honor_guid2lid"
+fi
+
+if [[ -n "${OSM_HOSTS}" && $(echo -n ${OSM_HOSTS} | wc -w | tr -d '[:space:]') -gt 1  ]]; then
+    HONORE_GUID2LID_FLAG="--honor_guid2lid"
+fi
+
+
+if [[ -z $CACHE_OPTIONS || "$CACHE_OPTIONS" == "none" ]]; then
+    CACHE_OPTIONS_FLAG=""
+else
+    CACHE_OPTIONS_FLAG="--cache-options"
+fi
+
+
+if [ -z $PORT_NUM ]; then
+    PORT_FLAG=1
+else
+    PORT_FLAG="${PORT_NUM}"
+fi
+
+
+#########################################################################
+# Get a sane screen width
+[ -z "${COLUMNS:-}" ] && COLUMNS=80
+
+[ -z "${CONSOLETYPE:-}" ] && [ -x /sbin/consoletype ] && CONSOLETYPE="`/sbin/consoletype`"
+
+if [ -f /etc/sysconfig/i18n -a -z "${NOLOCALE:-}" ] ; then
+  . /etc/sysconfig/i18n
+  if [ "$CONSOLETYPE" != "pty" ]; then
+        case "${LANG:-}" in
+                ja_JP*|ko_KR*|zh_CN*|zh_TW*)
+                        export LC_MESSAGES=en_US
+                        ;;
+                *)
+                        export LANG
+                        ;;
+        esac
+  else
+        export LANG
+  fi
+fi
+
+# Read in our configuration
+if [ -z "${BOOTUP:-}" ]; then
+  if [ -f /etc/sysconfig/init ]; then
+      . /etc/sysconfig/init
+  else
+    # This all seem confusing? Look in /etc/sysconfig/init,
+    # or in /usr/doc/initscripts-*/sysconfig.txt
+    BOOTUP=color
+    RES_COL=60
+    MOVE_TO_COL="echo -en \\033[${RES_COL}G"
+    SETCOLOR_SUCCESS="echo -en \\033[1;32m"
+    SETCOLOR_FAILURE="echo -en \\033[1;31m"
+    SETCOLOR_WARNING="echo -en \\033[1;33m"
+    SETCOLOR_NORMAL="echo -en \\033[0;39m"
+    LOGLEVEL=1
+  fi
+  if [ "$CONSOLETYPE" = "serial" ]; then
+      BOOTUP=serial
+      MOVE_TO_COL=
+      SETCOLOR_SUCCESS=
+      SETCOLOR_FAILURE=
+      SETCOLOR_WARNING=
+      SETCOLOR_NORMAL=
+  fi
+fi
+
+if [ "${BOOTUP:-}" != "verbose" ]; then
+   INITLOG_ARGS="-q"
+else
+   INITLOG_ARGS=
+fi
+
+echo_success() {
+  echo -n $@
+  [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
+  echo -n "[  "
+  [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
+  echo -n $"OK"
+  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
+  echo -n "  ]"
+  echo -e "\r"
+  return 0
+}
+
+echo_failure() {
+  echo -n $@
+  [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
+  echo -n "["
+  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
+  echo -n $"FAILED"
+  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
+  echo -n "]"
+  echo -e "\r"
+  return 1
+}
+
+
+#########################################################################
+
+# Check if $pid (could be plural) are running
+checkpid() {
+        local i
+
+        for i in $* ; do
+                [ -d "/proc/$i" ] || return 1
+        done
+        return 0
+}
+
+start_sldd()
+{
+    if [ -f $sldd_pid_file ]; then
+            local line p
+            read line < $sldd_pid_file
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
+            done
+    fi
+
+    if [ -z "$sldd_pid" ]; then
+        sldd_pid=`pidof -x $sldd_bin`
+    fi
+
+    if [ -n "${sldd_pid:-}" ] ; then
+	kill -9 ${sldd_pid} > /dev/null 2>&1
+    fi
+
+    $sldd_prog > /dev/null 2>&1 &
+    sldd_pid=$!
+
+    echo ${sldd_pid} > $sldd_pid_file
+    # Sleep is needed in order to update local gid2lid cache file before running opensm
+    sleep 3
+}
+
+stop_sldd()
+{
+    if [ -f $sldd_pid_file ]; then
+            local line p
+            read line < $sldd_pid_file
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
+            done
+    fi
+
+    if [ -z "$sldd_pid" ]; then
+        sldd_pid=`pidof -x $sldd_bin`
+    fi
+
+    if [ -n "${sldd_pid:-}" ] ; then
+        kill -15 ${sldd_pid} > /dev/null 2>&1
+    fi
+
+}
+
+start()
+{
+    if [ ! -d /sys/class/infiniband ]; then
+        echo
+        echo "Please load Infiniband driver first"
+        echo
+        return 2
+    fi
+
+    local OSM_PID=
+
+    if [ -f $PID_FILE ]; then
+            local line p
+            read line < $PID_FILE
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
+            done
+    fi
+
+    if [ -z "$pid" ]; then
+        pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
+    fi
+
+    if [ -n "${pid:-}" ] ; then
+        echo $"${bin} (pid $pid) is already running..."
+    else
+
+	if [ -n "${HONORE_GUID2LID_FLAG}" ]; then
+		# Run sldd daemod
+		start_sldd
+	fi
+
+        # Start opensm
+        local START_FLAGS=""
+        for flag in "$DEBUG_FLAG" "$LMC_FLAG" "$MAXSMPS_FLAG" "$REASSIGN_LIDS_FLAG" "$SWEEP_FLAG" "$TIMEOUT_FLAG" "$OSM_LOG_FLAG" "$VERBOSE_FLAG" "$UPDN_FLAG" "$GUID_FILE_FLAG" "$GUID_FLAG" "$HONORE_GUID2LID_FLAG" "$CACHE_OPTIONS_FLAG"
+        do
+            [ ! -z "$flag" ] && START_FLAGS="$START_FLAGS $flag"
+        done
+
+        echo $PORT_FLAG | $prog $START_FLAGS > /dev/null 2>&1 &
+        OSM_PID=$!
+        echo $OSM_PID > $PID_FILE
+	sleep 1
+        checkpid $OSM_PID
+        RC=$?
+        [ $RC -eq 0 ] && echo_success "$bin start" || echo_failure "$bin start"
+
+    fi
+return $RC
+}
+
+stop()
+{
+    local pid=
+    local pid1=
+    local pid2=
+
+    # Stop sldd daemon
+    stop_sldd
+
+    if [ -f $PID_FILE ]; then
+            local line p
+            read line < $PID_FILE
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid1="$pid1 $p"
+            done
+    fi
+
+    pid2=`pidof -o $$ -o $PPID -o %PPID -x $bin`
+
+    pid=`echo "$pid1 $pid2" | sed -e 's/\ /\n/g' | sort -n | uniq | sed -e 's/\n/\ /g'`
+
+    if [ -n "${pid:-}" ] ; then
+        # Kill opensm
+        kill -15 $pid > /dev/null 2>&1
+		cnt=0
+        while [ $cnt -lt 6 ]; do echo -n "."; sleep 1; let cnt++;done
+
+        for p in $pid
+        do
+            while checkpid $p ; do
+                kill -KILL $p > /dev/null 2>&1
+                echo -n "."
+                sleep 1
+            done
+        done
+        echo
+        checkpid $pid
+        RC=$?
+        [ $RC -eq 0 ] && echo_failure "$bin shutdown" || echo_success "$bin shutdown"
+        RC=$((! $RC))
+    else
+        echo_failure "$bin shutdown"
+        RC=1
+    fi
+
+    # Remove pid file if any.
+    rm -f $PID_FILE
+return $RC
+}
+
+status()
+{
+    local pid
+
+    # First try "pidof"
+    pid=`pidof -o $$ -o $PPID -o %PPID -x ${bin}`
+    if [ -n "$pid" ]; then
+            echo $"${bin} (pid $pid) is running..."
+            return 0
+    fi
+
+     # Next try "/var/run/opensm.pid" files
+     if [ -f $PID_FILE ] ; then
+             read pid < $PID_FILE
+             if [ -n "$pid" ]; then
+                     echo $"${bin} dead but pid file $PID_FILE exists"
+                     return 1
+             fi
+     fi
+     echo $"${bin} is stopped"
+     return 3
+}
+
+
+
+case $ACTION in
+	start)
+                start
+		;;
+	stop)
+		stop
+		;;
+	restart)
+		stop
+                start
+		;;
+	status)
+		status
+		;;
+	*)
+		echo
+		echo "Usage: `basename $0` {start|stop|restart|status}"
+		echo
+		exit 1
+		;;
+esac
+
+RC=$?
+exit $RC
diff --git a/opensm/scripts/redhat-opensm.init b/opensm/scripts/redhat-opensm.init
deleted file mode 100755
index 3e00403..0000000
--- a/opensm/scripts/redhat-opensm.init
+++ /dev/null
@@ -1,382 +0,0 @@
-#!/bin/bash
-#
-# Bring up/down opensm
-#
-# chkconfig: - 15 85
-# description: Activates/Deactivates InfiniBand Subnet Manager
-#
-### BEGIN INIT INFO
-# Provides:       opensm
-### END INIT INFO
-#
-# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
-#
-# This Software is licensed under one of the following licenses:
-#
-# 1) under the terms of the "Common Public License 1.0" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/cpl.php.
-#
-# 2) under the terms of the "The BSD License" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/bsd-license.php.
-#
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
-#    copy of which is available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/gpl-license.php.
-#
-# Licensee has the right to choose one of the above licenses.
-#
-# Redistributions of source code must retain the above copyright
-# notice and one of the license notices.
-#
-# Redistributions in binary form must reproduce both the above copyright
-# notice, one of the license notices in the documentation
-# and/or other materials provided with the distribution.
-#
-#
-#  $Id: openib-1.0-opensm.init,v 1.5 2006/08/02 18:18:23 dledford Exp $
-#
-# processname: /usr/sbin/opensm
-# config: /etc/ofa/opensm.conf
-# pidfile: /var/run/opensm.pid
-. /etc/rc.d/init.d/functions
-
-CONFIG=/etc/ofa/opensm.conf
-if [ ! -f $CONFIG ]; then
-    exit 0
-fi
-
-. $CONFIG
-
-prog=/usr/sbin/opensm
-bin=${prog##*/}
-
-# Handover daemon for updating guid2lid cache file
-sldd_prog=/usr/sbin/sldd.sh
-sldd_bin=${sldd_prog##*/}
-sldd_pid_file=/var/run/sldd.pid
-
-ACTION=$1
-
-# Setting OpenSM start parameters
-PID_FILE=/var/run/${bin}.pid
-touch $PID_FILE
-
-if [[ -z $DEBUG || "$DEBUG" == "none" ]]; then
-    DEBUG_FLAG=""
-else
-    DEBUG_FLAG="-d ${DEBUG}"
-fi
-
-if [[ -z $LMC || "$LMC" == "0" ]]; then
-    LMC_FLAG=""
-else
-    LMC_FLAG="-l ${LMC}"
-fi
-
-if [[ -z $MAXSMPS || "$MAXSMPS" == "4" ]]; then
-    MAXSMPS_FLAG=""
-else
-    MAXSMPS_FLAG="-maxsmps ${MAXSMPS}"
-fi
-
-if [[ -z $REASSIGN_LIDS || "$REASSIGN_LIDS" == "no" ]]; then
-    REASSIGN_LIDS_FLAG=""
-else
-    REASSIGN_LIDS_FLAG="-r"
-fi
-
-if [[ -z $SWEEP || "$SWEEP" == "10" ]]; then
-    SWEEP_FLAG=""
-else
-    SWEEP_FLAG="-s ${SWEEP}"
-fi
-
-if [[ -z $TIMEOUT || "$TIMEOUT" == "100" ]]; then
-    TIMEOUT_FLAG=""
-else
-    TIMEOUT_FLAG="-t ${TIMEOUT}"
-fi
-
-if [[ -z $OSM_LOG || "$OSM_LOG" == "/tmp/osm.log" ]]; then
-    OSM_LOG_FLAG=""
-else
-    OSM_LOG_FLAG="-f ${OSM_LOG}"
-fi
-
-if [[ -z $VERBOSE || "$VERBOSE" == "none" ]]; then
-    VERBOSE_FLAG=""
-else
-    VERBOSE_FLAG="${VERBOSE}"
-fi
-
-if [[ -z $UPDN || "$UPDN" == "off" ]]; then
-    UPDN_FLAG=""
-else
-    UPDN_FLAG="-u"
-fi
-
-if [[ -z $GUID_FILE || "$GUID_FILE" == "none" ]]; then
-    GUID_FILE_FLAG=""
-else
-    GUID_FILE_FLAG="-a ${GUID_FILE}"
-fi
-
-if [[ -z $GUID || "$GUID" == "none" ]]; then
-    GUID_FLAG=""
-else
-    GUID_FLAG="-g ${GUID}"
-fi
-
-if [[ -z $HONORE_GUID2LID || "$HONORE_GUID2LID" == "none" ]]; then
-    HONORE_GUID2LID_FLAG=""
-else
-    HONORE_GUID2LID_FLAG="--honor_guid2lid"
-fi
-
-if [[ -n "${OSM_HOSTS}" && $(echo -n ${OSM_HOSTS} | wc -w | tr -d '[:space:]') -gt 1  ]]; then
-    HONORE_GUID2LID_FLAG="--honor_guid2lid"
-fi
-
-
-if [[ -z $CACHE_OPTIONS || "$CACHE_OPTIONS" == "none" ]]; then
-    CACHE_OPTIONS_FLAG=""
-else
-    CACHE_OPTIONS_FLAG="--cache-options"
-fi
-
-
-if [ -z $PORT_NUM ]; then
-    PORT_FLAG=1
-else
-    PORT_FLAG="${PORT_NUM}"
-fi
-
-
-#########################################################################
-
-start_sldd()
-{
-    if [ -f $sldd_pid_file ]; then
-            local line p
-            read line < $sldd_pid_file
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
-            done
-    fi
-
-    if [ -z "$sldd_pid" ]; then
-        sldd_pid=`pidof -x $sldd_bin`
-    fi
-
-    if [ -n "${sldd_pid:-}" ] ; then
-	kill -9 ${sldd_pid} > /dev/null 2>&1
-    fi
-
-    $sldd_prog > /dev/null 2>&1 &
-    sldd_pid=$!
-
-    echo ${sldd_pid} > $sldd_pid_file
-    # Sleep is needed in order to update local gid2lid cache file before running opensm
-    sleep 3
-}
-
-stop_sldd()
-{
-    if [ -f $sldd_pid_file ]; then
-            local line p
-            read line < $sldd_pid_file
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
-            done
-    fi
-
-    if [ -z "$sldd_pid" ]; then
-        sldd_pid=`pidof -x $sldd_bin`
-    fi
-
-    if [ -n "${sldd_pid:-}" ] ; then
-        kill -15 ${sldd_pid} > /dev/null 2>&1
-    fi
-
-}
-
-start()
-{
-    local OSM_PID=
-
-    pid=""
-
-    if [ -f $PID_FILE ]; then
-            local line p
-            read line < $PID_FILE
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
-            done
-    fi
-
-    if [ -z "$pid" ]; then
-        pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
-    fi
-
-    if [ -n "${pid:-}" ] ; then
-        echo $"${bin} (pid $pid) is already running..."
-    else
-
-	if [ -n "${HONORE_GUID2LID_FLAG}" ]; then
-		# Run sldd daemod
-		start_sldd
-	fi
-
-        # Start opensm
-        local START_FLAGS=""
-        for flag in "$DEBUG_FLAG" "$LMC_FLAG" "$MAXSMPS_FLAG" "$REASSIGN_LIDS_FLAG" "$SWEEP_FLAG" "$TIMEOUT_FLAG" "$OSM_LOG_FLAG" "$VERBOSE_FLAG" "$UPDN_FLAG" "$GUID_FILE_FLAG" "$GUID_FLAG" "$HONORE_GUID2LID_FLAG" "$CACHE_OPTIONS_FLAG"
-        do
-            [ ! -z "$flag" ] && START_FLAGS="$START_FLAGS $flag"
-        done
-
-	echo -n "Starting IB Subnet Manager"
-        echo $PORT_FLAG | $prog $START_FLAGS > /dev/null 2>&1 &
-        cnt=0; alive=0
-        while [ $cnt -lt 6 -a $alive -ne 1 ]; do
-		echo -n ".";
-		sleep 1
-		alive=0
-                OSM_PID=`pidof $prog`
-                if [ "$OSM_PID" != "" ]; then
-                        alive=1
-                fi
-		let cnt++;
-	done
-
-        echo $OSM_PID > $PID_FILE
-        checkpid $OSM_PID
-        RC=$?
-        [ $RC -eq 0 ] && echo_success || echo_failure
-        [ $RC -eq 0 ] && touch /var/lock/subsys/opensm
-	echo
-
-    fi
-return $RC
-}
-
-stop()
-{
-    local pid=
-    local pid1=
-    local pid2=
-
-    # Stop sldd daemon
-    stop_sldd
-
-    if [ -f $PID_FILE ]; then
-            local line p
-            read line < $PID_FILE
-            for p in $line ; do
-                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid1="$pid1 $p"
-            done
-    fi
-
-    pid2=`pidof -o $$ -o $PPID -o %PPID -x $bin`
-
-    pid=`echo "$pid1 $pid2" | sed -e 's/\ /\n/g' | sort -n | uniq | sed -e 's/\n/\ /g'`
-
-    if [ -n "${pid:-}" ] ; then
-        # Kill opensm
-	echo -n "Stopping IB Subnet Manager."
-        kill -15 $pid > /dev/null 2>&1
-		cnt=0; alive=1
-        while [ $cnt -lt 6 -a $alive -ne 0 ]; do
-		echo -n ".";
-		alive=0
-		for p in $pid; do
-			if checkpid $p ; then alive=1; echo -n "-"; fi
-		done
-		let cnt++;
-		sleep $alive
-	done
-
-        for p in $pid
-        do
-            while checkpid $p ; do
-                kill -KILL $p > /dev/null 2>&1
-                echo -n "+"
-                sleep 1
-            done
-        done
-        checkpid $pid
-        RC=$?
-        [ $RC -eq 0 ] && echo_failure || echo_success
-	echo
-        RC=$((! $RC))
-    else
-	echo -n "Stopping IB Subnet Manager."
-        echo_failure
-	echo
-        RC=1
-    fi
-
-    # Remove pid file if any.
-    rm -f $PID_FILE
-    rm -f /var/lock/subsys/opensm
-    return $RC
-}
-
-status()
-{
-    local pid
-
-    # First try "pidof"
-    pid=`pidof -o $$ -o $PPID -o %PPID -x ${bin}`
-    if [ -n "$pid" ]; then
-            echo $"${bin} (pid $pid) is running..."
-            return 0
-    fi
-
-     # Next try "/var/run/opensm.pid" files
-     if [ -f $PID_FILE ] ; then
-             read pid < $PID_FILE
-             if [ -n "$pid" ]; then
-                     echo $"${bin} dead but pid file $PID_FILE exists"
-                     return 1
-             fi
-     fi
-     echo $"${bin} is stopped"
-     return 3
-}
-
-
-
-case $ACTION in
-	start)
-                start
-		;;
-	stop)
-		stop
-		;;
-	restart)
-		stop
-                start
-		;;
-	status)
-		status
-		;;
-	condrestart)
-		pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
-		if [ -n "$pid" ]; then
-			stop
-			sleep 1
-			start
-		fi
-		;;
-	*)
-		echo
-		echo "Usage: `basename $0` {start|stop|restart|status}"
-		echo
-		exit 1
-		;;
-esac
-
-RC=$?
-exit $RC
diff --git a/opensm/scripts/redhat-opensm.init.in b/opensm/scripts/redhat-opensm.init.in
new file mode 100755
index 0000000..3e00403
--- /dev/null
+++ b/opensm/scripts/redhat-opensm.init.in
@@ -0,0 +1,382 @@
+#!/bin/bash
+#
+# Bring up/down opensm
+#
+# chkconfig: - 15 85
+# description: Activates/Deactivates InfiniBand Subnet Manager
+#
+### BEGIN INIT INFO
+# Provides:       opensm
+### END INIT INFO
+#
+# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
+#
+# This Software is licensed under one of the following licenses:
+#
+# 1) under the terms of the "Common Public License 1.0" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/cpl.php.
+#
+# 2) under the terms of the "The BSD License" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/bsd-license.php.
+#
+# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
+#    copy of which is available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/gpl-license.php.
+#
+# Licensee has the right to choose one of the above licenses.
+#
+# Redistributions of source code must retain the above copyright
+# notice and one of the license notices.
+#
+# Redistributions in binary form must reproduce both the above copyright
+# notice, one of the license notices in the documentation
+# and/or other materials provided with the distribution.
+#
+#
+#  $Id: openib-1.0-opensm.init,v 1.5 2006/08/02 18:18:23 dledford Exp $
+#
+# processname: /usr/sbin/opensm
+# config: /etc/ofa/opensm.conf
+# pidfile: /var/run/opensm.pid
+. /etc/rc.d/init.d/functions
+
+CONFIG=/etc/ofa/opensm.conf
+if [ ! -f $CONFIG ]; then
+    exit 0
+fi
+
+. $CONFIG
+
+prog=/usr/sbin/opensm
+bin=${prog##*/}
+
+# Handover daemon for updating guid2lid cache file
+sldd_prog=/usr/sbin/sldd.sh
+sldd_bin=${sldd_prog##*/}
+sldd_pid_file=/var/run/sldd.pid
+
+ACTION=$1
+
+# Setting OpenSM start parameters
+PID_FILE=/var/run/${bin}.pid
+touch $PID_FILE
+
+if [[ -z $DEBUG || "$DEBUG" == "none" ]]; then
+    DEBUG_FLAG=""
+else
+    DEBUG_FLAG="-d ${DEBUG}"
+fi
+
+if [[ -z $LMC || "$LMC" == "0" ]]; then
+    LMC_FLAG=""
+else
+    LMC_FLAG="-l ${LMC}"
+fi
+
+if [[ -z $MAXSMPS || "$MAXSMPS" == "4" ]]; then
+    MAXSMPS_FLAG=""
+else
+    MAXSMPS_FLAG="-maxsmps ${MAXSMPS}"
+fi
+
+if [[ -z $REASSIGN_LIDS || "$REASSIGN_LIDS" == "no" ]]; then
+    REASSIGN_LIDS_FLAG=""
+else
+    REASSIGN_LIDS_FLAG="-r"
+fi
+
+if [[ -z $SWEEP || "$SWEEP" == "10" ]]; then
+    SWEEP_FLAG=""
+else
+    SWEEP_FLAG="-s ${SWEEP}"
+fi
+
+if [[ -z $TIMEOUT || "$TIMEOUT" == "100" ]]; then
+    TIMEOUT_FLAG=""
+else
+    TIMEOUT_FLAG="-t ${TIMEOUT}"
+fi
+
+if [[ -z $OSM_LOG || "$OSM_LOG" == "/tmp/osm.log" ]]; then
+    OSM_LOG_FLAG=""
+else
+    OSM_LOG_FLAG="-f ${OSM_LOG}"
+fi
+
+if [[ -z $VERBOSE || "$VERBOSE" == "none" ]]; then
+    VERBOSE_FLAG=""
+else
+    VERBOSE_FLAG="${VERBOSE}"
+fi
+
+if [[ -z $UPDN || "$UPDN" == "off" ]]; then
+    UPDN_FLAG=""
+else
+    UPDN_FLAG="-u"
+fi
+
+if [[ -z $GUID_FILE || "$GUID_FILE" == "none" ]]; then
+    GUID_FILE_FLAG=""
+else
+    GUID_FILE_FLAG="-a ${GUID_FILE}"
+fi
+
+if [[ -z $GUID || "$GUID" == "none" ]]; then
+    GUID_FLAG=""
+else
+    GUID_FLAG="-g ${GUID}"
+fi
+
+if [[ -z $HONORE_GUID2LID || "$HONORE_GUID2LID" == "none" ]]; then
+    HONORE_GUID2LID_FLAG=""
+else
+    HONORE_GUID2LID_FLAG="--honor_guid2lid"
+fi
+
+if [[ -n "${OSM_HOSTS}" && $(echo -n ${OSM_HOSTS} | wc -w | tr -d '[:space:]') -gt 1  ]]; then
+    HONORE_GUID2LID_FLAG="--honor_guid2lid"
+fi
+
+
+if [[ -z $CACHE_OPTIONS || "$CACHE_OPTIONS" == "none" ]]; then
+    CACHE_OPTIONS_FLAG=""
+else
+    CACHE_OPTIONS_FLAG="--cache-options"
+fi
+
+
+if [ -z $PORT_NUM ]; then
+    PORT_FLAG=1
+else
+    PORT_FLAG="${PORT_NUM}"
+fi
+
+
+#########################################################################
+
+start_sldd()
+{
+    if [ -f $sldd_pid_file ]; then
+            local line p
+            read line < $sldd_pid_file
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
+            done
+    fi
+
+    if [ -z "$sldd_pid" ]; then
+        sldd_pid=`pidof -x $sldd_bin`
+    fi
+
+    if [ -n "${sldd_pid:-}" ] ; then
+	kill -9 ${sldd_pid} > /dev/null 2>&1
+    fi
+
+    $sldd_prog > /dev/null 2>&1 &
+    sldd_pid=$!
+
+    echo ${sldd_pid} > $sldd_pid_file
+    # Sleep is needed in order to update local gid2lid cache file before running opensm
+    sleep 3
+}
+
+stop_sldd()
+{
+    if [ -f $sldd_pid_file ]; then
+            local line p
+            read line < $sldd_pid_file
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
+            done
+    fi
+
+    if [ -z "$sldd_pid" ]; then
+        sldd_pid=`pidof -x $sldd_bin`
+    fi
+
+    if [ -n "${sldd_pid:-}" ] ; then
+        kill -15 ${sldd_pid} > /dev/null 2>&1
+    fi
+
+}
+
+start()
+{
+    local OSM_PID=
+
+    pid=""
+
+    if [ -f $PID_FILE ]; then
+            local line p
+            read line < $PID_FILE
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
+            done
+    fi
+
+    if [ -z "$pid" ]; then
+        pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
+    fi
+
+    if [ -n "${pid:-}" ] ; then
+        echo $"${bin} (pid $pid) is already running..."
+    else
+
+	if [ -n "${HONORE_GUID2LID_FLAG}" ]; then
+		# Run sldd daemod
+		start_sldd
+	fi
+
+        # Start opensm
+        local START_FLAGS=""
+        for flag in "$DEBUG_FLAG" "$LMC_FLAG" "$MAXSMPS_FLAG" "$REASSIGN_LIDS_FLAG" "$SWEEP_FLAG" "$TIMEOUT_FLAG" "$OSM_LOG_FLAG" "$VERBOSE_FLAG" "$UPDN_FLAG" "$GUID_FILE_FLAG" "$GUID_FLAG" "$HONORE_GUID2LID_FLAG" "$CACHE_OPTIONS_FLAG"
+        do
+            [ ! -z "$flag" ] && START_FLAGS="$START_FLAGS $flag"
+        done
+
+	echo -n "Starting IB Subnet Manager"
+        echo $PORT_FLAG | $prog $START_FLAGS > /dev/null 2>&1 &
+        cnt=0; alive=0
+        while [ $cnt -lt 6 -a $alive -ne 1 ]; do
+		echo -n ".";
+		sleep 1
+		alive=0
+                OSM_PID=`pidof $prog`
+                if [ "$OSM_PID" != "" ]; then
+                        alive=1
+                fi
+		let cnt++;
+	done
+
+        echo $OSM_PID > $PID_FILE
+        checkpid $OSM_PID
+        RC=$?
+        [ $RC -eq 0 ] && echo_success || echo_failure
+        [ $RC -eq 0 ] && touch /var/lock/subsys/opensm
+	echo
+
+    fi
+return $RC
+}
+
+stop()
+{
+    local pid=
+    local pid1=
+    local pid2=
+
+    # Stop sldd daemon
+    stop_sldd
+
+    if [ -f $PID_FILE ]; then
+            local line p
+            read line < $PID_FILE
+            for p in $line ; do
+                    [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid1="$pid1 $p"
+            done
+    fi
+
+    pid2=`pidof -o $$ -o $PPID -o %PPID -x $bin`
+
+    pid=`echo "$pid1 $pid2" | sed -e 's/\ /\n/g' | sort -n | uniq | sed -e 's/\n/\ /g'`
+
+    if [ -n "${pid:-}" ] ; then
+        # Kill opensm
+	echo -n "Stopping IB Subnet Manager."
+        kill -15 $pid > /dev/null 2>&1
+		cnt=0; alive=1
+        while [ $cnt -lt 6 -a $alive -ne 0 ]; do
+		echo -n ".";
+		alive=0
+		for p in $pid; do
+			if checkpid $p ; then alive=1; echo -n "-"; fi
+		done
+		let cnt++;
+		sleep $alive
+	done
+
+        for p in $pid
+        do
+            while checkpid $p ; do
+                kill -KILL $p > /dev/null 2>&1
+                echo -n "+"
+                sleep 1
+            done
+        done
+        checkpid $pid
+        RC=$?
+        [ $RC -eq 0 ] && echo_failure || echo_success
+	echo
+        RC=$((! $RC))
+    else
+	echo -n "Stopping IB Subnet Manager."
+        echo_failure
+	echo
+        RC=1
+    fi
+
+    # Remove pid file if any.
+    rm -f $PID_FILE
+    rm -f /var/lock/subsys/opensm
+    return $RC
+}
+
+status()
+{
+    local pid
+
+    # First try "pidof"
+    pid=`pidof -o $$ -o $PPID -o %PPID -x ${bin}`
+    if [ -n "$pid" ]; then
+            echo $"${bin} (pid $pid) is running..."
+            return 0
+    fi
+
+     # Next try "/var/run/opensm.pid" files
+     if [ -f $PID_FILE ] ; then
+             read pid < $PID_FILE
+             if [ -n "$pid" ]; then
+                     echo $"${bin} dead but pid file $PID_FILE exists"
+                     return 1
+             fi
+     fi
+     echo $"${bin} is stopped"
+     return 3
+}
+
+
+
+case $ACTION in
+	start)
+                start
+		;;
+	stop)
+		stop
+		;;
+	restart)
+		stop
+                start
+		;;
+	status)
+		status
+		;;
+	condrestart)
+		pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
+		if [ -n "$pid" ]; then
+			stop
+			sleep 1
+			start
+		fi
+		;;
+	*)
+		echo
+		echo "Usage: `basename $0` {start|stop|restart|status}"
+		echo
+		exit 1
+		;;
+esac
+
+RC=$?
+exit $RC
diff --git a/opensm/scripts/sldd.sh b/opensm/scripts/sldd.sh
deleted file mode 100755
index 21f6126..0000000
--- a/opensm/scripts/sldd.sh
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
-#
-# This Software is licensed under one of the following licenses:
-#
-# 1) under the terms of the "Common Public License 1.0" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/cpl.php.
-#
-# 2) under the terms of the "The BSD License" a copy of which is
-#    available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/bsd-license.php.
-#
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
-#    copy of which is available from the Open Source Initiative, see
-#    http://www.opensource.org/licenses/gpl-license.php.
-#
-# Licensee has the right to choose one of the above licenses.
-#
-# Redistributions of source code must retain the above copyright
-# notice and one of the license notices.
-#
-# Redistributions in binary form must reproduce both the above copyright
-# notice, one of the license notices in the documentation
-# and/or other materials provided with the distribution.
-#
-#
-
-# OpenSM found to have the following problem
-# when handover is performed:
-# If some of the cluster nodes are rebooted during the handover they loose their LID assignment.
-# The reason for it is that the standby SM does not obey its own Guid to LID table
-# and simply uses the discovered LIDs. If some nodes are not available for it
-# their previous LID assignment is lost forever.
-
-# The idea is to use an external daemon that will distribute
-# the semi-static LID assignment table from the master SM to all standby SMs.
-# A standby SM, becoming a master . needs to obey the copied semi static LID assignment table.
-
-# config: /etc/opensm.conf
-
-[ -f /etc/sysconfig/opensm.conf ] && CONFIG=/etc/sysconfig/opensm.conf
-[ -f /etc/ofa/opensm.conf ] && CONFIG=/etc/ofa/opensm.conf
-
-SLDD_DEBUG=${SLDD_DEBUG:-0}
-
-if [ -z "$CONFIG" ]; then
-	[ $SLDD_DEBUG -eq 1 ] && echo "Config file not found."
-    	exit 0
-fi
-
-. ${CONFIG}
-
-CACHE_FILE=${CACHE_FILE:-/var/cache/opensm/guid2lid}
-CACHE_DIR=$(dirname ${CACHE_FILE})
-tmp_cache=${CACHE_FILE}.tmp
-
-PING='ping -w 1 -c 1'
-
-RCP=${RCP:-/usr/bin/scp}
-RSH=${RSH:-/usr/bin/ssh}
-IFCONFIG=${IFCONFIG:-'/sbin/ifconfig -a'}
-
-declare -i SLDD_DEBUG
-RESCAN_TIME=${RESCAN_TIME:-60}
-
-if [ -z "${OSM_HOSTS}" ]; then
-	[ $SLDD_DEBUG -eq 1 ] &&
-	echo "No OpenSM servers (OSM_HOSTS) configured for the IB subnet."
-	exit 0
-fi
-
-
-declare -a arr_OSM_HOSTS
-arr_OSM_HOSTS=(${OSM_HOSTS})
-
-num_of_osm_hosts=${#arr_OSM_HOSTS[@]}
-
-if [ ${num_of_osm_hosts} -eq 1 ]; then
-	[ $SLDD_DEBUG -eq 1 ] &&
-	echo "One OpenSM server configured in the IB subnet." &&
-	echo "Nothing to be done for SLDD"
-
-	exit 0
-fi
-
-trap 'trap_handler' 15
-
-trap_handler()
-{
-	logger -i "SLDD: Exiting."
-	exit 0
-}
-
-is_alive()
-{
-	$PING $1 > /dev/null 2>&1
-	return $?
-}
-
-is_local()
-{
-	$IFCONFIG | grep -w "$1" > /dev/null 2>&1
-	return $?
-}
-
-update_remote_cache()
-{
-	/bin/rm -f ${CACHE_FILE}.upd
-	/bin/cp -a ${CACHE_FILE} ${CACHE_FILE}.upd
-
-	[ $SLDD_DEBUG -eq 1 ] &&
-	echo "Updating remote cache file"
-
-	for host in ${OSM_HOSTS}
-	do
-		# Skip local host update
-		if [ "${host}" == "${local_host}" ]; then
-			continue
-		fi
-
-		if is_alive $host; then
-			stat=$($RSH $host "/bin/mkdir -p ${CACHE_DIR} > /dev/null 2>&1; /bin/rm -f ${CACHE_FILE}.${local_host} > /dev/null 2>&1; echo \$?" | tr -d '[:space:]')
-			if [ "X${stat}" == "X0" ]; then
-				[ $SLDD_DEBUG -eq 1 ] &&
-				echo "Updating $host"
-				logger -i "SLDD: updating $host with ${CACHE_FILE}"
-				$RCP ${CACHE_FILE}.upd ${host}:${CACHE_FILE}.${local_host}
-				/bin/cp ${CACHE_FILE}.upd ${CACHE_FILE}.${host}
-			else
-				[ $SLDD_DEBUG -eq 1 ] &&
-				echo "$RSH to $host failed."
-				logger -i "SLDD: Failed to update $host with ${CACHE_FILE}. $RSH without password should be enabled"
-				exit 5
-			fi
-		else
-			[ $SLDD_DEBUG -eq 1 ] &&
-			echo "$host is down."
-			continue
-		fi
-	done
-}
-
-get_latest_remote_cache()
-{
-	# Find most updated remote cache file (the suffix should be like ip address: *.*.*.*)
-	echo -n "$(/bin/ls -1t ${CACHE_FILE}.*.* 2> /dev/null | head -1)"
-}
-
-get_largest_remote_cache()
-{
-	# Find largest (size) remote cache file (the suffix should be like ip address: *.*.*.*)
-	echo -n "$(/bin/ls -1S ${CACHE_FILE}.*.* 2> /dev/null | head -1)"
-}
-
-swap_cache_files()
-{
-	/bin/rm -f ${CACHE_FILE}.old
-	/bin/mv ${CACHE_FILE} ${CACHE_FILE}.old
-	/bin/cp ${largest_remote_cache} ${CACHE_FILE}
-	touch ${CACHE_FILE}.tmp
-}
-
-# Find local host in the osm hosts list
-local_host=""
-for host in ${OSM_HOSTS}
-do
-	if is_local $host; then
-		local_host=${host}
-	fi
-done
-
-# Get cache file info
-declare -i new_size=0
-declare -i last_size=0
-declare -i largest_remote_cache_size=0
-
-if [ -e ${CACHE_FILE} ]; then
-	last_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')
-else
-	touch ${CACHE_FILE} ${CACHE_FILE}.tmp
-fi
-
-# if [ ${last_size} -gt 0 ]; then
-# 	# First time update
-# 	update_remote_cache
-# fi
-
-while true
-do
-	if [ -s "${CACHE_FILE}" ]; then
-		new_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')
-		# Check if local cache file grew from its last version or the time stamp changed
-		if [ ${new_size} -gt ${last_size} ]
-		   [ "$(/bin/ls -1t ${CACHE_FILE} ${CACHE_FILE}.tmp 2> /dev/null | head -1)"  != "${CACHE_FILE}.tmp" ]; then
-			largest_remote_cache=$(get_largest_remote_cache)
-			if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
-				largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')
-			else
-				largest_remote_cache_size=0
-			fi
-
-			# Check if local cache file larger than remote chache file
-			if [ ${new_size} -gt ${largest_remote_cache_size} ]; then
-				[ $SLDD_DEBUG -eq 1 ] &&
-				echo "Local cache file larger then remote. Update remote cache files"
-				last_size=${new_size}
-				update_remote_cache
-				continue
-			fi
-		fi
-
-		largest_remote_cache=$(get_largest_remote_cache)
-		if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
-			largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')
-		else
-			largest_remote_cache_size=0
-		fi
-
-		# Update local cache file from remote
-		if [ ${largest_remote_cache_size} -gt ${new_size} ]; then
-			[ $SLDD_DEBUG -eq 1 ] &&
-			echo "Local cache file shorter then remote. Use ${largest_remote_cache}"
-			logger -i "SLDD: updating local cache file with ${largest_remote_cache}"
-			swap_cache_files
-			last_size=${largest_remote_cache_size}
-		fi
-
-	else # The local cache file is empty
-		[ $SLDD_DEBUG -eq 1 ] &&
-		echo "${CACHE_FILE} is empty"
-
-		largest_remote_cache=$(get_largest_remote_cache)
-		if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
-			# Copy it to the current cache
-			[ $SLDD_DEBUG -eq 1 ] &&
-			echo "Local cache file is empty. Use ${largest_remote_cache}"
-			logger -i "SLDD: updating local cache file with ${largest_remote_cache}"
-			swap_cache_files
-		fi
-
-	fi
-
-	[ $SLDD_DEBUG -eq 1 ] &&
-	echo "Sleeping ${RESCAN_TIME} seconds."
-	sleep ${RESCAN_TIME}
-
-done
diff --git a/opensm/scripts/sldd.sh.in b/opensm/scripts/sldd.sh.in
new file mode 100755
index 0000000..21f6126
--- /dev/null
+++ b/opensm/scripts/sldd.sh.in
@@ -0,0 +1,249 @@
+#!/bin/bash
+#
+# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
+#
+# This Software is licensed under one of the following licenses:
+#
+# 1) under the terms of the "Common Public License 1.0" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/cpl.php.
+#
+# 2) under the terms of the "The BSD License" a copy of which is
+#    available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/bsd-license.php.
+#
+# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
+#    copy of which is available from the Open Source Initiative, see
+#    http://www.opensource.org/licenses/gpl-license.php.
+#
+# Licensee has the right to choose one of the above licenses.
+#
+# Redistributions of source code must retain the above copyright
+# notice and one of the license notices.
+#
+# Redistributions in binary form must reproduce both the above copyright
+# notice, one of the license notices in the documentation
+# and/or other materials provided with the distribution.
+#
+#
+
+# OpenSM found to have the following problem
+# when handover is performed:
+# If some of the cluster nodes are rebooted during the handover they loose their LID assignment.
+# The reason for it is that the standby SM does not obey its own Guid to LID table
+# and simply uses the discovered LIDs. If some nodes are not available for it
+# their previous LID assignment is lost forever.
+
+# The idea is to use an external daemon that will distribute
+# the semi-static LID assignment table from the master SM to all standby SMs.
+# A standby SM, becoming a master . needs to obey the copied semi static LID assignment table.
+
+# config: /etc/opensm.conf
+
+[ -f /etc/sysconfig/opensm.conf ] && CONFIG=/etc/sysconfig/opensm.conf
+[ -f /etc/ofa/opensm.conf ] && CONFIG=/etc/ofa/opensm.conf
+
+SLDD_DEBUG=${SLDD_DEBUG:-0}
+
+if [ -z "$CONFIG" ]; then
+	[ $SLDD_DEBUG -eq 1 ] && echo "Config file not found."
+    	exit 0
+fi
+
+. ${CONFIG}
+
+CACHE_FILE=${CACHE_FILE:-/var/cache/opensm/guid2lid}
+CACHE_DIR=$(dirname ${CACHE_FILE})
+tmp_cache=${CACHE_FILE}.tmp
+
+PING='ping -w 1 -c 1'
+
+RCP=${RCP:-/usr/bin/scp}
+RSH=${RSH:-/usr/bin/ssh}
+IFCONFIG=${IFCONFIG:-'/sbin/ifconfig -a'}
+
+declare -i SLDD_DEBUG
+RESCAN_TIME=${RESCAN_TIME:-60}
+
+if [ -z "${OSM_HOSTS}" ]; then
+	[ $SLDD_DEBUG -eq 1 ] &&
+	echo "No OpenSM servers (OSM_HOSTS) configured for the IB subnet."
+	exit 0
+fi
+
+
+declare -a arr_OSM_HOSTS
+arr_OSM_HOSTS=(${OSM_HOSTS})
+
+num_of_osm_hosts=${#arr_OSM_HOSTS[@]}
+
+if [ ${num_of_osm_hosts} -eq 1 ]; then
+	[ $SLDD_DEBUG -eq 1 ] &&
+	echo "One OpenSM server configured in the IB subnet." &&
+	echo "Nothing to be done for SLDD"
+
+	exit 0
+fi
+
+trap 'trap_handler' 15
+
+trap_handler()
+{
+	logger -i "SLDD: Exiting."
+	exit 0
+}
+
+is_alive()
+{
+	$PING $1 > /dev/null 2>&1
+	return $?
+}
+
+is_local()
+{
+	$IFCONFIG | grep -w "$1" > /dev/null 2>&1
+	return $?
+}
+
+update_remote_cache()
+{
+	/bin/rm -f ${CACHE_FILE}.upd
+	/bin/cp -a ${CACHE_FILE} ${CACHE_FILE}.upd
+
+	[ $SLDD_DEBUG -eq 1 ] &&
+	echo "Updating remote cache file"
+
+	for host in ${OSM_HOSTS}
+	do
+		# Skip local host update
+		if [ "${host}" == "${local_host}" ]; then
+			continue
+		fi
+
+		if is_alive $host; then
+			stat=$($RSH $host "/bin/mkdir -p ${CACHE_DIR} > /dev/null 2>&1; /bin/rm -f ${CACHE_FILE}.${local_host} > /dev/null 2>&1; echo \$?" | tr -d '[:space:]')
+			if [ "X${stat}" == "X0" ]; then
+				[ $SLDD_DEBUG -eq 1 ] &&
+				echo "Updating $host"
+				logger -i "SLDD: updating $host with ${CACHE_FILE}"
+				$RCP ${CACHE_FILE}.upd ${host}:${CACHE_FILE}.${local_host}
+				/bin/cp ${CACHE_FILE}.upd ${CACHE_FILE}.${host}
+			else
+				[ $SLDD_DEBUG -eq 1 ] &&
+				echo "$RSH to $host failed."
+				logger -i "SLDD: Failed to update $host with ${CACHE_FILE}. $RSH without password should be enabled"
+				exit 5
+			fi
+		else
+			[ $SLDD_DEBUG -eq 1 ] &&
+			echo "$host is down."
+			continue
+		fi
+	done
+}
+
+get_latest_remote_cache()
+{
+	# Find most updated remote cache file (the suffix should be like ip address: *.*.*.*)
+	echo -n "$(/bin/ls -1t ${CACHE_FILE}.*.* 2> /dev/null | head -1)"
+}
+
+get_largest_remote_cache()
+{
+	# Find largest (size) remote cache file (the suffix should be like ip address: *.*.*.*)
+	echo -n "$(/bin/ls -1S ${CACHE_FILE}.*.* 2> /dev/null | head -1)"
+}
+
+swap_cache_files()
+{
+	/bin/rm -f ${CACHE_FILE}.old
+	/bin/mv ${CACHE_FILE} ${CACHE_FILE}.old
+	/bin/cp ${largest_remote_cache} ${CACHE_FILE}
+	touch ${CACHE_FILE}.tmp
+}
+
+# Find local host in the osm hosts list
+local_host=""
+for host in ${OSM_HOSTS}
+do
+	if is_local $host; then
+		local_host=${host}
+	fi
+done
+
+# Get cache file info
+declare -i new_size=0
+declare -i last_size=0
+declare -i largest_remote_cache_size=0
+
+if [ -e ${CACHE_FILE} ]; then
+	last_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')
+else
+	touch ${CACHE_FILE} ${CACHE_FILE}.tmp
+fi
+
+# if [ ${last_size} -gt 0 ]; then
+# 	# First time update
+# 	update_remote_cache
+# fi
+
+while true
+do
+	if [ -s "${CACHE_FILE}" ]; then
+		new_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')
+		# Check if local cache file grew from its last version or the time stamp changed
+		if [ ${new_size} -gt ${last_size} ]
+		   [ "$(/bin/ls -1t ${CACHE_FILE} ${CACHE_FILE}.tmp 2> /dev/null | head -1)"  != "${CACHE_FILE}.tmp" ]; then
+			largest_remote_cache=$(get_largest_remote_cache)
+			if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
+				largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')
+			else
+				largest_remote_cache_size=0
+			fi
+
+			# Check if local cache file larger than remote chache file
+			if [ ${new_size} -gt ${largest_remote_cache_size} ]; then
+				[ $SLDD_DEBUG -eq 1 ] &&
+				echo "Local cache file larger then remote. Update remote cache files"
+				last_size=${new_size}
+				update_remote_cache
+				continue
+			fi
+		fi
+
+		largest_remote_cache=$(get_largest_remote_cache)
+		if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
+			largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')
+		else
+			largest_remote_cache_size=0
+		fi
+
+		# Update local cache file from remote
+		if [ ${largest_remote_cache_size} -gt ${new_size} ]; then
+			[ $SLDD_DEBUG -eq 1 ] &&
+			echo "Local cache file shorter then remote. Use ${largest_remote_cache}"
+			logger -i "SLDD: updating local cache file with ${largest_remote_cache}"
+			swap_cache_files
+			last_size=${largest_remote_cache_size}
+		fi
+
+	else # The local cache file is empty
+		[ $SLDD_DEBUG -eq 1 ] &&
+		echo "${CACHE_FILE} is empty"
+
+		largest_remote_cache=$(get_largest_remote_cache)
+		if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
+			# Copy it to the current cache
+			[ $SLDD_DEBUG -eq 1 ] &&
+			echo "Local cache file is empty. Use ${largest_remote_cache}"
+			logger -i "SLDD: updating local cache file with ${largest_remote_cache}"
+			swap_cache_files
+		fi
+
+	fi
+
+	[ $SLDD_DEBUG -eq 1 ] &&
+	echo "Sleeping ${RESCAN_TIME} seconds."
+	sleep ${RESCAN_TIME}
+
+done
-- 
1.5.4.1.122.gaa8d




More information about the general mailing list