CQ5 init script

Nearly all Unix flavors have the notion of so-called initscripts, which are executed at startup (or when you switch the runlevel) and which start all required services or adapt settings. Usually all daemon and server processes are started via such initscripts. CQ5 doesn’t provide such a script out-of-the-box, but a rather complex shell script called “serverctl”, which performs many steps you would expect from a initscript:

  • assembling parameters
  • setting environment variables
  • start/stop/status of the server process (start and stop are also available a separate scripts for ease of use)

This would easily qualify this script as a initscript, but it lacks one important task: Changing the uid for the to-be-started process, it doesn’t run as root user. While from a purely functional perspective this isn’t important, every sysadmin will tell you, that you shouldn’t run processes as root, when they don’t require such permissions to perform their tasks. And the security guys won’t even let you golive with such a setting. So if you write an init script, you should add this functionality there.

And one last plea: Do not start the java process directly in the initscript and assemble the commandline yourself, but call the start&stop scripts. Especially if you are not that familiar with the serverctl script. So, a simple initscript  could look like this:


STATUS="${SERVER}/serverctl status" 

case "$1" in 
    su - ${CQ5_USER} ${START} 
    su - ${CQ5_USER} ${STOP} 
    su - ${CQ5_USER} ${STATUS} 
    echo "Unknown argument $1" 

2 thoughts on “CQ5 init script

  1. why would you not just forward all arguments to the serverctl script? Looks to me, the serverctl script is already an initscript but has a small problem that it has to be invoked from the directory it lives in unless you change the path where to find cq in the script. Something like the following would be suficcient:



    su – ${CQ_USER}./crx-quickstart/server/serverctl $*

    1. Thanks reusr1 for your comment.

      Yes, that’s the way I would do this; creating a small wrapper to prepare the environment, change to the correct path and so on.

Comments are closed.