Saturday, November 3, 2012

Linux: Create a service to automate Oracle BI Publisher 11g Trial Edition startup & shutdown

I used OEL 6.3 and Oracle BI Publisher 11g Trial Edition is installed under "oracle" user in:
/oracle/BI_Publisher_Trial

Create bi_start.sh in /home/oracle. This will start Publisher:
#!/bin/bash

# Script to start BI Publisher

. ~/.bash_profile

# Start BI Publisher
nohup /oracle/BI_Publisher_Trial/bin/startBIP.sh &

exit 0

Create bi_stop.sh in /home/oracle. This will stop Publisher:
#!/bin/bash

# Script to stop BI Publisher

. ~/.bash_profile

# Stop BI Publisher
/oracle/BI_Publisher_Trial/bin/stopBIP.sh

exit 0

Execute:
chmod u+x /home/oracle/bi*.sh

 Login as root and create /etc/init.d/publisher:
#! /bin/bash
# chkconfig: 2345 99 10
# description: BI Publisher auto start-stop script.

# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

ORA_OWNER=oracle
RETVAL=0

case "$1" in
'start')
# Start BI Publisher:
su - $ORA_OWNER -c "/home/oracle/bi_start.sh"
touch /var/lock/subsys/publisher
;;
'stop')
# Stop BI Publisher:
su - $ORA_OWNER -c "/home/oracle/bi_stop.sh"
rm -f /var/lock/subsys/publisher
;;
*)
echo $"Usage: $0 {start|stop}"
RETVAL=1
esac
exit $RETVAL

Execute as root:
chgrp dba /etc/init.d/publisher
chmod 750 /etc/init.d/publisher
chkconfig --add publisher

Check, if the service was created:
chkconfig|grep publisher
 publisher          0:off    1:off    2:on    3:on    4:on    5:on    6:off

Test it:
service publisher start
service publisher stop