Bash script for bundles deployment with options
Question
My deployment process is customized and involves several steps and operations in the bundles.
Do we have a script or an automatized process to deploy a list of bundles and that allows operations like start, stop, uninstall, install, refresh and update? Also with an option to flush the cache before installing the new bundles?
Answer
Jahia provides several REST services to perform operations in its bundles.
A Jahia package contains several bash scripts under DX_INSTALLATION_PATH/tools/ folder containing the rest calls to make all kinds of operations in bundles: install, uninstall, refresh, update, start and stop. These scripts are available for OS, Linux and Windows.
We also developed an automatized deployment script where the users can choose exactly which operations they want to run in the deployment (and the order) as well as the option to flush the cache in any moment.
The script can be fetched from here: https://github.com/Jahia/support-scripts/tree/master/bash
To read the documentation of the script one can run the following command:
$ ./deploy.sh --help
Script to perform operations in multiple bundles using the Module management REST API.
if parameter '--start' is specified, the files are started
if parameter '--stop' is specified, the bundles are stopped
if parameter '--update' is specified, the bundles are updated
if parameter '--refresh' is specified, the bundles are refreshed
if parameter '--install' is specified, the files are installed
if parameter '--uninstall' is specified, the bundles are uninstalled
if parameter '--flushcache' is specified, the cache is flushed
Configuration is described in deployconfig.json file The script will perform all actions described as parameters in the same order they were called
Usage:
./deploy.sh bundleFilePath [bundleFilePathZ ... bundleFilePathN] [ --start | --stop | --update | --refresh ... N ]
The configuration file is described in file deployconfig.json:
{
"dx_host" : "localhost:8080",
"dx_username" : "root",
"dx_password" : "password",
"dx_tool_username" : "jahia",
"dx_tool_password" : "password",
"delay_seconds" : 1
}
So let's take the following installed bundle list in Jahia as an example:
jahia@dx()> bundle:list
...
170 | Installed | 90 | 2.7.0 | file-uploader
171 | Active | 90 | 2.7.0.SNAPSHOT | file-uploader
172 | Installed | 90 | 4.0.7 | modulesExporter
173 | Active | 90 | 2.0.7.SNAPSHOT | modulesExporter
174 | Installed | 90 | 3.0.7.SNAPSHOT | modulesExporter
175 | Installed | 90 | 4.0.7.SNAPSHOT | modulesExporter
To install and update new bundles modulesExporter and file-uploader you can run the following command which will stop, uninstall, flush the cache, install, update and then start the new modules:
$ ./deploy.sh jar/file-uploader-2.7.0.jar jar/modulesexporter-4.0.7.jar --stop --uninstall --flushcache --install --update --start
Bundle org.jahia.modules/file-uploader/2.7.0 _stop successful
Bundle org.jahia.modules/file-uploader/2.7.0.SNAPSHOT _stop successful
Bundle org.jahia.modules/modulesexporter/2.0.7.SNAPSHOT _stop successful
Bundle org.jahia.modules/modulesexporter/3.0.7.SNAPSHOT _stop successful
Bundle org.jahia.modules/modulesexporter/4.0.7 _stop successful
Bundle org.jahia.modules/modulesexporter/4.0.7.SNAPSHOT _stop successful
Bundle org.jahia.modules/file-uploader/2.7.0 _uninstall successful
Bundle org.jahia.modules/file-uploader/2.7.0.SNAPSHOT _uninstall successful
Bundle org.jahia.modules/modulesexporter/2.0.7.SNAPSHOT _uninstall successful
Bundle org.jahia.modules/modulesexporter/3.0.7.SNAPSHOT _uninstall successful
Bundle org.jahia.modules/modulesexporter/4.0.7 _uninstall successful
Bundle org.jahia.modules/modulesexporter/4.0.7.SNAPSHOT _uninstall successful
Done flushing cache
Bundle jar/file-uploader-2.7.0.jar installing successful
Bundle jar/modulesexporter-4.0.7.jar installing successful
Bundle org.jahia.modules/file-uploader/2.7.0 _update successful
Bundle org.jahia.modules/modulesexporter/4.0.7 _update successful
Bundle org.jahia.modules/file-uploader/2.7.0 _start successful
Bundle org.jahia.modules/modulesexporter/4.0.7 _start successful
Deployment done!