134 lines
2.8 KiB
Bash
134 lines
2.8 KiB
Bash
#!/bin/bash
|
|
#
|
|
# opensm: Manage OpenSM
|
|
#
|
|
# chkconfig: - 09 91
|
|
# description: Manage OpenSM
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: opensm
|
|
# Required-Start: $syslog
|
|
# Default-Start: none
|
|
# Default-Stop: 0 1 6
|
|
# Description: Manage OpenSM
|
|
### END INIT INFO
|
|
#
|
|
# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
|
|
# 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.
|
|
|
|
prefix=@prefix@
|
|
exec_prefix=@exec_prefix@
|
|
|
|
# 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
|
|
|
|
CONFIG=@sysconfdir@/sysconfig/opensm
|
|
if [[ -s $CONFIG ]]; then
|
|
. $CONFIG
|
|
fi
|
|
|
|
start () {
|
|
echo -n "Starting opensm: "
|
|
@sbindir@/opensm --daemon $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 () {
|
|
pid="`pidof opensm`"
|
|
ret=$?
|
|
if [ $ret -eq 0 ] ; then
|
|
echo "OpenSM is running... pid=$pid"
|
|
else
|
|
echo "OpenSM is not running."
|
|
fi
|
|
}
|
|
|
|
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
|