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