/etc/init.d/activemq is in activemq 5.6.0+dfsg-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | #! /bin/sh
### BEGIN INIT INFO
# Provides: activemq
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ActiveMQ instance
# Description: Start ActiveMQ instance
### END INIT INFO
# Author: Damien Raude-Morvan <drazzib@debian.org>
# Author: Jonas Genannt <jonas.genannt@capi2name.de>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="ActiveMQ instance"
NAME=activemq
DAEMON=/usr/bin/$NAME
SCRIPTNAME=/etc/init.d/`basename $0`
DEFAULT=/etc/default/$NAME
ACTIVEMQ_JAR=/usr/share/activemq/bin/run.jar
ACTIVEMQ_INSTANCES_ENABLED=/etc/activemq/instances-enabled
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
# Whether to start ActiveMQ (as a daemon or not)
NO_START=0
ACTIVEMQ_USER=activemq
DIETIME=2
# Read configuration variable file if it is present
[ -r $DEFAULT ] && . $DEFAULT
# Exit now if daemon binary is not installed
test -x $DAEMON || exit 0
# Check that the user exists (if we set a user)
# Does the user exist?
if [ -n "$ACTIVEMQ_USER" ] ; then
if getent passwd | grep -q "^$ACTIVEMQ_USER:"; then
# Obtain the uid and gid
DAEMONUID=`getent passwd |grep "^$ACTIVEMQ_USER:" | awk -F : '{print $3}'`
DAEMONGID=`getent passwd |grep "^$ACTIVEMQ_USER:" | awk -F : '{print $4}'`
else
log_failure_msg "The user $ACTIVEMQ_USER, required to run $NAME does not exist."
exit 1
fi
fi
# Check whether startup has been disabled
if [ "$NO_START" != "0" -a "$1" != "stop" ]; then
[ "$VERBOSE" != "no" ] && log_failure_msg "Not starting $NAME - edit /etc/default/$NAME and change NO_START to be 0 (or comment it out)."
exit 0
fi
# Check if any instances exists in instances-enabled directory
check_instances_enabled() {
if [ -d "$ACTIVEMQ_INSTANCES_ENABLED" ] && [ `/bin/ls $ACTIVEMQ_INSTANCES_ENABLED | wc -l` -gt 0 ]; then
return 1
else
return 0
fi
}
# Check if a given process pid's cmdline matches a given name
running_pid() {
pid=$1
[ -z "$pid" ] && return 1
[ ! -d /proc/$pid ] && return 1
cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|grep "activemq\.base" |cut -d= -f2`
getinst=`basename $cmd`
# Is this the expected server
[ "x$getinst" != "x$INSTANCE" ] && return 1
return 0
}
# Check if the process is running looking at /proc
# (works for all users)
running() {
# No pidfile, probably no daemon present
[ ! -f "$ACTIVEMQ_PIDFILE" ] && return 1
pid=`cat $ACTIVEMQ_PIDFILE`
running_pid $pid || return 1
return 0
}
# Start the process using the wrapper
start_servers() {
mkdir -p /var/run/activemq/
chown $ACTIVEMQ_USER /var/run/activemq/
if check_instances_enabled; then
echo "No instances found at ${ACTIVEMQ_INSTANCES_ENABLED}."
exit 0
fi
for INSTANCE in `ls $ACTIVEMQ_INSTANCES_ENABLED`; do
if [ -d "${ACTIVEMQ_INSTANCES_ENABLED}/${INSTANCE}" ]; then
ACTIVEMQ_PIDFILE="/var/run/activemq/$INSTANCE.pid"
ACTIVEMQ_CONFIG_DIR="$ACTIVEMQ_INSTANCES_ENABLED/$INSTANCE"
export INSTANCE
export ACTIVEMQ_USER
export ACTIVEMQ_PIDFILE
export ACTIVEMQ_HOME=/usr/share/activemq
export ACTIVEMQ_CONFIG_DIR
# Import global configuration
. /usr/share/activemq/activemq-options
# Import per instance configuration
[ -r "${ACTIVEMQ_CONFIG_DIR}/options" ] && . ${ACTIVEMQ_CONFIG_DIR}/options
log_progress_msg "$INSTANCE"
start-stop-daemon --start --quiet --pidfile $ACTIVEMQ_PIDFILE \
--chuid $ACTIVEMQ_USER --background \
--name java --startas $DAEMON -- $ACTIVEMQ_ARGS
errcode=$?
if [ ! $errcode ]; then
log_progress_msg "(failed)"
else
[ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
if running; then
log_progress_msg "(running)"
else
log_progress_msg "(failed?)"
fi
fi
else
echo -n "${INSTANCE} (not an directory)"
fi
done
}
# Stops an running Instance
stop_server() {
INSTANCE=$1
ACTIVEMQ_PIDFILE="/var/run/activemq/$INSTANCE.pid"
start-stop-daemon --stop --quiet --pidfile $ACTIVEMQ_PIDFILE \
--user $ACTIVEMQ_USER \
--name java --startas $DAEMON -- stop
if running; then
force_stop
fi
if running; then
log_progress_msg "(failed)"
else
log_progress_msg "(stopped)"
fi
}
# Stop the process using the wrapper
stop_servers() {
for INSTANCE in `ls /var/run/activemq/`; do
INSTANCE=$(echo $INSTANCE | sed 's@.pid@@')
log_progress_msg "$INSTANCE"
stop_server "$INSTANCE"
done
}
# Force the process to die killing it manually
force_stop() {
[ ! -e "$ACTIVEMQ_PIDFILE" ] && return
if running ; then
kill -15 $pid
# Is it really dead?
sleep "$DIETIME"s
if running ; then
kill -9 $pid
sleep "$DIETIME"s
if running ; then
echo "Cannot kill $NAME (pid=$pid)!"
exit 1
fi
fi
fi
rm -f $ACTIVEMQ_PIDFILE
}
case "$1" in
console)
INSTANCE=$2
if [ ! -z $INSTANCE ]; then
log_daemon_msg "Starting with Console $DESC " "$INSTANCE"
if [ -r "${ACTIVEMQ_INSTANCES_ENABLED}/${INSTANCE}/activemq.xml" ]; then
ACTIVEMQ_PIDFILE="/var/run/activemq/$INSTANCE.pid"
ACTIVEMQ_CONFIG_DIR="$ACTIVEMQ_INSTANCES_ENABLED/$INSTANCE"
if [ -f $ACTIVEMQ_PIDFILE ]; then
stop_server "$INSTANCE"
fi
export INSTANCE
export ACTIVEMQ_USER
export ACTIVEMQ_PIDFILE
export ACTIVEMQ_HOME=/usr/share/activemq
export ACTIVEMQ_CONFIG_DIR
# Import global configuration
. /usr/share/activemq/activemq-options
# Import per instance configuration
[ -r "${ACTIVEMQ_CONFIG_DIR}/options" ] && . ${ACTIVEMQ_CONFIG_DIR}/options
ACTIVEMQ_ARGS=$(echo $ACTIVEMQ_ARGS | sed 's/start/console/')
start-stop-daemon --start --pidfile $ACTIVEMQ_PIDFILE \
--chuid $ACTIVEMQ_USER \
--name java --startas $DAEMON -- $ACTIVEMQ_ARGS
else
echo "File ${ACTIVEMQ_INSTANCES_ENABLED}/${BROKER}/activemq.xml not found."
exit 1
fi
else
echo "Usage: $0 console foo"
echo "This will start instance foo in foreground useful for debugging purposes."
exit 1
fi
log_end_msg 0
;;
start)
log_daemon_msg "Starting $DESC " "$NAME"
start_servers
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
stop_servers
log_end_msg 0
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
stop_servers
start_servers
log_end_msg 0
;;
status)
log_daemon_msg "Checking status of $DESC" "$NAME"
for INSTANCE in `ls $ACTIVEMQ_INSTANCES_ENABLED`; do
if [ -d "${ACTIVEMQ_INSTANCES_ENABLED}/${INSTANCE}" ]; then
ACTIVEMQ_PIDFILE="/var/run/activemq/${INSTANCE}.pid"
log_progress_msg "$INSTANCE"
if running; then
log_progress_msg "(running)"
else
log_progress_msg "(stopped)"
fi
fi
done
log_end_msg 0
;;
reload)
log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
log_warning_msg "cannot re-read the config file (use restart)."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status|console}" >&2
exit 1
;;
esac
exit 0
|