【发布时间】: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