#!/bin/bash -p

# $Id: runmx4j.bash,v 1.2 2007/07/22 21:19:06 blaine Exp $

# JMX Accelerated Howto and its sample code are copyrighted with the
# BSD license available in the Howto document.
# Copyright (c) 2004-2007, Axis Data Management Corp

# This is a UNIX script for starting up the MX4J HttpAdaptor with a HTML
# transformer.

# Modify the SECURITY_SETTINGS to secure access.
# Modify the CLASSPATH to give visibilty the the Classes which you want
# to manage.... and correct the path to mx4j-tools.jar.
# Invoke like "nohup ./run.bash"

set +u
[ -e httpd.pid ] && kill -INT $(<httpd.pid) 2>&-
sleep 1
rm -f httpd.pid

export SECURITY_SETTINGS=
export CLASSPATH=.:/opt/mx4j/lib/mx4j-tools.jar:dist/tst.jar:offlimits

echo 'Exit with "kill $(<httpd.pid)" (from this directory).'
bash -c 'echo $$ > httpd.pid;
exec java $SECURITY_SETTINGS MX4JHttpAdaptor' > stdout.txt 2> stderr.txt &

# Alternatively, to run in foreground comment out the 3 lines above, and
# de-comment the following lines.
#echo 'Exit with Ctrl-C.'
#exec java $SECURITY_SETTINGS MX4JHttpAdaptor
