Thursday, July 3, 2008

OIM Startup Script for JBOSS

Here is a shell script that you can use to bring up OIM quickly from your home folder.

Usage: jboss {start|stop|restart|help}

=====================================
jboss.sh
=====================================
#!/bin/sh

JBOSS_HOME=/opt/jboss
JAVA_HOME=/opt/j2sdk1.4.2_17
JBOSS_USER=oimuser
XL_HOME=/opt/oracle/xellerate
RUN_AS="su -l $JBOSS_USER -c"
XL_OPTS="-DXL.HomeDir=/opt/oracle/xellerate -Djava.awt.headless=true -Djboss.partition.name=$partition_name$"
XL_CMD_START="$JBOSS_HOME/bin/run.sh $XL_OPTS"
XL_CMD_STOP="$JBOSS_HOME/bin/shutdown.sh -S"
JBOSS_CONSOLE=$JBOSS_HOME/server/default/log/console.log

#
# Check if Jboss home directory exists
#
if [ ! -d "$JBOSS_HOME" ]; then
echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
exit 1
fi

#
# Check if XL home directory exists
#
if [ ! -d "$XL_HOME" ]; then
echo XL_HOME does not exist as a valid directory : $XL_HOME
exit 1
fi

if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
# ensure the file exists
touch $JBOSS_CONSOLE
if [ ! -z "$SUBIT" ]; then
chown $JBOSS_USER $JBOSS_CONSOLE
fi
fi

if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
echo "WARNING: ignoring it and using /dev/null"
JBOSS_CONSOLE="/dev/null"
fi

start(){
echo "Starting jboss.."

echo XL_CMD_START = $XL_CMD_START
if [ -z "$RUN_AS" ]; then
eval "$XL_CMD_START > ${JBOSS_CONSOLE} 2>&1 &"
else
$RUN_AS "$XL_CMD_START > ${JBOSS_CONSOLE} 2>&1 &"
fi

}

stop(){
echo "Stopping jboss.."

echo XL_CMD_STOP = $XL_CMD_STOP
if [ -z "$RUN_AS" ]; then
eval "$XL_CMD_STOP > ${JBOSS_CONSOLE} 2>&1 &"
else
$RUN_AS "$XL_CMD_STOP > ${JBOSS_CONSOLE} 2>&1 &"
fi

}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: jboss {start|stop|restart|help}"
exit 1
esac

exit 0


courtesy:Rajesh Mittal

1 comment:

geetha said...

Thanks for sharing this useful info. Keep updating same way.
Regards,Siddu online Training