2

When i run karaf, i need to install some features into it. For that i give commands like:

install -s mvn:org.apache.derby/derby/10.8.2.2
feature:install jndi jpa transaction http

I want to automate this thing as i want to start karaf by itself on reboot. I have read that i can start it on reboot by using wrapper:service. But next question to my mind is how will i give these commands.

I have read that it can be done using etc/shell.init.script. But i am not able to understand examples given on scripting page of karaf site.

Last lines on shell.init.script file in my karaf is:

help = { *:help $args | more } ;
man = { help $args } ;
log:list = { log:get ALL } ;

Should i simply write these commands below these lines, or i need to write some functions like given on scripting page ( one is given below) of which i have no idea.

#
# Add a value at the end of a property in the given OSGi configuration
#
# For example:
# > config-add-to-list org.ops4j.pax.url.mvn org.ops4j.pax.url.mvn.repositories http://scala-tools.org/repo-releases
#
config-add-to-list = {
  config:edit $1 ;
  a = (config:property-list | grep --color never $2 | tac) ;
  b = (echo $a | grep --color never "\b$3\b" | tac) ;
  if { ($b trim) isEmpty } {
    if { $a isEmpty } {
      config:property-set $2 $3
    } {
      config:property-append $2 ", $3"
    } ;
    config:update
  } {
    config:cancel
  }
}
HimanshuR
  • 1,390
  • 5
  • 16
  • 35

2 Answers2

1

After studying some more concepts and doing some hit and trail i found these commands can be written in the script but, it has to be specified with its package( i dont know what to call it a package or a bundle)

These commands can be given in this form:

bundle:install -s mvn:org.apache.derby/derby/10.8.2.2
feature:install jndi jpa transaction http
shell:echo "in script"
HimanshuR
  • 1,390
  • 5
  • 16
  • 35
  • 1
    The first part of karaf commands (`bundle`, `feature`, `shell`...) is called **scope** – Francesco Di Paolo Feb 09 '16 at 15:55
  • I have a question that is similar to this. Unfortunately, this answer really doesn't help. I don't know where you put those commands, etc. https://stackoverflow.com/q/61020044/1582712 Think you could help? – E.S. Apr 03 '20 at 20:42
0

You can add features (and feature repos) to install at startup in 'org.apache.karaf.features.cfg' under the featuresRepositories and featuresBoot sections.

Steven Spungin
  • 27,002
  • 5
  • 88
  • 78