Karaf CLI

The Apache Karaf container used by the Frinx ODL Distribution supports three different start modes:

  1. regular mode starts Apache Karaf in the foreground, including the shell console.
  2. server mode starts Apache Karaf in the foreground, without the shell console.
  3. background mode starts Apache Karaf in the background.

You can also manage Apache Karaf as a system service (see System Service section of this manual).

Regular mode
Uses the bin/karaf Linux script (binkaraf.bat on Windows). It’s the default start process. It starts Apache Karaf as a foreground process, and displays the shell console.

a. On Linux:

b. On Windows:

and [cmd] --help for help on a specific command.

Hit <ctrl-d> or type system:shutdown or logout to shutdown Karaf.

karaf@root()>

Server mode
Server mode starts Apache Karaf as a foreground process, but doesn’t start the shell console. To use this mode, use the server argument to the bin/karaf Linux script (on Windows the script is at binkaraf.bat).
a. On Linux:

b. On Windows:

You can connect to the shell console using SSH or client (see the Connect section in this page).

Background mode
Background mode starts Apache Karaf as a background process. To start in background mode, you have to use the bin/start Linux script (binstart.bat on Windows).

a. On Linux:

b. On Windows:

Clean start
Apache Karaf stores all previously installed applications and changes that you made in the data folder. If you want to start from a clean state, you can remove the data folder. For convenience, you can use the clean argument to the bin/karaf Linux script (binkaraf.bat on Windows).
a. On Linux:

b. On Windows:

Customize variables
Apache Karaf accepts environment variables:

You can define these environment variables in the bin/setenv Linux script (binsetenv.bat on Windows). For instance, to set the minimum and maximum memory size for the JVM, you can define the following values: a. On Linux: Content of bin/setenv

b. On Windows:** rem Content of binsetenv.bat**

Connecting
Even if you start Apache Karaf without the console (using server or background modes), you can connect to the console. This connection can be local or remote, in which case you can access the Karaf console remotely. To connect to the console, you can use the bin/client Linux script (binclient.bat on Windows).
a. On Linux:

Logging in as karaf 360 [pool-2-thread-3] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier – Server at /0.0.0.0:8101 presented unverified key:

Hit [tab] for a list of available commands

Type[cmd] --help for help on a specific command.

Type system:shutdown to shutdown Karaf.

Hit <ctrl-d> or type logout to disconnect the shell from the current session.

karaf@root()>

b. On Windows:

Logging in as karaf 360 [pool-2-thread-3] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier – Server at /0.0.0.0:8101 presented unverified key:

Hit [tab] for a list of available commands

Type[cmd] --help for help on a specific command.

Type system:shutdown to shutdown Karaf.

Hit <ctrl-d> or type logout to disconnect shell from current session.

By default, client tries to connect on localhost, on port 8101 (the default Apache Karaf SSH port). Client accepts different options to let you connect on a remote Apache Karaf instance. You can use –help to get details about these options.

Help
a. On Linux:

Apache Karaf client

-a [port] specify the port to connect to -h [host] specify the host to connect to -u [user] specify the user name

  • -help shows this help message -v raise verbosity
  • -r [attempts] retry connection establishment (up to attempts times) -d [delay] intra-retry delay (defaults to 2 seconds) -b batch mode, specify multiple commands via standard input -f [file] read commands from the specified file [commands] commands to run

If no commands are specified, the client will be put into an interactive mode

b. On Windows:

Apache Karaf client
-a [port] specify the port to connect to -h [host] specify the host to connect to -u [user] specify the user name –help shows this help message -v raise verbosity -r [attempts] retry connection establishment (up to attempts times) -d [delay] intra-retry delay (defaults to 2 seconds) -b batch mode, specify multiple commands via standard input -f [file] read commands from the specified file [commands] commands to run If no commands are specified, the client will be put in an interactive mode