freebsd-ports/mail/openemm2013/files/openemm2013.in
Kurt Jaeger bc3fc9f856 New port: mail/openemm2013
OpenEMM is a feature-rich web-based enterprise application for email
marketing, newsletters and service mails (transaction mails and
event or time triggered mails). OpenEMM offers a great user interface,
sophisticated bounce management, link tracking, lots of graphical
realtime statistics, a CMS module and a scripting feature to implement
individual tasks.

OpenEMM is the first open source application for e-mail marketing.
Its code base has been developed since 1999 and is used - as part
of the commercial software product E-Marketing Manager (EMM) - by
companies like IBM, Daimler, Siemens and Deutsche Telekom.

OpenEMM offers already more than 95% of the functionality of most
commercial products and some features most commercial products do
not offer right now (for example MySQL support and CMS functionality).

WWW: http://www.openemm.org

PR:		196516
Submitted by:	Horst Leitenmueller <horst.leitenmueller@liwest.at>
2015-10-17 16:41:29 +00:00

176 lines
5.7 KiB
Bash

#!/bin/sh
#
# %%APP_SHORTNAME%% startup script.
#
# $FreeBSD$
#
# PROVIDE: %%APP_SHORTNAME%%
# REQUIRE: NETWORKING SERVERS
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf to enable %%APP_SHORTNAME%%:
# %%APP_SHORTNAME%%_enable (bool): Set to "YES" to enable %%APP_SHORTNAME%%
# %%APP_SHORTNAME%%_args (str): Optional arguments to OAJBoss
# %%APP_SHORTNAME%%_log_stdout (str) OpenEMM log output stdout, filename.
# %%APP_SHORTNAME%%_log_stderr (str) OpenEMM log output stderr, filename.
#
. /etc/rc.subr
name="%%APP_SHORTNAME%%"
rcvar=%%APP_SHORTNAME%%_enable
extra_commands="status"
load_rc_config $name
%%APP_SHORTNAME%%_logdir="%%LOG_DIR%%"
%%APP_SHORTNAME%%_enable="${%%APP_SHORTNAME%%_enable:-"NO"}"
%%APP_SHORTNAME%%_log_stdout="${%%APP_SHORTNAME%%_log_stdout:-"${%%APP_SHORTNAME%%_logdir}/log"}"
%%APP_SHORTNAME%%_log_stderr="${%%APP_SHORTNAME%%_log_stderr:-"${%%APP_SHORTNAME%%_logdir}/error"}"
%%APP_SHORTNAME%%_args="${%%APP_SHORTNAME%%_args:-""}"
%%APP_SHORTNAME%%_sleep="${%%APP_SHORTNAME%%_sleep:-"5"}"
%%APP_SHORTNAME%%_kill9="${%%APP_SHORTNAME%%_kill9:-""}"
%%APP_SHORTNAME%%_additional_killall="${%%APP_SHORTNAME%%_additional_killall:-""}"
%%APP_SHORTNAME%%_user="%%USER%%"
%%APP_SHORTNAME%%_group="%%GROUP%%"
%%APP_SHORTNAME%%_lockdir="/var/run/openemm"
start_cmd="%%APP_SHORTNAME%%_start"
stop_cmd="%%APP_SHORTNAME%%_stop"
pidfile="%%PID_FILE%%"
tomcat_pidfile="tomcat8.pid" # todo replace dynamic with current version
sendmail_pidfile="sendmail.pid"
OPENEMM_HOME="%%APP_HOME%%"
#minimal requirements must be set for our javavmwrapper
JAVA_VERSION="1.7+"
export JAVA_VERSION
%%APP_SHORTNAME%%_start ()
{
if [ ! -d "${%%APP_SHORTNAME%%_logdir}" ]
then
install -d -o ${%%APP_SHORTNAME%%_user} ${%%APP_SHORTNAME%%_logdir}
fi
if [ ! -d "${%%APP_SHORTNAME%%_lockdir}" ]
then
install -d -o ${%%APP_SHORTNAME%%_user} ${%%APP_SHORTNAME%%_lockdir}
fi
echo "Preconditions for %%APP_SHORTNAME%%"
echo " - check if sendmail processes are stopped, it will be started via this application"
if [ -f "/var/run/${sendmail_pidfile}"]
then
echo "TODO STOP all sendmail processes"
service sendmail stop
# check for sendmail queues started via openemm
if [ -f "${%%APP_SHORTNAME%%_lockdir}/mailer.pid" ]
then
echo "Stop Mailer Service...."
pkill qctrl
pkill sendmail
fi
fi
echo "Starting %%APP_SHORTNAME%%."
# check for the startup pyhton scripts
# check if tomcat is running otherwise warning
if [ ! -f "/var/run/${tomcat_pidfile}" ]
then
echo "Tomcat is not running please start tomcat first"
else
echo "Tomcat is running... starting app"
fi
echo "Start BOUNCE Servcie...."
daemon -u ${%%APP_SHORTNAME%%_user} ${OPENEMM_HOME}/bin/bounce.sh start >> ${%%APP_SHORTNAME%%_logdir}/bounce.log 2>> ${%%APP_SHORTNAME%%_logdir}/bounce_error.log
echo "Start Merger Service...."
daemon -u ${%%APP_SHORTNAME%%_user} ${OPENEMM_HOME}/bin/merger.sh start >> ${%%APP_SHORTNAME%%_logdir}/merger.log 2>> ${%%APP_SHORTNAME%%_logdir}/merger_error.log
echo "Start Mailer Service...."
daemon ${OPENEMM_HOME}/bin/mailer.sh start >> ${%%APP_SHORTNAME%%_logdir}/mailer.log 2>> ${%%APP_SHORTNAME%%_logdir}/mailer_error.log
pgrep sendmail > ${openemm2013_lockdir}/mailer.pid
echo "Start SLRT scan Service...."
daemon -u ${%%APP_SHORTNAME%%_user} ${OPENEMM_HOME}/bin/slrtscn.sh start >> ${%%APP_SHORTNAME%%_logdir}/slrtscn.log 2>> ${%%APP_SHORTNAME%%_logdir}/slrtscn_error.log
echo "START THE APP ITSELF..."
#daemon -u ${%%APP_SHORTNAME%%_user} ${OPENEMM_HOME}/bin/standalone.sh ${%%APP_SHORTNAME%%_args} >> ${%%APP_SHORTNAME%%_log_stdout} 2>> ${%%APP_SHORTNAME%%_log_stderr}
#sleep ${%%APP_SHORTNAME%%_sleep} # let daemon(8) and sh(1) finish before executing pgrep(1)
#pgrep -U ${%%APP_SHORTNAME%%_user} -f ${OPENEMM_HOME}/modules > ${pidfile}
#chown ${%%APP_SHORTNAME%%_user} $pidfile
}
%%APP_SHORTNAME%%_stop ()
{
${OPENEMM_HOME}/bin/bounce.sh stop
${OPENEMM_HOME}/bin/merger.sh stop
#${OPENEMM_HOME}/bin/mailer.sh stop
service sendmail stop # pkill sendmail
#sendmail stop
pkill sendmail
terminator bin/qctrl #pkill qctrl
${OPENEMM_HOME}/bin/slrtscn.sh stop
# Subvert the check_pid_file procname check.
# at the moment we dont't handle this here
if [ -f ${pidfile} ]
then
kill `cat ${pidfile}`
# Only if we aware that our setup can hangs, and only after trying simple kill, we can kill it hard way.
if [ ! -z "${%%APP_SHORTNAME%%_kill9}" ]
then
sleep ${%%APP_SHORTNAME%%_sleep}
#kill -9 `cat ${pidfile}`
fi
# In some setups, OpenEMM (Tomcat) can spawn some child processess, which could prevent it from stopping, and freeing net ports.
# Let's blindly kill them all, since we are really know what we are doing.
if [ ! -z "${%%APP_SHORTNAME%%_additional_killall}" ]
then
sleep ${%%APP_SHORTNAME%%_sleep}
killall ${%%APP_SHORTNAME%%_additional_killall}
fi
fi
}
terminator() {
while [ $# -gt 0 ] ; do
__pat="$1"
shift
if [ "$__pat" ] ; then
for sig in 15 9 ; do
__run="`ps -aux | grep -- \"$__pat\" | grep -v grep | awk '{ print $2 }'`"
if [ "$__run" ] ; then
echo "Stop $__pat program with signal $sig .. "
kill -$sig $__run >/dev/null 2>&1
sleep 2
echo "done."
fi
done
fi
done
}
%%APP_SHORTNAME%%_status ()
{
# If running, show pid
if [ -f ${pidfile} ]
then
echo "%%APP_SHORTNAME%% is running as pid" `cat ${pidfile}`
else
echo "%%APP_SHORTNAME%% is not running"
fi
}
run_rc_command "$1"