CopyDisable

Saturday, 5 January 2013

Shell script to run Pentaho as service

For this blog post I am using Ubuntu Linux 12.04 and Pentaho 4.5. This script will start/stop pentaho bi-server and the administration console. Also this script will show the running status of the pentaho bi-server and the administration console.

I am naming this script as pentaho (as my service name)

#pico pentaho

#!/bin/sh
# Startup script for Pentaho BI Server and Administration Console
# Author: Pranab Sharma
http://pe-kay.blogspot.in/
# Usage: ./pentaho.sh start | stop | restart | status

JAVA_OPTS="-Djava.awt.headless=true"
case "$1" in
start)

cd /usr/local/pentaho-4.5/biserver-ce

$cmd ./start-pentaho.sh >> biserver.log &
# Start admin console
cd /usr/local/pentaho-4.5/administration-console

$cmd ./start-pac.sh >> admin-console.log &
;;
stop)

cd /usr/local/pentaho-4.5/administration-console

$cmd ./stop-pac.sh >> admin-console.log &

cd /usr/local/pentaho-4.5/biserver-ce

$cmd ./stop-pentaho.sh >> biserver.log &
;;
restart)
$0 stop
$0 start
;;
status)
admin_pid=$(ps -ef | grep pentaho-open-admin-console | grep -v grep | awk '{print $2}')
if [ ! -z "$admin_pid" ]
then
echo "Pentaho Admin Console is running with PID $admin_pid"
else
echo "Pentaho Admin Console is not running"
fi
biserver_pid=$(ps -ef | grep biserver-ce | grep -v grep | awk '{print $2}')
if [ ! -z "$biserver_pid" ]
then
echo "Pentaho BiServer is running with PID $biserver_pid"
else
echo "Pentaho BiServer is not running"
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0

 

Make this script executable

# chmod +x pentaho

Copy the script to /etc/init.d

# cp pentaho /etc/init.d

That’s it, our pentaho service is ready.

Sample run of this service:

image