在 apache karaf 开始时运行命令的脚本 [英] script to run commands at start of apache karaf
问题描述
当我运行 karaf 时,我需要在其中安装一些功能.为此,我给出如下命令:
install -s mvn:org.apache.derby/derby/10.8.2.2功能:安装 jndi jpa 事务 http
我想自动化这件事,因为我想在重新启动时自行启动 karaf.我已经读到我可以通过使用 wrapper:service 在重新启动时启动它.但我想到的下一个问题是我将如何发出这些命令.
我读到可以使用 etc/shell.init.script 来完成.但我无法理解 scripting 页面上给出的示例卡拉夫网站.
我的 karaf 中 shell.init.script 文件的最后几行是:
help = { *:help $args |更多的 } ;人 = { 帮助 $args } ;日志:列表 = { 日志:获取所有 } ;
我应该简单地在这些行下面写这些命令,还是我需要写一些我不知道的脚本页面上给出的函数(下面给出了一个).
<预><代码>## 在给定的 OSGi 配置中的属性末尾添加一个值## 例如:# >配置添加到列表 org.ops4j.pax.url.mvn org.ops4j.pax.url.mvn.repositories http://scala-tools.org/repo-releases#配置添加到列表 = {配置:编辑 $1 ;a = (config:property-list | grep --color never $2 | tac) ;b = (echo $a | grep --color 从不 "\b$3\b" | tac) ;if { ($b trim) isEmpty } {如果 { $a isEmpty } {config:property-set $2 $3} {config:property-append $2", $3"};配置:更新} {配置:取消}}在研究了更多的概念并做了一些跟踪后,我发现这些命令可以写在脚本中,但是,它必须用它的包指定(我不知道叫什么包或包)
这些命令可以以这种形式给出:
bundle:install -s mvn:org.apache.derby/derby/10.8.2.2功能:安装 jndi jpa 事务 http外壳:回声在脚本中"
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
}
}
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"
这篇关于在 apache karaf 开始时运行命令的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!