#!/bin/sh
### BEGIN INIT INFO
# Provides: start-pentaho stop-pentaho
# Required-Start: networking postgresql
# Required-Stop: postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Pentaho BA Server
### END INIT INFO


export PENTAHO_HOME=/usr/local/pentaho/biserver

case "$1" in
'start')

   echo "Iniciando pentaho biserver"
   cd $PENTAHO_HOME/biserver-ce
   ./start-pentaho.sh &

   echo "Iniciando pentaho administration-console"
   cd $PENTAHO_HOME/administration-console
   ./start-pac.sh &

   echo "ok"
   ;;

'stop')

   echo "Finalizando pentaho administration-console"
   cd $PENTAHO_HOME/administration-console
   ./stop-pac.sh &

   echo "Finalizando pentaho biserver"
   cd $PENTAHO_HOME/biserver-ce
   ./stop-pentaho.sh &

   echo "ok"
   ;;
'restart')
   $0 stop
   sleep 5
   $0 start
   ;;

*)
   echo "Usage: $0 (start|stop|restart)"

esac

exit 0
