JBoss Community

jboss autostart script

created by gasper jeric in Beginner's Corner - View the full discussion

hello

this maybe help someone. I modified ex jboss_init_redhat.sh script to work it for jboss 7.1

 

#!/bin/sh

#jboss home

JBOSS_HOME=${JBOSS_HOME:-"/opt/jboss"}

#make sure java is in your path

JAVAPTH=${JAVAPTH:-"/usr/local/jdk/bin"}

#define the classpath for the shutdown class

JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/jboss-cli.sh --connect command=:shutdown"}

#define the script to use to start jboss

JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/standalone.sh"}

#define what will be done with the console log

JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}

 

JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"

JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"$JBOSSCP"}

 

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 JBOSS_CMD_START = $JBOSS_CMD_START

 

case "$1" in

start)

    cd $JBOSS_HOME/bin & echo starting...

    if [ -z "$SUBIT" ]; then

        eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &

    else

        $SUBIT "$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &"

    fi

    ;;

stop)

    if [ -z "$SUBIT" ]; then

        $JBOSS_CMD_STOP & echo stopping...

    else

        $SUBIT "$JBOSS_CMD_STOP"

    fi

    ;;

restart)

    $0 stop

    $0 start

    ;;

*)

    echo "usage: $0 (start|stop|restart|help)"

esac

 

 

usage:

 

  • sudo service jboss start
  • sudo service jboss stop
  • sudo service jboss restart

 

or this way:

 

  • sudo /etc/init.d/jboss start
  • sudo /etc/init.d/jboss stop
  • sudo /etc/init.d/jboss restart

 

 

all comments apreciated

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community