Branding
Console
You can "brand" the Apache Karaf console.
By branding, it means that you can define your own:
-
the welcome message (motd or Message Of The Day) displayed when you start the console
-
the prompt displayed to the users
There are 2 ways of branding the Karaf console:
-
adding a branding.properties file to etc
-
creating a branding bundle.
Adding a branding.properties file to etc
Create a etc/branding.properties
file similar to:
welcome = \ \u001B[36m __ __ ____ \u001B[0m\r\n\ \u001B[36m / //_/____ __________ _/ __/ \u001B[0m\r\n\ \u001B[36m / ,< / __ `/ ___/ __ `/ /_ \u001B[0m\r\n\ \u001B[36m / /| |/ /_/ / / / /_/ / __/ \u001B[0m\r\n\ \u001B[36m /_/ |_|\\__,_/_/ \\__,_/_/ \u001B[0m\r\n\ \r\n\ \u001B[1m Apache Karaf\u001B[0m (4.0.0)\r\n\ \r\n\ Hit '\u001B[1m<tab>\u001B[0m' for a list of available commands\r\n\ and '\u001B[1m[cmd] --help\u001B[0m' for help on a specific command.\r\n\ Hit '\u001B[1m<ctrl-d>\u001B[0m' or '\u001B[1mosgi:shutdown\u001B[0m' to shutdown Karaf.\r\n prompt = \u001B[1m${USER}@${APPLICATION}\u001B[0m>
Start Karaf and you will see your branded Karaf console.
Adding a branding-ssh.properties file to etc
In a similar way, a etc/branding-ssh.properties
file can be added. It should contain the same
welcome
and prompt
entries but those will be used for external clients connecting through ssh.
The values default to the ones in etc/branding.properties
if this file is not defined.
Branding bundle
WebConsole
It’s also possible to brand the Apache Karaf WebConsole.
You have to create a bundle, fragment of the Apache Karaf WebConsole.
This WebConsole branding bundle contains a META-INF/webconsole.properties
containing branding properties:
# # This file contains branding properties to overwrite the default # branding of the Apache Felix Web Console when deployed in an # Apache Karaf application. webconsole.brand.name = My Web Console webconsole.product.name = My Karaf webconsole.product.url = http://karaf.apache.org/ webconsole.product.image = /res/karaf/imgs/logo.png webconsole.vendor.name = The Apache Software Foundation webconsole.vendor.url = http://www.apache.org webconsole.vendor.image = /res/karaf/imgs/logo.png webconsole.favicon = /res/karaf/imgs/favicon.ico webconsole.stylesheet = /res/karaf/ui/webconsole.css
The bundle also provides the css stylesheet and images defined in this properties file.
As for console, you can use the following pom.xml
to create the WebConsole branding bundle:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my.group.id</groupId> <artifactId>branding</artifactId> <packaging>bundle</packaging> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.4.0</version> <extensions>true</extensions> <configuration> <instructions> <Bundle-DocURL>http://felix.apache.org/site/apache-karaf.html</Bundle-DocURL> <Fragment-Host>org.apache.karaf.webconsole.console;bundle-version="[3,4)"</Fragment-Host> <Export-Package>!*</Export-Package> <Import-Package> javax.servlet;version=2.4, javax.servlet.http;version=2.4, !org.apache.felix.webconsole*, org.apache.aries.blueprint, org.osgi.service.blueprint.container, org.osgi.service.blueprint.reflect, * </Import-Package> </instructions> </configuration> </plugin> </plugins> </build> </project>
With the webconsole
feature installed, you can install this bundle (using bundle:install
or by editing the
etc/startup.properties
), you will see the WebConsole with your branding.