openhab / openhab-distro

The binary distribution of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.3k stars 389 forks source link

Tune Karaf Service Wrapper Conf for Windows #467

Open AngelosF opened 7 years ago

AngelosF commented 7 years ago

Hi All,

TL;DR: wrapper:install produces an incomplete wrapper.conf that needs major changes for the Windows OH2 service to work

Issue: Since bin\setenv.bat (which calls also oh2_dir_layout.bat) on Windows is NOT used by the Apache Karaf Service Wrapper" (source: Link), we need to find a way to "fix" the default wrapper.conf file that is being generated by the wrapper:install command.

One way would be to include in the distro a script that runs all the necessary commands to install the Windows service.

It would have to:

feature:install service-wrapper (needed?)
wrapper:install --name "openHAB2" --display "openHAB2" --description "openHAB 2 Service" (this generates the "problematic" `%APP_ETC%\%APP_NAME%-wrapper.conf`
Overwrite the generated wrapper.conf with the distributed one (we need to find a way to let user adjust `OPENHAB_HOME`
openHAB2-service.bat install
net start "openHAB2"

What solutions can be applied here?

Relevant info: https://community.openhab.org/t/documenting-openhab-2/10568/151 https://github.com/openhab/openhab-docs/pull/398#issuecomment-309223733 http://docs.openhab.org/installation/windows.html#starting-openhab-as-a-service

maggu2810 commented 7 years ago

Why not providing a openhab:wrapper-install command that internally uses the wrapper:install command with the correct arguments and modifies the wrapper configuration itself?

AngelosF commented 7 years ago

That's a great idea! I don't even know if this is possible within Karaf (a new console command?) I am not that advanced :)

kaikreuzer commented 7 years ago

You might be interested in https://github.com/openhab/openhab-core/blob/master/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/command/InstallServiceCommand.java.