How to install CRX packages automatically on server startup

Question

How can I repackage the crx quickstart jar file to include packages that I would like to install when crx is started for the first time?

Answer, Resolution

Installing Packages Automatically on CRX startup

The CRX application includes a directory named crx-quickstart/repository/install that can be used for installing CRX packages automatically on CRX application startup. This feature is called the CRX Auto Installer. Packages that are copied to this folder will be installed in alphabetical order.

From CRX2.3 OR Later

Please use directory named <cq_home>/crx-quickstart/install for installing packages automatically on application startup.

Installing Packages on CRX Quickstart Installation

You may also have packages automatically installed when CRX is first installed. This can be done by creating a custom CRX Quickstart jar that will auto install your packages. To do this we must add the package files to the jar file under /static/repository/install/.

Example

To provide a more in depth understanding, we will take a look at how CQ5 uses this feature.

CQ5.3 uses the install folder for auto-installing its packages. If you run java -jar cq-author-4502.jar -unpack on a CQ5.3 jar then you will see the following CRX packages in crx-quickstart/repository/install before you start the server for the first time:

cq-content-5.3.jar

cq-documentation-5.3.zip

After starting CQ5 for the first time you will see that 2 property files are generated under crx-quickstart/repository/install. These files track that the packages have already been installed by the CRX Auto Installer: