分类: LINUX
2009-03-23 11:26:53
# /etc/profile |
jboss_home=/usr/local/jboss4x
path=$path:$jboss_home/bin
export jboss _home path |
# ln –s /etc/init.d/jboss_init_redhat.sh /etc/rc3.d/k20jboss_init_redhat
# ln –s /etc/init.d/jboss_init_redhat.sh /etc/rc3.d/s80jboss_init_redhat
# ln –s /etc/init.d/jboss_init_redhat.sh /etc/rc5.d/k20jboss_init_redhat
# ln –s /etc/init.d/jboss_init_redhat.sh /etc/rc5.d/s80jboss_init_redhat |
# vi /etc/init.d/jboss_init_redhat.sh |
#!/bin/sh
#
# jboss control script
#
# chkconfig: 3 80 20
# description: jboss ejb container
#
# to use this script
# run it as root - it will switch to the specified user
# it loses all console output - use the log.
#
# here is a little (and extremely primitive)
# startup/shutdown script for redhat systems. it assumes
# that jboss lives in /usr/local/jboss, it's run by user
# 'jboss' and jdk binaries are in /usr/local/jdk/bin. all
# this can be changed in the script itself.
# bojan
#
# either amend this script for your requirements
# or just ensure that the following variables are set correctly
# before calling the script
# [ #420297 ] jboss startup/shutdown for redhat
#define where jboss is - this is the directory containing directories log, bin, conf etc
jboss_home=${jboss_home:-"/usr/local/jboss4x"}
#make java is on your path
javapth=${javapth:-"/usr/local/j2sdk
#define the classpath for the shutdown class
jbosscp=${jbosscp:-"$jboss_home/bin/shutdown.jar:$jboss_home/client/jnet.jar"}
#define the script to use to start jboss
jbosssh=${jbosssh:-"$jboss_home/bin/run.sh -c all"}
if [ -n "$jboss_console" -a ! -d "$jboss_console" ]; then
# ensure the file exists
touch $jboss_console
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
#define what will be done with the console log
jboss_console=${jboss_console:-"/dev/null"}
#define the user under which jboss will run, or use runasis to run as the current user
jbossus=${jbossus:-"jboss"}
cmd_start="cd $jboss_home/bin; $jbosssh"
cmd_stop="java -classpath $jbosscp org.jboss.shutdown --shutdown"
if [ "$jbossus" = "runasis" ]; then
subit=""
else
subit="su - $jbossus -c "
fi
if [ -z "`echo $path | grep $javapth`" ]; then
export path=$path:$javapth
fi
if [ ! -d "$jboss_home" ]; then
echo jboss_home does not exist as a valid directory : $jboss_home
exit 1
fi
echo cmd_start = $cmd_start
case "$1" in
start)
cd $jboss_home/bin
if [ -z "$subit" ]; then
eval $cmd_start >${jboss_console} 2>&1 &
else
$subit "$cmd_start >${jboss_console} 2>&1 &"
fi
;;stop)
if [ -z "$subit" ]; then
$cmd_stop
else
$subit "$cmd_stop"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 (start|stop|restart|help)"
esac |