Starting the BI Server At Boot Time On Linux

You can start and stop the BI Server using the scripted commands start-pentaho.sh and stop-pentaho.sh which are located in /biserver-ce directory by default.  To have the BI Server start automatically during boot time, we need to modify these two scripts and create a startup script called pentaho.  All configurations here were tested on Ubuntu 8.10 64-bit.

When modifying start-pentaho.sh we need to accomplish two things.  First we need to make sure all directory changes are appropriate.  Second, we need to make sure to add an "&" at the end of the start_hypersonic.sh line.  If we forget to add an "&" sign at the end of the command, the system will run the script and wait for it to quit.  During boot we would like for the service to start via script and not hold the system up in any way. 

The following script assumes that BI Server is installed in /biserver-ce and that administrative-console is installed at /administration-console.

/biserver-ce/start-pentaho.sh should read as follows:

#!/bin/sh
### ====================================================================== ###
##                                                                          ##
##  Pentaho Start Script                                                    ##
##                                                                          ##
### ====================================================================== ###

if [ -e promptuser.sh ]; then
  sh promptuser.sh
  rm promptuser.sh
fi
if [ "$?" = 0 ]; then
  cd data
  sh start_hypersonic.sh &
  cd ..
  cd tomcat/bin
  export CATALINA_OPTS="-Xms256m -Xmx768m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
  sh startup.sh
fi

Next, your /biserver-ce/stop-pentaho.sh should read as follows:

#!/bin/sh
### ====================================================================== ###
##                                                                          ##
##  Pentaho Stop Script                                                     ##
##                                                                          ##
### ====================================================================== ###

cd data
sh stop_hypersonic.sh &
cd ..
cd tomcat/bin
sh shutdown.sh






We will now go to create the appropriate startup script to start and stop the BI Server and administrative console in /etc/init.d

create a file called pentaho in /etc/init.d by typing the following:

sudo nano /etc/init.d/pentaho

Some of the fine points to notice about the script below is that in it we define the JAVA_HOME and JRE_HOME variables.  During boot we have no guarantees that any environment variables will have been set by the time our script runs.  We define them here so the BI Server will start.  According to the documentation for BI Server v2.x and BI Server 3.x-RCX Sun's Java 1.5 is the only reliable way to go. 

We add the following text to the file:

#!/bin/bash
### BEGIN INIT INFO
# Provides: start-pentaho stop-pentaho
# Required-Start: networking mysql
# Required-Stop: mysql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Pentaho BI Platform
### END INIT INFO
export JAVA_HOME="/usr/lib/jvm/java-1.5.0-sun"
export JRE_HOME="/usr/lib/jvm/java-1.5.0-sun/jre"

start(){
if [ "$1" == "adm" ];then
        echo "Iniciando aplicacao administration-console"
        cd ../administration-console
       ./start-pac.sh > /tmp/pentaho_console.out 2>&1 &

else
        echo "Iniciando aplicacao biserver"
        ./start-pentaho.sh > /tmp/pentaho.out 2>&1
fi

echo "ok"

}

stop(){
echo "recebi: $1"

if [ "$1" == "adm" ];then
        echo "Finalizando aplicacao administration-console"
        cd ../administration-console
        ./stop-pac.sh
else
        echo "Finalizando aplicacao biserver"
        ./stop-pentaho.sh
fi

echo "ok"
}


case "$1" in
start)
        start $2
        ;;
stop)
        stop $2
        ;;
*)
        printf "\nUsage: $0 \n
                start | stop            : Inicia ou finaliza a aplicacao biserver\n
                start adm | stop adm    : Inicia ou finaliza o administration console\n\n"
        ;;
esac
exit 0

Please note:

If you would like the scripts to run as a background task when the server starts up instead of launching in a terminal window, append an "&" to the end of the script name.  So, in the above code:

 cd /biserver-ce
/biserver-ce/start-pentaho.sh&
cd /administration-console
/administration-console/start.sh&




Now we need to make pentaho executable and add it to the startup and shutdown runlevels.

To make our new script executable by the system we run the following command

sudo chmod +x /etc/init.d/pentaho

Finally, we add the pentaho script to the system startup and shutdown runlevels by issuing the following command.

sudo update-rc.d pentaho defaults

The Pentaho BI Server, Sample Database (Hypersonic), and administration console will now start at boot time and shut down when the system restarts or stops.