Tag Archives: jboss

Related softwares:

  1. JBoss 5.1.0
  2. Ubuntu 9.04

As of time of writing, Ubuntu repository only provides JBoss AS 4. So, to install the latest JBoss (5.1.0), you need to manually download it from:
http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/jboss-5.1.0.GA-jdk6.zip/download

Once you downloaded the jboss-5.1.0.GA-jdk6.zip archive file, unzip it and put the folder jboss-5.1.0.GA in /opt folder. Thus, I’ve chosen /opt/jboss-5.1.0.GA path as my $JBOSS_HOME.

To setup the JBoss to startup on machine bootup, below are the steps.

Create a system user named jboss by running below command in the terminal:

sudo adduser --system jboss

Change the owner of $JBOSS_HOME and its subfolders to jboss user by typing below command:

 sudo chown jboss /opt/jboss-5.1.0.GA -R
 

Create a script file named jboss in /etc/init.d folder. Type in below content into the jboss script:

#! /bin/sh

JBOSS_HOME=/opt/jboss-5.1.0.GA

start(){
 echo "Starting jboss.."

 sudo -u jboss ${JBOSS_HOME}/bin/run.sh -b 0.0.0.0 > /dev/null &
}

stop(){
 echo "Stopping jboss.."

 sudo -u jboss ${JBOSS_HOME}/bin/shutdown.sh -S > /dev/null &
 #give time to shutdown jboss services.
 sleep 60
 #kill all java services started by user jboss
 su -l jboss -c 'killall java'
}

restart(){
 stop
 start
}

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

exit 0

Include above startup script into Ubuntu bootup sequence by typing command below:

sudo update-rc.d /etc/init.d/jboss defaults
sudo service jboss start

And you’re done.

References:

  1. http://www.jboss.org/community/wiki/StartJBossOnBootWithLinux