blob: 29d1ffe70e736d8ab51113e96202d2fa6bbdf2c0 (
plain)
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$
#
# PROVIDE: %%APP_SHORTNAME%%
# REQUIRE: NETWORKING SERVERS
# KEYWORD: shutdown
#
# Configuration settings for geronimo%%GERONIMO_VERSION%% in /etc/rc.conf:
#
# geronimo%%GERONIMO_VERSION%%_enable (bool):
# Set to "NO" by default.
# Set it to "YES" to enable geronimo%%GERONIMO_VERSION%%
#
# geronimo%%GERONIMO_VERSION%%_flags (str):
# Set to "" by default.
# Extra flags passed to start command
#
# geronimo%%GERONIMO_VERSION%%_home (str)
# Set to "%%GERONIMO_HOME%%" by default.
# Set the CATALINA_HOME variable for the Tomcat process
#
# geronimo%%GERONIMO_VERSION%%_base (str)
# Set to "%%GERONIMO_HOME%%" by default.
# Set the CATALINA_BASE variable for the Tomcat process
#
# geronimo%%GERONIMO_VERSION%%_tmpdir (str)
# Set to "%%GERONIMO_HOME%%/temp" by default.
#
# geronimo%%GERONIMO_VERSION%%_out (str)
# Set to "%%GERONIMO_OUT%%" by default.
# Set the location for the Geronimo process log (standard output & error output)
#
# 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.
#
# geronimo%%GERONIMO_VERSION%%_java_home (str):
# geronimo%%GERONIMO_VERSION%%_java_vendor (str):
# geronimo%%GERONIMO_VERSION%%_java_version (str):
# geronimo%%GERONIMO_VERSION%%_java_os (str):
# Specify the requirements of the Java VM to use. See javavm(1).
#
# geronimo%%GERONIMO_VERSION%%_classpath (str):
# Set to "" by default.
# Addtional classes to add to the CLASSPATH
#
# geronimo%%GERONIMO_VERSION%%_java_opts (str):
# Set to "" by default.
# Java VM args to use.
#
geronimo%%GERONIMO_VERSION%%_enable="${geronimo%%GERONIMO_VERSION%%_enable:-"NO"}"
geronimo%%GERONIMO_VERSION%%_java_version="${geronimo%%GERONIMO_VERSION%%_java_version:-"%%JAVA_VERSION%%"}"
geronimo%%GERONIMO_VERSION%%_user="${geronimo%%GERONIMO_VERSION%%_user:-"%%USER%%"}"
geronimo%%GERONIMO_VERSION%%_home="${geronimo%%GERONIMO_VERSION%%_home:-"%%GERONIMO_HOME%%"}"
geronimo%%GERONIMO_VERSION%%_base="${geronimo%%GERONIMO_VERSION%%_base:-"%%GERONIMO_HOME%%"}"
geronimo%%GERONIMO_VERSION%%_tmpdir="${geronimo%%GERONIMO_VERSION%%_tmpdir:-"/tmp"}"
geronimo%%GERONIMO_VERSION%%_out="${geronimo%%GERONIMO_VERSION%%_out:-"%%GERONIMO_OUT%%"}"
geronimo%%GERONIMO_VERSION%%_stop_timeout="${geronimo%%GERONIMO_VERSION%%_stop_timeout:-"10"}"
. /etc/rc.subr
name="geronimo%%GERONIMO_VERSION%%"
rcvar=`set_rcvar`
pidfile="%%PID_FILE%%"
JAVA_HOME=%%JAVA_HOME%%
JRE_HOME=$JAVA_HOME/jre
EXT_DIRS="$JRE_HOME/lib/ext:${geronimo%%GERONIMO_VERSION%%_home}/lib/ext"
ENDORSED_DIRS="$JRE_HOME/lib/endorsed:${geronimo%%GERONIMO_VERSION%%_home}/lib/endorsed"
LONG_OPT=
if [ "$1" = "start" ] ; then
LONG_OPT=--long
fi
load_rc_config "${name}"
if [ -n "${geronimo%%GERONIMO_VERSION%%_java_home}" ] ; then
export JAVA_HOME="${geronimo%%GERONIMO_VERSION%%_java_home}"
fi
if [ -n "${geronimo%%GERONIMO_VERSION%%_java_version}" ] ; then
export JAVA_VERSION="${geronimo%%GERONIMO_VERSION%%_java_version}"
fi
if [ -n "${geronimo%%GERONIMO_VERSION%%_java_vendor}" ] ; then
export JAVA_VENDOR="${geronimo%%GERONIMO_VERSION%%_java_vendor}"
fi
if [ -n "${geronimo%%GERONIMO_VERSION%%_java_os}" ] ; then
export JAVA_OS="${geronimo%%GERONIMO_VERSION%%_java_os}"
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 \
${geronimo%%GERONIMO_VERSION%%_java_opts} \
-Dorg.apache.geronimo.base.dir=${geronimo%%GERONIMO_VERSION%%_base} \
-Djava.endorsed.dirs=$ENDORSED_DIRS \
-Djava.ext.dirs=$EXT_DIRS \
-Djava.io.tmpdir=${geronimo%%GERONIMO_VERSION%%_tmpdir}"
java_start_command="${java_command} \
-jar ${geronimo%%GERONIMO_VERSION%%_home}/bin/server.jar $LONG_OPT"
java_stop_command="${java_command} \
-jar ${geronimo%%GERONIMO_VERSION%%_home}/bin/shutdown.jar"
log_args=">> ${geronimo%%GERONIMO_VERSION%%_out} 2>&1"
# 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_start_command} ${geronimo%%GERONIMO_VERSION%%_flags} ${log_args}"
start_precmd=pid_touch
stop_cmd="geronimo%%GERONIMO_VERSION%%_stop"
pid_touch ()
{
touch $pidfile
chown $geronimo%%GERONIMO_VERSION%%_user $pidfile
}
geronimo%%GERONIMO_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} 2> /dev/null
geronimo_wait_max_for_pid ${geronimo%%GERONIMO_VERSION%%_stop_timeout} ${rc_pid}
kill -KILL ${rc_pid} 2> /dev/null && echo "Killed."
echo -n > ${pidfile}
}
geronimo_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"
|