【问题标题】:script to run commands at start of apache karaf在 apache karaf 开始时运行命令的脚本
【发布时间】:2015-06-18 09:24:57
【问题描述】:

当我运行 karaf 时,我需要在其中安装一些功能。为此,我给出如下命令:

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

我想自动化这件事,因为我想在重新启动时自行启动 karaf。我读过我可以使用 wrapper:service 在重新启动时启动它。但我想到的下一个问题是我将如何发出这些命令。

我读过它可以使用 etc/shell.init.script 来完成。但我无法理解 karaf 网站 scripting 页面上给出的示例。

我的 karaf 中 shell.init.script 文件的最后几行是:

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

我应该简单地在这些行下面写这些命令,还是我需要写一些我不知道的脚本页面上给出的函数(下面给出了一个)。

#
# 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
  }
}

【问题讨论】:

    标签: osgi apache-karaf karaf


    【解决方案1】:

    在研究了一些概念并进行了一些尝试后,我发现这些命令可以写在脚本中,但是必须用它的包来指定(我不知道叫它包还是包)

    这些命令可以以这种形式给出:

    bundle:install -s mvn:org.apache.derby/derby/10.8.2.2
    feature:install jndi jpa transaction http
    shell:echo "in script"
    

    【讨论】:

    • karaf 命令的第一部分(bundlefeatureshell...)被称为scope
    • 我有一个类似的问题。不幸的是,这个答案真的没有帮助。我不知道你把这些命令等放在哪里了。stackoverflow.com/q/61020044/1582712你能帮忙吗?
    【解决方案2】:

    您可以在 featuresRepositoriesfeaturesBoot 下的“org.apache.karaf.features.cfg”中添加要在启动时安装的功能(和功能存储库) 部分。

    【讨论】:

      猜你喜欢
      • 2014-12-13
      • 2014-01-08
      • 1970-01-01
      • 2022-09-23
      • 2011-03-10
      • 2017-12-07
      • 1970-01-01
      • 1970-01-01
      • 2016-02-07
      相关资源
      最近更新 更多