ports/net/openmq/files/imq.in
Doug Barton 83eb2c3700 In the rc.d scripts, change assignments to rcvar to use the
literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().

In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
2012-01-14 08:57:23 +00:00

137 lines
4 KiB
Bash

#!/bin/sh
#
# Copyright (c) 2009, 2010 Radim Kolar. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# $FreeBSD$
# PROVIDE: imq
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable Open MQ:
#
# imq_enable="YES"
# # optional
# imq_data="/var/spool/imq"
# imq_vmargs="-Xms150m -Xss128k -XX:MaxGCPauseMillis=5000"
# imq_brokerlist="hostname1:7676,hostname2:7676"
# imq_memory="256m"
. /etc/rc.subr
name="imq"
rcvar=imq_enable
load_rc_config $name
imq_enable=${imq_enable:-"NO"}
imq_data=${imq_data:-"/var/spool/imq"}
imq_vmargs=${imq_vmargs:-"-Xms150m -Xss128k -Xbatch -XX:MaxGCPauseMillis=5000"}
imq_memory=${imq_memory:-"256m"}
pidfile=/var/run/imq.pid
start_cmd="${name}_start"
start_precmd="${name}_build_cmdline"
command=%%PREFIX%%/imq/bin/imqbrokerd
command_args="-bgnd -silent"
command_interpreter="/bin/sh"
sigstop=INT
CONF_FILE=%%PREFIX%%/etc/mq/imqbrokerd.conf
#Check if we have enabled AUTOSTART feature, which overrides rcvar=NO
if ! checkyesno ${rcvar}; then
if [ -f $CONF_FILE -a -r $CONF_FILE ]; then
autostart=`grep "^AUTOSTART=" $CONF_FILE | cut -c11-`
if checkyesno autostart; then
eval ${rcvar}=YES
fi
fi
fi
imq_start()
{
if [ -z "$rc_pid" ]; then
echo -n "Starting $name"
# do we have memory limit defined?
if [ -n "$imq_memory" ]; then
#add imq_memory to vmargs
echo "$imq_vmargs" | grep -q -- '-Xmx'
if [ ! $? -eq 0 ]; then
imq_vmargs="$imq_vmargs -Xmx${imq_memory}"
fi
fi
#run with imq_vmargs if defined
if [ -n "$imq_vmargs" ]; then
${command} ${command_args} -vmargs "$imq_vmargs" &
else
${command} ${command_args} &
fi
echo -n $! > $pidfile
echo "."
else
echo "imq is already running with pid=$rc_pid."
fi
}
imq_build_cmdline()
{
# add imq_flags
if [ -n "$imq_flags" ]; then
command_args="$command_args $imq_flags"
fi
#check if RESTART feature is enabled
if [ -f $CONF_FILE -a -r $CONF_FILE ]; then
autorestart=`grep "^RESTART=" $CONF_FILE | cut -c9-`
autoargs=`grep "^ARGS=" $CONF_FILE | cut -c6-`
if checkyesno autorestart; then
command_args="$command_args -autorestart"
fi
fi
#load aditional command line arguments from broker config file
if [ -n $autoargs ]; then
echo "$autoargs" | grep -q -- '-varhome'
if [ ! $? -eq 0 ]; then
command_args="$command_args -varhome $imq_data $autoargs"
else
command_args="$command_args $autoargs"
fi
fi
#add brokerlist if not yet defined
if [ -n "$imq_brokerlist" ]; then
echo "$command_args" | grep -q -- '-cluster '
if [ ! $? -eq 0 ]; then
command_args="$command_args -cluster $imq_brokerlist"
fi
fi
return 0
}
run_rc_command "$1"