updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / apache-activemq / activemq.rc.d
blob66e9ea3ef5a3ea4f3822c06fd4adb20e77759d9f
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 ACTIVEMQ_HOME=/opt/activemq
7 PIDFILE="$ACTIVEMQ_HOME/data/activemq.pid"
8 umask=077
10 check_pid() {
11 [ ! -f "$PIDFILE" ] && return 1
12 local PID=$(cat "$PIDFILE" 2> /dev/null)
13 [ -z "$PID" ] && return 1
14 if [ ! -d "/proc/$PID" ]; then
15 rm -f "$PIDFILE" 2> /dev/null
16 return 1
18 return 0
21 kill_pid() {
22 if check_pid; then
23 local PID=$(cat "$PIDFILE" 2> /dev/null)
24 kill $PID &> /dev/null
25 local RET=$?
26 check_pid
27 return $RET
29 return 1
32 wait_pid() {
33 while check_pid; do sleep 1; done
36 case "$1" in
37 start)
38 stat_busy "Starting ActiveMQ"
39 check_pid || JAVA_HOME=/opt/java $ACTIVEMQ_HOME/bin/activemq start >/dev/null 2>&1 &
40 if [ $? -gt 0 ]; then
41 stat_fail
42 else
43 add_daemon activemq
44 stat_done
47 stop)
48 stat_busy "Stopping ActiveMQ"
49 if ! kill_pid; then
50 stat_fail
51 else
52 rm_daemon activemq
53 stat_done
56 restart)
57 $0 stop
58 wait_pid
59 $0 start
62 echo "usage: $0 {start|stop|restart}"
63 esac
64 exit 0