]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ofed/management/opensm/scripts/opensm.init.in
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ofed / management / opensm / scripts / opensm.init.in
1 #!/bin/bash
2 #
3 # opensm:               Manage OpenSM
4 #
5 # chkconfig: - 09 91
6 # description:  Manage OpenSM
7 #
8 ### BEGIN INIT INFO
9 # Provides: opensm
10 # Required-Start: $syslog
11 # Default-Start: none
12 # Default-Stop: 0 1 6
13 # Description:  Manage OpenSM
14 ### END INIT INFO
15 #
16 # Copyright (c) 2008 Voltaire, Inc. All rights reserved.
17 # Copyright 2006 PathScale, Inc.  All Rights Reserved.
18 #
19 # This Software is licensed under one of the following licenses:
20 #
21 # 1) under the terms of the "Common Public License 1.0" a copy of which is
22 #    available from the Open Source Initiative, see
23 #    http://www.opensource.org/licenses/cpl.php.
24 #
25 # 2) under the terms of the "The BSD License" a copy of which is
26 #    available from the Open Source Initiative, see
27 #    http://www.opensource.org/licenses/bsd-license.php.
28 #
29 # 3) under the terms of the "GNU General Public License (GPL) Version 2" a
30 #    copy of which is available from the Open Source Initiative, see
31 #    http://www.opensource.org/licenses/gpl-license.php.
32 #
33 # Licensee has the right to choose one of the above licenses.
34 #
35 # Redistributions of source code must retain the above copyright
36 # notice and one of the license notices.
37 #
38 # Redistributions in binary form must reproduce both the above copyright
39 # notice, one of the license notices in the documentation
40 # and/or other materials provided with the distribution.
41
42 prefix=@prefix@
43 exec_prefix=@exec_prefix@
44
45 # Source function library.
46 if [[ -s /etc/init.d/functions ]]; then
47     . /etc/init.d/functions
48     rc_status() { :; }
49     rc_exit() { exit $RETVAL; }
50 fi
51 if [[ -s /etc/rc.status ]]; then
52     . /etc/rc.status
53     failure() { rc_status -v; }
54     success() { rc_status -v; }
55 fi
56
57 CONFIG=@sysconfdir@/sysconfig/opensm
58 if [[ -s $CONFIG ]]; then
59     . $CONFIG
60 fi
61
62 start () {
63     echo -n "Starting opensm: "
64     @sbindir@/opensm --daemon $OPTIONS > /dev/null
65     if [[ $RETVAL -eq 0 ]]; then
66         touch /var/lock/subsys/opensm
67         success
68     else
69         failure
70     fi
71     echo
72 }
73
74 stop () {
75     echo -n "Shutting down opensm: "
76     killproc opensm
77     if [[ $RETVAL -eq 0 ]]; then
78         rm -f /var/lock/subsys/opensm
79         success
80     else
81         failure
82     fi
83     echo
84 }
85
86 Xstatus () {
87         pid="`pidof opensm`"
88         ret=$?
89         if [ $ret -eq 0 ] ; then
90                 echo "OpenSM is running... pid=$pid"
91         else
92                 echo "OpenSM is not running."
93         fi
94 }
95
96 restart() {
97     stop
98     start
99 }
100
101 # See how we were called.
102 case "$1" in
103     start)
104         start
105         ;;
106     stop)
107         stop
108         ;;
109     status)
110         Xstatus
111         ;;
112     restart | force-reload | reload)
113         restart
114         ;;
115     try-restart | condrestart)
116         [ -e /var/lock/subsys/opensm ] && restart
117         ;;
118     resweep)
119         killall -HUP opensm
120         RETVAL=$?
121         ;;
122     rotatelog)
123         killall -USR1 opensm
124         RETVAL=$?
125         ;;
126     *)
127         echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|resweep|rotatelog}"
128         RETVAL=1
129         ;;
130 esac
131
132 _rc_status_all=$RETVAL
133 rc_exit