author | John Beck <John.Beck@Oracle.COM> |
Fri, 27 Feb 2015 14:35:08 -0800 | |
branch | s11-update |
changeset 3980 | a5c4d6759ee0 |
parent 2785 | b6f5c5d1d0b7 |
permissions | -rw-r--r-- |
2785
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
1 |
#!/usr/sbin/sh |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
2 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
4 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
8 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
13 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
19 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
21 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
22 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
23 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
24 |
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
25 |
# |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
26 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
27 |
. /lib/svc/share/smf_include.sh |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
28 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
29 |
RABBIT_SERVER=/usr/bin/rabbitmq-server |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
30 |
RABBIT_CTL=/usr/bin/rabbitmqctl |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
31 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
32 |
if [[ -z "$SMF_FMRI" ]]; then |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
33 |
echo "This script can only be invoked by smf(5)" |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
34 |
exit $SMF_EXIT_ERR_NOSMF |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
35 |
fi |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
36 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
37 |
# rabbitmq-env handles pulling in configuration from a number of sources. Out |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
38 |
# of that, the server builds more configuration variables if they haven't |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
39 |
# already been set. getenv() gives us the variable as the server would see it. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
40 |
# It's up to the caller to massage it as the server would. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
41 |
getenv() { |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
42 |
# Has the RABBITMQ_ version been set? If so, that takes precedence. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
43 |
r=$(eval print \$RABBITMQ_${1}) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
44 |
if [[ -n $r ]]; then |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
45 |
print $r |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
46 |
else |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
47 |
print $( |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
48 |
SCRIPT_DIR=/usr/lib/rabbitmq/bin; |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
49 |
. /usr/lib/rabbitmq/bin/rabbitmq-env; |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
50 |
eval print \${$1} |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
51 |
) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
52 |
fi |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
53 |
} |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
54 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
55 |
# If RABBITMQ_NODENAME isn't set in the environment, then use the FMRI instance |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
56 |
# name, unless the instance name is "default", in which case we use the default |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
57 |
# from the configuration files. If the instance name doesn't have an @ in it, |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
58 |
# then append the hostname. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
59 |
if [[ -z $RABBITMQ_NODENAME ]]; then |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
60 |
INSTANCE=${SMF_FMRI##*:} |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
61 |
if [[ $INSTANCE == default ]]; then |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
62 |
INSTANCE=$(getenv NODENAME) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
63 |
fi |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
64 |
if [[ $INSTANCE != *@* ]]; then |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
65 |
INSTANCE=$INSTANCE@$(hostname) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
66 |
fi |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
67 |
export RABBITMQ_NODENAME=$INSTANCE |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
68 |
fi |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
69 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
70 |
# XXX Why isn't HOME set for us? |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
71 |
export HOME=/var/lib/rabbitmq |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
72 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
73 |
case "$1" in |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
74 |
"start") |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
75 |
$RABBIT_SERVER -detached |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
76 |
;; |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
77 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
78 |
"stop") |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
79 |
$RABBIT_CTL -n $RABBITMQ_NODENAME stop |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
80 |
# XXX epmd should be in a separate SMF service (16749936); for now, |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
81 |
# though, be sure to kill it here. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
82 |
epmd_pid=$(pgrep -c $(svcs -H -o ctid $SMF_FMRI) epmd) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
83 |
if [[ -n $epmd_pid ]]; then |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
84 |
sleep 2 |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
85 |
epmd -kill |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
86 |
fi |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
87 |
;; |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
88 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
89 |
*) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
90 |
echo "Usage: $0 { start | stop }" |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
91 |
exit $SMF_EXIT_ERR_CONFIG |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
92 |
;; |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
93 |
esac |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
94 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
95 |
exit $SMF_EXIT_OK |