Blame scripts/opensm.init.in

Packit 13e616
#!/bin/bash
Packit 13e616
#
Packit 13e616
# opensm:		Manage OpenSM
Packit 13e616
#
Packit 13e616
# chkconfig: - 09 91
Packit 13e616
# description:  Manage OpenSM
Packit 13e616
#
Packit 13e616
### BEGIN INIT INFO
Packit 13e616
# Provides: opensm
Packit 13e616
# Required-Start: $syslog @RDMA_SERVICE@
Packit 13e616
# Required-Stop: $syslog @RDMA_SERVICE@
Packit 13e616
# Default-Start: @DEFAULT_START@
Packit 13e616
# Default-Stop: @DEFAULT_STOP@
Packit 13e616
# Description:  Manage OpenSM
Packit 13e616
### END INIT INFO
Packit 13e616
#
Packit 13e616
# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
Packit 13e616
# Copyright 2006 PathScale, Inc.  All Rights Reserved.
Packit 13e616
#
Packit 13e616
# This Software is licensed under one of the following licenses:
Packit 13e616
#
Packit 13e616
# 1) under the terms of the "Common Public License 1.0" a copy of which is
Packit 13e616
#    available from the Open Source Initiative, see
Packit 13e616
#    http://www.opensource.org/licenses/cpl.php.
Packit 13e616
#
Packit 13e616
# 2) under the terms of the "The BSD License" a copy of which is
Packit 13e616
#    available from the Open Source Initiative, see
Packit 13e616
#    http://www.opensource.org/licenses/bsd-license.php.
Packit 13e616
#
Packit 13e616
# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
Packit 13e616
#    copy of which is available from the Open Source Initiative, see
Packit 13e616
#    http://www.opensource.org/licenses/gpl-license.php.
Packit 13e616
#
Packit 13e616
# Licensee has the right to choose one of the above licenses.
Packit 13e616
#
Packit 13e616
# Redistributions of source code must retain the above copyright
Packit 13e616
# notice and one of the license notices.
Packit 13e616
#
Packit 13e616
# Redistributions in binary form must reproduce both the above copyright
Packit 13e616
# notice, one of the license notices in the documentation
Packit 13e616
# and/or other materials provided with the distribution.
Packit 13e616
Packit 13e616
prefix=@prefix@
Packit 13e616
exec_prefix=@exec_prefix@
Packit 13e616
pidfile=/var/run/opensm.pid
Packit 13e616
Packit 13e616
# Source function library.
Packit 13e616
if [[ -s /etc/init.d/functions ]]; then
Packit 13e616
    # RHEL / CentOS / SL / Fedora.
Packit 13e616
    . /etc/init.d/functions
Packit 13e616
    rc_status() { :; }
Packit 13e616
    rc_exit() { exit $RETVAL; }
Packit 13e616
elif [[ -s /lib/lsb/init-functions ]]; then
Packit 13e616
    # SLES / openSuSE / Debian.
Packit 13e616
    . /lib/lsb/init-functions
Packit 13e616
    rc_exit() { exit $RETVAL; }
Packit 13e616
    success() { log_success_msg; }
Packit 13e616
    failure() { log_failure_msg; }
Packit 13e616
elif [[ -s /etc/rc.status ]]; then
Packit 13e616
    # Older SuSE systems.
Packit 13e616
    . /etc/rc.status
Packit 13e616
    failure() { rc_status -v; }
Packit 13e616
    success() { rc_status -v; }
Packit 13e616
fi
Packit 13e616
Packit 13e616
CONFIG=@sysconfdir@/sysconfig/opensm
Packit 13e616
if [[ -s $CONFIG ]]; then
Packit 13e616
    . $CONFIG
Packit 13e616
fi
Packit 13e616
Packit 13e616
running () {
Packit 13e616
    [ -e $pidfile ] &&
Packit 13e616
        [ "$(readlink "/proc/$(<$pidfile)/exe")" = "@sbindir@/opensm" ]
Packit 13e616
}
Packit 13e616
Packit 13e616
start () {
Packit 13e616
    if running; then
Packit 13e616
	echo Already started
Packit 13e616
	return 1
Packit 13e616
    fi
Packit 13e616
    echo -n "Starting opensm: "
Packit 13e616
    @sbindir@/opensm --daemon --pidfile $pidfile $OPTIONS > /dev/null
Packit 13e616
    RETVAL=$?
Packit 13e616
    if [[ $RETVAL -eq 0 ]]; then
Packit 13e616
        success
Packit 13e616
    else
Packit 13e616
        failure
Packit 13e616
    fi
Packit 13e616
    echo
Packit 13e616
}
Packit 13e616
Packit 13e616
stop () {
Packit 13e616
    echo -n "Shutting down opensm: "
Packit 13e616
    killproc opensm
Packit 13e616
    RETVAL=$?
Packit 13e616
    if [[ $RETVAL -eq 0 ]]; then
Packit 13e616
        success
Packit 13e616
    else
Packit 13e616
        failure
Packit 13e616
    fi
Packit 13e616
    echo
Packit 13e616
}
Packit 13e616
Packit 13e616
Xstatus () {
Packit 13e616
	pid="`pidof opensm`"
Packit 13e616
	ret=$?
Packit 13e616
	if [ $ret -eq 0 ] ; then
Packit 13e616
		echo "OpenSM is running... pid=$pid"
Packit 13e616
	else
Packit 13e616
		echo "OpenSM is not running."
Packit 13e616
	fi
Packit 13e616
}
Packit 13e616
Packit 13e616
restart() {
Packit 13e616
    stop
Packit 13e616
    start
Packit 13e616
}
Packit 13e616
Packit 13e616
# See how we were called.
Packit 13e616
case "$1" in
Packit 13e616
    start)
Packit 13e616
	start
Packit 13e616
	;;
Packit 13e616
    stop)
Packit 13e616
	stop
Packit 13e616
	;;
Packit 13e616
    status)
Packit 13e616
        Xstatus
Packit 13e616
	;;
Packit 13e616
    restart | force-reload | reload)
Packit 13e616
	restart
Packit 13e616
	;;
Packit 13e616
    try-restart | condrestart)
Packit 13e616
	[ -e $pidfile ] && restart
Packit 13e616
	;;
Packit 13e616
    resweep)
Packit 13e616
	killall -HUP opensm
Packit 13e616
        RETVAL=$?
Packit 13e616
	;;
Packit 13e616
    rotatelog)
Packit 13e616
	killall -USR1 opensm
Packit 13e616
        RETVAL=$?
Packit 13e616
	;;
Packit 13e616
    *)
Packit 13e616
	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|resweep|rotatelog}"
Packit 13e616
	RETVAL=1
Packit 13e616
	;;
Packit 13e616
esac
Packit 13e616
Packit 13e616
_rc_status_all=$RETVAL
Packit 13e616
rc_exit