I need to issue Karaf shell commands non-interactively, preferably from a script. More specifically, I need to tell Karaf to feature:install
a set of features in an automated way.
# Attempt to install a feature in a way I could script
bash> bin/karaf feature:install myFeature
# Drops me into Karaf shell
karaf> feature:uninstall myFeature
Error executing command: Feature named 'myFeature' is not installed
# Feature wasn't installed
Is this possible? Is there a different way of solving this issue (automated install of a set of Karaf features) that I'm missing?
To issue Karaf shell commands not-interactively, preferably from a script you can also use the Karaf client (scroll down to "Apache Karaf client"). To install features I use command like
/opt/karaf/bin/client -r 7 "feature:install http; feature:install webconsole"
The -r
switch allows to retry the connection if the server is not up yet (I use it in a Docker script).