1219820Sjeff#!/bin/bash 2219820Sjeff# 3219820Sjeff# opensm: Manage OpenSM 4219820Sjeff# 5219820Sjeff# chkconfig: - 09 91 6219820Sjeff# description: Manage OpenSM 7219820Sjeff# 8219820Sjeff### BEGIN INIT INFO 9219820Sjeff# Provides: opensm 10219820Sjeff# Required-Start: $syslog 11219820Sjeff# Default-Start: none 12219820Sjeff# Default-Stop: 0 1 6 13219820Sjeff# Description: Manage OpenSM 14219820Sjeff### END INIT INFO 15219820Sjeff# 16219820Sjeff# Copyright (c) 2008 Voltaire, Inc. All rights reserved. 17219820Sjeff# Copyright 2006 PathScale, Inc. All Rights Reserved. 18219820Sjeff# 19219820Sjeff# This Software is licensed under one of the following licenses: 20219820Sjeff# 21219820Sjeff# 1) under the terms of the "Common Public License 1.0" a copy of which is 22219820Sjeff# available from the Open Source Initiative, see 23219820Sjeff# http://www.opensource.org/licenses/cpl.php. 24219820Sjeff# 25219820Sjeff# 2) under the terms of the "The BSD License" a copy of which is 26219820Sjeff# available from the Open Source Initiative, see 27219820Sjeff# http://www.opensource.org/licenses/bsd-license.php. 28219820Sjeff# 29219820Sjeff# 3) under the terms of the "GNU General Public License (GPL) Version 2" a 30219820Sjeff# copy of which is available from the Open Source Initiative, see 31219820Sjeff# http://www.opensource.org/licenses/gpl-license.php. 32219820Sjeff# 33219820Sjeff# Licensee has the right to choose one of the above licenses. 34219820Sjeff# 35219820Sjeff# Redistributions of source code must retain the above copyright 36219820Sjeff# notice and one of the license notices. 37219820Sjeff# 38219820Sjeff# Redistributions in binary form must reproduce both the above copyright 39219820Sjeff# notice, one of the license notices in the documentation 40219820Sjeff# and/or other materials provided with the distribution. 41219820Sjeff 42219820Sjeffprefix=@prefix@ 43219820Sjeffexec_prefix=@exec_prefix@ 44219820Sjeff 45219820Sjeff# Source function library. 46219820Sjeffif [[ -s /etc/init.d/functions ]]; then 47219820Sjeff . /etc/init.d/functions 48219820Sjeff rc_status() { :; } 49219820Sjeff rc_exit() { exit $RETVAL; } 50219820Sjefffi 51219820Sjeffif [[ -s /etc/rc.status ]]; then 52219820Sjeff . /etc/rc.status 53219820Sjeff failure() { rc_status -v; } 54219820Sjeff success() { rc_status -v; } 55219820Sjefffi 56219820Sjeff 57219820SjeffCONFIG=@sysconfdir@/sysconfig/opensm 58219820Sjeffif [[ -s $CONFIG ]]; then 59219820Sjeff . $CONFIG 60219820Sjefffi 61219820Sjeff 62219820Sjeffstart () { 63219820Sjeff echo -n "Starting opensm: " 64219820Sjeff @sbindir@/opensm --daemon $OPTIONS > /dev/null 65219820Sjeff if [[ $RETVAL -eq 0 ]]; then 66219820Sjeff touch /var/lock/subsys/opensm 67219820Sjeff success 68219820Sjeff else 69219820Sjeff failure 70219820Sjeff fi 71219820Sjeff echo 72219820Sjeff} 73219820Sjeff 74219820Sjeffstop () { 75219820Sjeff echo -n "Shutting down opensm: " 76219820Sjeff killproc opensm 77219820Sjeff if [[ $RETVAL -eq 0 ]]; then 78219820Sjeff rm -f /var/lock/subsys/opensm 79219820Sjeff success 80219820Sjeff else 81219820Sjeff failure 82219820Sjeff fi 83219820Sjeff echo 84219820Sjeff} 85219820Sjeff 86219820SjeffXstatus () { 87219820Sjeff pid="`pidof opensm`" 88219820Sjeff ret=$? 89219820Sjeff if [ $ret -eq 0 ] ; then 90219820Sjeff echo "OpenSM is running... pid=$pid" 91219820Sjeff else 92219820Sjeff echo "OpenSM is not running." 93219820Sjeff fi 94219820Sjeff} 95219820Sjeff 96219820Sjeffrestart() { 97219820Sjeff stop 98219820Sjeff start 99219820Sjeff} 100219820Sjeff 101219820Sjeff# See how we were called. 102219820Sjeffcase "$1" in 103219820Sjeff start) 104219820Sjeff start 105219820Sjeff ;; 106219820Sjeff stop) 107219820Sjeff stop 108219820Sjeff ;; 109219820Sjeff status) 110219820Sjeff Xstatus 111219820Sjeff ;; 112219820Sjeff restart | force-reload | reload) 113219820Sjeff restart 114219820Sjeff ;; 115219820Sjeff try-restart | condrestart) 116219820Sjeff [ -e /var/lock/subsys/opensm ] && restart 117219820Sjeff ;; 118219820Sjeff resweep) 119219820Sjeff killall -HUP opensm 120219820Sjeff RETVAL=$? 121219820Sjeff ;; 122219820Sjeff rotatelog) 123219820Sjeff killall -USR1 opensm 124219820Sjeff RETVAL=$? 125219820Sjeff ;; 126219820Sjeff *) 127219820Sjeff echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|resweep|rotatelog}" 128219820Sjeff RETVAL=1 129219820Sjeff ;; 130219820Sjeffesac 131219820Sjeff 132219820Sjeff_rc_status_all=$RETVAL 133219820Sjeffrc_exit 134