blob: 838ae5f61443a34fc3078135efd191f044036379 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
#!/bin/sh
#
# $FreeBSD$
#
#
# Configuration settings for geronimo%%GERONIMO_VERSION%% in /etc/rc.conf:
#
# james%%JAMES_VERSION%%_enable (bool):
# Set to "NO" by default.
# Set it to "YES" to enable james%%JAMES_VERSION%%
#
#
# james%%JAMES_VERSION%%_home (str)
# Set to "%%JAMES_HOME%%" by default.
# Set the JAMES_HOME variable for the James process
#
# james%%JAMES_VERSION%%_base (str)
# Set to "%%JAMES_HOME%%" by default.
# Set the JAMES_BASE variable for the James process
#
# james%%JAMES_VERSION%%_tmpdir (str)
# Set to "/tmp" by default.
#
# geronimo%%GERONIMO_VERSION%%_stop_timeout (num)
# Set to "10" by default.
# Sets the timeout in seconds to allow geronimo to shutdown.
# After the timeout has elapsed, geronimo will be killed.
#
# james%%JAMES_VERSION%%_java_home (str):
# james%%JAMES_VERSION%%_java_vendor (str):
# james%%JAMES_VERSION%%_java_version (str):
# james%%JAMES_VERSION%%_java_os (str):
# Specify the requirements of the Java VM to use. See javavm(1).
#
# james%%JAMES_VERSION%%_classpath (str):
# Set to "" by default.
# Addtional classes to add to the CLASSPATH
#
# james%%JAMES_VERSION%%_java_opts (str):
# Set to "" by default.
# Java VM args to use.
#
james%%JAMES_VERSION%%_enable="${james%%JAMES_VERSION%%_enable:-"NO"}"
james%%JAMES_VERSION%%_java_version="${james%%JAMES_VERSION%%_java_version:-"%%JAVA_VERSION%%"}"
james%%JAMES_VERSION%%_home="${james%%JAMES_VERSION%%_home:-"%%JAMES_HOME%%"}"
james%%JAMES_VERSION%%_base="${james%%JAMES_VERSION%%_base:-"%%JAMES_HOME%%"}"
james%%JAMES_VERSION%%_tmpdir="${james%%JAMES_VERSION%%_tmpdir:-"/tmp"}"
james%%JAMES_VERSION%%_stop_timeout="${james%%JAMES_VERSION%%_stop_timeout:-"10"}"
. /etc/rc.subr
name="james%%JAMES_VERSION%%"
rcvar=james%%JAMES_VERSION%%_enable
pidfile="%%PID_FILE%%"
JAVA_HOME=%%JAVA_HOME%%
JRE_HOME=$JAVA_HOME/jre
JVM_EXT_DIRS="${james%%JAMES_VERSION%%_home}/lib:${james%%JAMES_VERSION%%_home}/tools/lib"
JVM_OPTS="-Djava.ext.dirs=$JVM_EXT_DIRS"
load_rc_config "${name}"
if [ -n "${james%%JAMES_VERSION%%_java_home}" ] ; then
export JAVA_HOME="${james%%JAMES_VERSION%%_java_home}"
fi
if [ -n "${james%%JAMES_VERSION%%_java_version}" ] ; then
export JAVA_VERSION="${james%%JAMES_VERSION%%_java_version}"
fi
if [ -n "${james%%JAMES_VERSION%%_java_vendor}" ] ; then
export JAVA_VENDOR="${james%%JAMES_VERSION%%_java_vendor}"
fi
if [ -n "${james%%JAMES_VERSION%%_java_os}" ] ; then
export JAVA_OS="${james%%JAMES_VERSION%%_java_os}"
fi
if [ "$JAVA_HOME" = "" ] ; then
echo "ERROR: JAVA_HOME not found in your environment."
echo
echo "Please, set the JAVA_HOME variable in your environment to match the"
echo "location of the Java Virtual Machine you want to use."
exit 1
fi
if [ -z "${james%%JAMES_VERSION%%_tmpdir}" ] ; then
# Define the java.io.tmpdir to use for Phoenix
james%%JAMES_VERSION%%_tmpdir="${james%%JAMES_VERSION%%_home}"/temp
mkdir -p "${james%%JAMES_VERSION%%_tmpdir}"
fi
java_cmd=
if [ -z "${JAVA_HOME}" ] ; then
java_cmd=%%LOCALBASE%%/bin/java
else
java_cmd=${JAVA_HOME}/bin/java
fi
java_command="$java_cmd $JVM_OPTS \
-Djava.security.policy=jar:file:${james%%JAMES_VERSION%%_home}/bin/phoenix-loader.jar!/META-INF/java.policy \
-Dphoenix.home=${james%%JAMES_VERSION%%_home} \
-Djava.io.tmpdir=${james%%JAMES_VERSION%%_tmpdir} \
-jar ${james%%JAMES_VERSION%%_home}/bin/phoenix-loader.jar >/dev/null"
PHOENIX_CONSOLE="$PHOENIX_TMPDIR/phoenix.console"
if [ -z "$PHOENIX_CONSOLE" ]
then
if [ -w /dev/console ]
then
PHOENIX_CONSOLE=/dev/console
else
PHOENIX_CONSOLE=/dev/tty
fi
fi
# Subvert the check_pid_file procname check.
if [ -f $pidfile ]; then
read rc_pid junk < $pidfile
if [ ! -z "$rc_pid" ]; then
procname=`ps -o ucomm= $rc_pid`
fi
fi
command="/usr/sbin/daemon"
flags="-p ${pidfile} ${java_command}"
start_precmd=pid_touch
stop_cmd="james%%JAMES_VERSION%%_stop"
pid_touch ()
{
touch $pidfile
}
james%%JAMES_VERSION%%_stop() {
rc_pid=$(check_pidfile $pidfile *$procname*)
if [ -z "$rc_pid" ]; then
[ -n "$rc_fast" ] && return 0
if [ -n "$pidfile" ]; then
echo "${name} not running? (check $pidfile)."
else
echo "${name} not running?"
fi
return 1
fi
echo "Stopping ${name}."
kill ${rc_pid}>/dev/null
james_wait_max_for_pid ${james%%JAMES_VERSION%%_stop_timeout} ${rc_pid}
kill -KILL ${rc_pid} 2> /dev/null && echo "Killed."
echo -n > ${pidfile}
}
james_wait_max_for_pid() {
_timeout=$1
shift
_pid=$1
_prefix=
while [ $_timeout -gt 0 ] ; do
echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_pid
_prefix=", "
sleep 2
kill -0 $_pid 2> /dev/null || break
_timeout=$(($_timeout-2))
done
if [ -n "$_prefix" ]; then
echo "."
fi
}
run_rc_command "$1"
|