Wednesday, November 16, 2011

How to write CQ / WEM init script for Linux

Use case : You want to start and stop CQ on system start and stop

Solution: Here is script that you can use. Put this script in /etc/init.d


1. Create a file /etc/init.d/cq5 on your server and copy the contents from below script.
2. edit the file and make the following changes
update the "pidfile:" config to match your cq instance
update the "CQ5_ROOT" and "CQ5_USER" variables to match your cq instance
3. Run this command:
chmod 755 /etc/init.d/cq5
4. Run this command to add the config to redhat startup and shutdown:
chkconfig --add cq5

#!/bin/bash
#
# /etc/rc.d/init.d/cq5
#
#
#
#
# # of the file to the end of the tags section must begin with a #
# character. After the tags section, there should be a blank line.
# This keeps normal comments in the rest of the file from being
# mistaken for tags, should they happen to fit the pattern.>
#
# chkconfig: 35 85 15
# description: This service manages the Adobe WEM Content Management java process.
# processname: cq5
# pidfile: /crx-quickstart/server/logs/cq.pid

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

CQ5_ROOT=/opt/cq5
CQ5_USER=cq5

########
SERVER=${CQ5_ROOT}/crx-quickstart/server
START=${SERVER}/start
STOP=${SERVER}/stop
STATUS="${SERVER}/serverctl status"

case "$1" in
start)
echo -n "Starting cq5 services: "
su - ${CQ5_USER} ${START}
touch /var/lock/subsys/cq5
;;
stop)
echo -n "Shutting down cq5 services: "
su - ${CQ5_USER} ${STOP}
rm -f /var/lock/subsys/cq5
;;
status)
su - ${CQ5_USER} ${STATUS}
;;
restart)
su - ${CQ5_USER} ${STOP}
su - ${CQ5_USER} ${START}
;;
reload)
;;
*)
echo "Usage: cq5 {start|stop|status|reload}"
exit 1
;;
esac





For CQ5.5



#!/bin/bash
#
# /etc/r.d/init.d/cq5author
#
# of the file to the end of the tags section must begin with a #
# character. After the tags section, there should be a blank line.
# This keeps normal comments in the rest of the file from being
# mistaken for tags, should they happen to fit the pattern.>
#
# chkconfig: 35 85 15
# description: This service manages the Adobe WEM Content Management java process.
# processname: cq5author
# pidfile: /crx-quickstart/conf/cq.pid

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

CQ5_ROOT=/opt/Adobe/cq5_5/author
CQ5_USER=root

########
SERVER=${CQ5_ROOT}/crx-quickstart
START=${SERVER}/bin/start
STOP=${SERVER}/bin/stop
STATUS="${SERVER}/bin/status"

case "$1" in
start)
echo -n "Starting cq5 services: "
su - ${CQ5_USER} ${START}
touch /var/lock/subsys/cq5
;;
stop)
echo -n "Shutting down cq5 services: "
su - ${CQ5_USER} ${STOP}
rm -f /var/lock/subsys/cq5
;;
status)
su - ${CQ5_USER} ${STATUS}
;;
restart)
su - ${CQ5_USER} ${STOP}
su - ${CQ5_USER} ${START}
;;
reload)
;;
*)
echo "Usage: cq5 {start|stop|status|reload}"
exit 1
;;
esac


Thanks Andrew Khoury and Daniel Gordon from Adobe for providing this information.

No comments:

Post a Comment