Pentaho – Avviare il servizio al boot. Uno script per CentOS, Fedora e RHEL

Ho visto che in giro non è ancora stato pubblicato uno script per l’avvio automatico di pentaho su sistemi linux derivati da Red Hat così ho pensato di mettere online il mio:

#!/bin/bash
#
# chkconfig: - 92 36
# description: Starts and stops pentaho.

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

unset BASH_ENV ENV

PUSER="pentaho"
PENTAHO_HOME="/opt/pentaho/biserver-ce"
JAVA_HOME="/usr/lib/jvm/jre-1.6.0/"
prog=$"Pentaho server"
logfile="${PENTAHO_HOME}/pentaho.log"

if [ -e "${logfile}" ]; then
    rm -f "${logfile}" > /dev/null
fi

cd ${PENTAHO_HOME}
. "${PENTAHO_HOME}/set-pentaho-java.sh"

if [ -d "${PENTAHO_HOME}/jre" ]; then
    setPentahoJava "${PENTAHO_HOME}/jre" >> ${logfile} 2>&1
else
    setPentahoJava >> ${logfile} 2>&1
fi

PENV="export _PENTAHO_JAVA_HOME=${_PENTAHO_JAVA_HOME} && export _PENTAHO_JAVA=${_PENTAHO_JAVA} && export JAVA_OPTS='-Djava.awt.headless=true' && export JAVA_HOME=${_PENTAHO_JAVA_HOME}"

start() {
    echo -n $"Starting $prog: "

    if [ -e "${PENTAHO_HOME}/promptuser.sh" ]; then
        sh "${PENTAHO_HOME}/promptuser.sh" >> ${logfile} 2>&1
        rm "${PENTAHO_HOME}/promptuser.sh"
    fi

    if [ "$?" = 0 ]; then
        /sbin/runuser -l ${PUSER} -c "${PENV} && cd '${PENTAHO_HOME}/data' && sh ./start_hypersonic.sh & " >> ${logfile} 2>&1 && \
        /sbin/runuser -l ${PUSER} -c "${PENV} && cd '${PENTAHO_HOME}/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" >> ${logfile} 2>&1 && echo "OK" || echo "ERROR"

    fi

}

stop() {
    echo -n $"Shutting down $prog: "

    /sbin/runuser -l ${PUSER} -c "${PENV} && cd '${PENTAHO_HOME}/data' && sh ./stop_hypersonic.sh & "  >> ${logfile} 2>&1 && \
    /sbin/runuser -l ${PUSER} -c "${PENV} && cd '${PENTAHO_HOME}/tomcat/bin' && sh ./shutdown.sh"  >> ${logfile} 2>&1 && echo 'OK' || echo "ERROR"

}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	sleep 3
	start
	;;
  status)
	ps U 'pentaho' | grep -e 'sh ./start_hypersonic.sh' >> /dev/null && echo "$prog is running" || echo "$prog is stopped"
	;;
  *)
	echo $"Usage: $0 {start|stop|restart}"
	exit 1
esac

Ovviamente sarà necessario configurare le variabili in base alla installazione di Pentaho.

Alla prossima.

Leave a comment

1 Comments.

  1. ti faccio il fischio…aspetto la ricetta:-)
    Annamaria

Leave a Reply


[ Ctrl + Enter ]