Exemple A.4. Script de lancement de JBoss go.sh
#!/bin/sh
#source function library.
. /etc/init.d/functions
TOMCAT_HOME=/applis/JBoss-2.4.4_Tomcat-4.0.1/catalina
JBOSS_HOME=/applis/JBoss-2.4.4_Tomcat-4.0.1/jboss
JAVA_HOME=/usr/lib/j2sdk1.3
JAVACMD=$JAVA_HOME/bin/java
JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/bin/run.jar:$JAVA_HOME/lib/tools.jar
JBOSS_CLASSPATH=$JBOSS_CLASSPATH
HOTSPOT=`java -version 2>&1 | grep HotSpot`"x"
if [ "$HOTSPOT" != "x" ]; then
HOTSPOT="-server"
else
HOTSPOT=""
fi
JBOSS_CLASSPATH=$JBOSS_CLASSPATH:$JBOSS_HOME/lib/crimson.jar
JAXP=-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.crimson.
jaxp.DocumentBuilderFactoryImpl
JAXP="$JAXP -Djavax.xml.parsers.SAXParserFactory=org.apache.
crimson.jaxp.SAXParserFactoryImpl"
case "$1" in
start)
shift
#echo -n "JBoss starting:"
if [ -f /var/run/jboss.pid ] ; then
print_status running
else
$JAVACMD $HOTSPOT $JAXP -classpath $JBOSS_CLASSPATH org.jboss.Main
catalina > /dev/null 2>&1 &
echo $! > /var/run/jboss.pid
until [ `tail -n 1 $JBOSS_HOME/log/server.log |
grep "JBoss-2.4.4 Started" | wc -l` -eq 1 ] ; do
sleep 5
done
print_status success
fi
;;
stop)
shift
#echo -n "JBoss stoping:"
if [ -f /var/run/jboss.pid ] ; then
kill -15 `cat /var/run/jboss.pid`
rm -rf /var/run/jboss.pid
until [ `tail -n 1 $JBOSS_HOME/log/server.log |
grep "Shutdown complete" | wc -l` -eq 1 ] ; do
sleep 5
done
print_status success
else
print_status stopped
fi
;;
run)
shift
$JAVACMD $HOTSPOT $JAXP -classpath $JBOSS_CLASSPATH org.jboss.Main catalina
;;
status)
shift
if [ -f /var/run/jboss.pid ] ; then
print_status status_running
else
print_status status_stopped
fi
;;
esac
exit 0
Exemple A.5. Script de lancement de JBoss jboss ( à mettre dans /etc/init.d )
#!/bin/sh
export JAVA_HOME=/usr/lib/j2sdk1.3
export JBOSS_HOME=/applis/JBoss-2.4.4_Tomcat-4.0.1/jboss
export PATH=$PATH:$JBOSS_HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
RETVAL=0
# See how we were called.
case "$1" in
start)
cd $JBOSS_HOME/bin
echo -n "Starting JBoss/Tomcat daemon: "
$JBOSS_HOME/bin/go.sh start
;;
stop)
echo -n "Stopping JBoss/Tomcat daemon: "
cd $JBOSS_HOME/bin
$JBOSS_HOME/bin/go.sh stop
;;
status)
echo -n "Status JBoss/Tomcat daemon: "
$JBOSS_HOME/bin/go.sh status
;;
restart)
echo -n "Restarting jboss daemon: "
$0 stop
sleep 2
$0 start
;;
esac