Commit fa2d125b authored by Truc Nguyen's avatar Truc Nguyen
Browse files

feat(custom-init): update with PR feedbacks

parent 77cd7fac
......@@ -8,16 +8,16 @@ This feature relies on the ability to extend the [Bonita Docker image](https://h
Custom initialization scripts must be placed in BCD's `roles/bonita/files/custom-init.d` folder. Each script to execute must have a `.sh` extension.
Here's the directory layout for a `` custom script:
Here's the directory layout for a `` custom script:
├── bonita
│   ├── files
│   │   ├── custom-init.d
│   │   │   ├── bonita-tenant-sp-custom.xml
│   │   │   ├──
│   │   │   ├── login-logo.png
│   │   │   ├── logo.png
│   │   │   └──
│   │   │   ├── event-handler-example-1.0.0-SNAPSHOT.jar
│   │   │   └──
## When are custom initialization scripts invoked?
......@@ -66,85 +66,14 @@ More precisely scripts are executed in the order returned by this command: `ls -
Ths `` script is provided as part of BCD's core scripts.
In particular it shows how to further configure the server using [Bonita Platform setup tool](${bonitaDocVersion}/BonitaBPM_platform_setup).
This sample script replaces the default logo images (login and header logos) in Bonita Portal.
Assuming the following custom logo files:
- roles/bonita/files/custom-init.d/login-logo.png
- roles/bonita/files/custom-init.d/logo.png
Here's a sample `` script:
set -euxo pipefail
indicator_path=/opt/$(basename $BASH_ARGV)-executed
if [ -f ${indicator_path} ]; then
echo "Custom script already executed" && return 0
war_path=$(find "${BONITA_PATH}/Bonita"*"Subscription-${BONITA_VERSION}-Tomcat-${TOMCAT_VERSION}/server/webapps" -name bonita.war)
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rm -rf ${workdir} && mkdir -p ${workdir}
pushd ${workdir}
# extract themes from war
mkdir -p WEB-INF/classes
unzip -j "${war_path}" "WEB-INF/classes/bonita-portal-theme*.zip" -d WEB-INF/classes
# prepare logo images
mkdir -p skin/images
cp ${script_dir}/login-logo.png ${script_dir}/logo.png skin/images/
# replace logo images in themes
ls -1 WEB-INF/classes/bonita-portal-theme*.zip | xargs -I {} -n1 zip -r {} skin
# repackage war
zip -r "${war_path}" "WEB-INF/classes/bonita-portal-theme*.zip"
touch ${indicator_path}
This sample script activates all standard [REST API dynamic authorization rules](${bonitaDocVersion}/rest-api-authorization) to further secure Bonita REST API. These rules are meant to cover the most frequent cases.
set -euxo pipefail
BONITA_SETUP_SH=$(find "${BONITA_PATH}/Bonita"*"-${BONITA_VERSION}-Tomcat-${TOMCAT_VERSION}/setup" -name
# Pull current configuration
# Uncomment all default rules
find ${BONITA_PATH}/Bonita*-${BONITA_VERSION}-Tomcat-${TOMCAT_VERSION}/setup/platform_conf/current -name "" | xargs -I{} -n10 \
sed -i "s/^#\(GET|\|POST|\|PUT|\|DELETE|\)/\1/g"
# Update configuration
This sample script deploys and registers a Bonita engine Event handler as described in [Event handlers Documentation](${bonitaDocVersion}/event-handlers).
Assuming the following files:
- roles/bonita/files/custom-init.d/event-handler-example-1.0.0-SNAPSHOT.jar (event handler JAR file)
- roles/bonita/files/custom-init.d/bonita-tenant-sp-custom.xml (tenant configuration file where the event handler is registered)
- `roles/bonita/files/custom-init.d/event-handler-example-1.0.0-SNAPSHOT.jar` (event handler JAR file)
- `roles/bonita/files/custom-init.d/bonita-tenant-sp-custom.xml` (tenant configuration file where the event handler is registered)
Here's a sample `` script:
......@@ -186,6 +115,8 @@ ${BONITA_SETUP_SH} push
This sample script deploys the [JavaMelody monitoring tool]( to Bonita web application. This example shows how to download external jars and include them to Bonita WAR.
With this example, JavaMelody will be available at this URL: `http://<bonita_host>:8081/bonita/monitoring`.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment