openhab / openhab-distro

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

Windows installer #807

Open tmrobert8 opened 5 years ago

tmrobert8 commented 5 years ago

Not sure if this is something that should be in distro - so please let me know if there's a better place for this. I'd like to create an actual windows installer for openhab that has the following features:

  1. Will download/install java if needed (and insure java_home is set)
  2. Will allow the user to pick version (2.3, 2.4, stable, snapshot, etc)
  3. Will download and install the appropriate openhab distribution to a directory (with c:\openhab2 being the default)
  4. Allow the user to specify whether to install the windows service or not.

In the past, I've used Inno Setup (you can read the license here: http://www.jrsoftware.org/files/is/license.txt) and it works well but would be open to other suggestions if anyone has strong feelings (wix or nullsoft)

kaikreuzer commented 5 years ago

License of Inno Setup looks fine, it's BSD-style, so should be no problem.

I don't know how exactly the sources for such an installer will look like, but considering that we have dedicated repos for docker, synology, linuxpkg, etc., I would say that this should go into a dedicated repo as well. Feel free to start with one on your own Github and once it is ready, we can transfer that repo over to openHAB.

tmrobert8 commented 5 years ago

@kaikreuzer I've started to think about this more and wanted your input...

Here's the features I was thinking:

  1. Detect whether java is installed - will inform them to visit some java site to install. Apparently its against license to redistribute or automate installation of oracle java apparently.
  2. Install the latest stable by default (will download then install). Optionally choose snapshot or a different version EDIT: 2a Allow the user (optionally) to download/install addons.kar for the distribution (any others?)
  3. Installs to "c:\openhab2" by default. User can choose a different installation path
  4. Allows setup of a scheduled task (think cron) that will execute the backup on either daily, weekly or monthly (user choice) and to specify how many files to keep (ie last 10 backups, 11+ would be deleted)
  5. Allows setup of a windows service
  6. Creates an uninstaller that reverses above

1, 3, 4, 6 are pretty easy and straightforward.

2 - I think it would be easy to pick up on the latest stable from bintray without knowing the version number. However, the second part (choosing snapshot/version) would be more difficult - is there anything online (github or otherwise) that lists the OH versions available? My goal of the install is to make it version independent so we don't need to update it with each version. I could ask them to input the version they want - but not really user friendly if I can present a drop down listing the version - but then I'd need to have a source of versions. Thoughts?

5 - I really want to do this as most people would run it as a service. However, the current way (karaf wrapper + special conf) is really a stopping point because I'd have to open up a session (wait for all the initialization task to complete), install the wrapper (feature:install followed by wrapper:install) then [from somewhere] download the special conf and install it, then create the service - really complicated for an install script to do. Do you know of any alternatives to this?

I could quickly put together a service class (small C# service) what simply calls the 'start.bat' on startup, monitors the process and would call 'stop.bat' when ending. Pretty quick and doesn't require any special conf - but introduces a different type of service (ie not karaf) and I'm not sure you want to go there..

Tim

AngelosF commented 5 years ago

is there anything online (github or otherwise) that lists the OH versions available?

Maybe you can use: https://ci.openhab.org/job/openHAB-Distribution/ ? (this is for snapshots 2.4.0 S) https://ci.openhab.org/ has also the milestone releases (2.4.0 M) listed as well but not the stable release (2.3.0

They offer RSS and REST API (maybe you could use them to pull this info from their website?)

I don't know if there is a better online resource that covers all options (Stable, Milestone, Snapshot)

I really want to do this as most people would run it as a service. [...] Do you know of any alternatives to this?

I think that if we fix https://github.com/openhab/openhab-distro/issues/467 then it will become easier to deploy as a service. I will look into this to see if we can progress this old issue.

tmrobert8 commented 5 years ago

@AngelosF Thanks - for the initial go around, I'll probably just have a single file that needs updating for the various versions.

The real issue with the service is not being able to easily create it (the conf file is the least problem actually). What I'd need to do is open up a telnet session, wait for initialization to finish, issue the feature install for the wrapper, issue the feature install to create the service then close all that. Too much for an installation service. What would be handy if there was a single command line that I could issue that would do that for me (then I simply have to issue the command and wait for it to finish).

An alternative would be to simply embed (in the installer) the wrapper stuff to begin with (the exe, dll, conf, etc) and copy it over when needed. The only issue with that would be the snapshots (if something changed from snapshot to snapshot with the service creation).

At any rate, unless someone has some simple approach that would work - I may ignore service creation on the initial version..

AngelosF commented 5 years ago

I think that you should ignore the service installation for the initial version

It is an optional component of Karaf and it is difficult to deploy.

We already have documented installation steps that could be used to install the service after you deploy OH2 on Windows using your installer.

By the way, the Karaf docs refer to another tool that could also be used: https://github.com/kohsuke/winsw Ref: http://karaf.apache.org/manual/latest/#_service_script_templates Section: Windows

Do you think this is winsw tool can be used ? (for the next release)

tmrobert8 commented 5 years ago

The documented steps is great for someone who knows what they are doing - but I'd wager that most windows users are non-technical and those instructions would be too intimidating to complete.

winsw is one of the MANY service wrappers we could go (or I could write one myself - about 30 lines of code) with if it would be okay to abandon the karaf one. I was worried whether it would be an issue to ignore the karaf wrapper in favor of something like that. Note: if we want to go with winsw, I can add that to the initial version since it's pretty easy to setup..

AngelosF commented 5 years ago

I believe we need @kaikreuzer 's opinion here (if the installer should include the service installation method also for the first release or not).

Also: I believe that Kai is the best to best answer your other question: "is there anything online (github or otherwise) that lists the OH versions available?"

Technical solution for the service wrapper: I think you are the best to decide on that 🥇

On an "importance" scale from 0 to 10, having openHAB running as a service on Windows gets a 8 mark from me :)

If people use Win for "production" they will definitely want to run it as a service. For testing and playing: it doesn't hurt to have the Karaf console running.

kaikreuzer commented 5 years ago

I was worried whether it would be an issue to ignore the karaf wrapper in favor of something like that.

Not for me - the Karaf wrapper does not seem to work well on most platforms, so I'm fine with ignoring it and providing a better solution instead :-)

is there anything online (github or otherwise) that lists the OH versions available?

I actually do not know. But we already have to maintain those links for https://www.openhab.org/download/, so @ghys might be the right person to answer, how/where we can maintain the urls to the latest version (btw, @ghys, the milestones are still missing on the website and should probably be added there as well).

tmrobert8 commented 5 years ago

@kaikreuzer Thanks - I'll see about using winsw as the wrapper then. BTW - I switched from Inno Setup to NSIS as there were some issues using inno setup for what I wanted. Applicable license: https://nsis.sourceforge.io/License - I don't think there are any issues here but let me know if you have some doubts.

As for the versions - for the initial version, I'm just using a file to let me know the versions (simple version=desc). Example:

2.3.0=openHAB 2.3.0 Stable
2.4.0-SNAPSHOT=openHAB 2.4.0 Snapshot

I then use the same logic as the update scripts to decide on what links to hit to get the downloads. So for now - a simple update to the file would be necessary to add a new version.

A really nice to have would be some json file hosted somewhere that would be something like:

[
  {
     "version": "2.3.0",
     "desc":"openHAB 2.3.0 Stable",
     "url":"https://bintray.com/....",
     any other useful info describing the version
  }, 
  {
     "version": "2.4.0-SNAPSHOT",
     "desc":"openHAB 2.3.0 Stable",
     "url":"https://ci.openhab.org/..."
  }
]
kaikreuzer commented 5 years ago

I don't think there are any issues here but let me know if you have some doubts.

lgtm, I don't see issues with that either.

ghys commented 5 years ago

I actually do not know. But we already have to maintain those links for https://www.openhab.org/download/, so @ghys might be the right person to answer, how/where we can maintain the urls to the latest version

Currently it's only in the frontmatter of the download page (https://github.com/openhab/website/tree/master/download > currentVersion/currentSnapshotVersion). IMHO at least for the website following the KISS principle is the right way to go - but I wouldn't object to having some API call or similar during the build to retrieve current values.

(btw, @ghys, the milestones are still missing on the website and should probably be added there as well).

Right, I'll get them on the page as well!

tmrobert8 commented 5 years ago

Quick update - I've created an installer and have tested it pretty well now.

ToDo:

  1. I need to fix some side cases (features not available prior to 2.4, etc)
  2. Create the uninstaller part
  3. Create a repository of everything (ie readme, etc)

Issues left:

  1. Need some windows testers (assuming @bdleedy may want to - not sure who else)
  2. Not sure who needs to host the installer executable (and how to get it to them)
  3. Need to get with @kaikreuzer and determine if/how to do an automated build of the installer (windows, needs nsis executable, etc)
tmrobert8 commented 5 years ago

@ghys @kaikreuzer Kinda getting off topic on this issue - but since we are discussing issues. If we could get a simple file (json, xml, or properties) that describes the versions, the descriptions and maybe the type (milestone, snapshot, stable) - then there are three things that can use it:

  1. Installers
  2. Update.sh/bat
  3. Website
  4. Potentially paperui if we ever integrated the update process into it..

For now, in the windows installer - I have a simple text file that controls the version shown

tmrobert8 commented 5 years ago

Attached is the first try at the installer. Note: there may still be issues but it covers the ground pretty well. Hoping @bdleedy or other windows users will shake it down - once it seems stable, I'll invite some people from the community to try it.

openhab-setup.zip

How to Download, unzip and run it.

Notes:

  1. This was much more involved than I anticipated but I covered all the parts that I wanted - it will download, install, create update/backup jobs and create a service
  2. Note that it will select 2.4.0 stable by default - you'll want to change that since it's not valid (yet).
  3. The 2.4+ features (ie max files) won't work yet as the windows scripts that support them were just merged today. When that merge hits the snapshot (or stable), then it should work
  4. Advanced will not allow you to change the OPENHAB_ADDONS (since that doesn't exist yet) nor the OPENHAB_RUNTIME (which must be OPENHAB_HOME\runtime for now since start.bat doesn't support it). I have issues in on both of those and we can enable them when its fixed.
  5. I did not put in support for milestones - doesn't make sense to me to support those since they will change often (and we don't want to regenerate this for each milestone). Correct me if I'm wrong on that - wouldn't be a huge issue.
  6. The service installer/manager will be located in OPENHAB_HOME (along with the supporting XML file)
  7. Three new logs are written to OPENHAB_USERDATA\logs - update.ps1.log, backup.ps1.log and openHAB-service.*.log. Each are log files for the jobs/service.
  8. Uninstaller is written to OPENHAB_HOME and you can use add/remove programs to uninstall as well
  9. No support for langauges yet - would need help coming up with translations

2.0.0 and 2.1.0 Notes

  1. Doesn't support the powershell scripts - so you won't get the option to define backup/update jobs

2.2.0 and 2.3.0 Notes

  1. The powershell scripts make assumptions on directory structure - so you won't get the option to define backup/update jobs if you used the advanced option (you will get them if you didn't)
  2. The backup powershell script did not support the -MaxFiles option - so it will be disabled (and set to 0 for unlimited) on the backup job options.

2.4.0+ Notes

  1. Supports everything - however, remember that until the merge occurs - the new -MaxFiles will cause an issue. Manually copy backup.ps1 to your runtime\bin directory to test the backup job. Again - only an issue until everything is merged
bdleedy commented 5 years ago

Is this meant to be an updater as well? I would say yes, right? I tried 2.3 to 2.4. I still have 2.3....ish. It's definitely trying to run/install 2.4 things but not being successful at it at all. I think this needs some clarification first before I get to crazy with comments.

The existing service was never deleted, that would be nice. I think it was looking for one specifically called the same thing as what it did install then. This leads me to believe that you built it as an updater as well.

2018-12-20 18:10:37,705 INFO  - Uninstalling the service with id 'openHAB-2.4.0'
2018-12-20 18:10:37,721 WARN  - The service with id 'openHAB-2.4.0' does not exist. Nothing to uninstall
2018-12-20 18:10:37,721 DEBUG - Completed. Exit code is 0
2018-12-20 18:10:37,971 DEBUG - Starting ServiceWrapper in the CLI mode
2018-12-20 18:10:38,236 INFO  - Installing the service with id 'openHAB-2.4.0'
2018-12-20 18:10:38,268 DEBUG - Completed. Exit code is 0

It doesn't have any detection to find a current instance? I don't know if that's something we want to get into or not. Maybe a rewording on the install location dialog?

It would be nice to have everything for each schedule creation on one dialog but I can understand that being tough. Maybe some sort of wording to make it known that more config will be on the next page?

A bit of clean up for this checkbox. image

Uninstall works pretty well.

bdleedy commented 5 years ago

Does it write a log file itself?

tmrobert8 commented 5 years ago
  1. No - it is not meant to be an updater. This was actually a discussion I wanted to have once you tried it - what to do if an older version exists? My thoughts were to maybe give them a choice whether to uninstall the old version (using the uninstaller or manually blowing away the openhab directory if no uninstaller), overwrite the current version (and try to overwrite in a way compatible with the updater) or to allow them to run the update.ps1. What do you think?
  2. Service name - yes it will blindly try to delete the service (rather than detect one). I'll change the code - again won't delete the old one because of 1 (yet)
  3. Schedules - originally I had it that way but it was a major pain - this flow makes it easier to deal with from a programming standpoint and I don't think people will care that much.
  4. Interesting on the checkbox - looks fine on mine but I'll definitely make it bigger
  5. No log file for the install. There is a special build that will dump to a log file but since its a 'special' build - I didn't go with it. Not sure if it's worth the trouble..
tmrobert8 commented 5 years ago
  1. Another point for discussion - I tried to make it so you can install various versions side by side (the schedules and services all have the version embedded in them - so you could specify different install directories for each version). Not sure if that's worth the effort
bdleedy commented 5 years ago
  1. It makes sense to be an updater. We already know what needs to happen... Create a backup, wipe the directory, lay it all down, restore. At the end, checkbox to display a readme with all of the changes to be noted. If you're going to all of this work for an installer, it makes sense to make it an updater too. It makes openHAB pretty user friendly then. It makes sense for it to be an option though.
  2. Service deletion as an option then?
  3. Understood, maybe just a note or '...' to suggest that there is more to the schedule on the next page.
  4. Yeah, my display font isn't cranked up either.
  5. Doesn't seem needed for prod, just wondering for troubleshooting.
  6. Yeah. I'm not sure if anyone would use it. Maybe to test migrating?
tmrobert8 commented 5 years ago

Just did a bunch of work on this and have a fairly good version with everything I wanted in it. @bdleedy could you give it a quick try and give me any feedback (it's fairly complicated now and I'm sure there are still issues - that's why it's a beta). You can find the download link in the release section of my new repository (including README to describe everything). Look at https://github.com/tmrobert8/openhab-windows-utils

@kaikreuzer I named it openhab-windows-utils for two reasons:

  1. you already have an openhab-windows repository (although it looks dead)
  2. the repository hold the installer AND a windows service (version agnostic) that can be installed/used independent of the installer (although the installer will install the service as well).

If things look ok - I'll invite people from the community to try it

tmrobert8 commented 5 years ago

Just pinging @bdleedy to see if he's had time to look at it? I know alot has been going on but I don't want this dropped..

Gozilla01 commented 5 years ago

I installed 2.5 snapshots through your installation program, it worked the first time ..... Congratulations You should make it productive Question:

tmrobert8 commented 5 years ago

@Gozilla01 Look in the runtime/bin directory - you'll see a bunch of batch files. There is an update.bat (can't remember if you need to run it as admin or not) that will do both of those (and can even downgrade if you want).

Gozilla01 commented 5 years ago

I tried the file is it works. Thank you

tmrobert8 commented 5 years ago

@kaikreuzer Quite a few people have used this now successfully - want to move it over to the openhab repositories?

kaikreuzer commented 5 years ago

Sounds good, @tmrobert8, I think we could move it to become an official openHAB util. Just one question as this isn't fully clear to me yet: Do we need to build a new installer with every openHAB release (incl. milestones)? Or can the installer pick up any most recent openHAB builds? If we need to rebuild the installer, we will have to think about a way to automate this. And I assume, it can only be done on a Windows machine, right? How could we handle that?

tmrobert8 commented 5 years ago

@kaikreuzer

If you look at the top of this discussion, I asked if there was a way to get all the openHAB versions (json file, something) and it appears there is not a way to do it.

Because of that - there is one file that will need to be updated each time and the installer rebuilt (which can only be done on windows and I haven't the slightest idea how to handle that).

An alternative however is that if we make this an official openhab repository. I could modify the installer to pick up the version file from the repository itself - then we'd only have to commit changes to the file and the installer would work just fine - probably would be the best approach

tmrobert8 commented 5 years ago

@kaikreuzer How to we proceed on this?

tmrobert8 commented 4 years ago

@kaikreuzer Did a bit of work on this and it's VERY easy now to have it automatically built using Azure Pipelines (for open source projects - you have unlimited minutes and was very easy to setup. Take a look at:

  1. https://github.com/tmrobert8/openhab-windows-utils/blob/master/azure-pipelines.yml - this is the build file to build the installer using NSIS then to publish the file back to github as a release
  2. If I make any commit, the pipelines run the azure-pipelines.yml, produces the installer and then creates a release for it (you can see the output at https://github.com/tmrobert8/openhab-windows-utils/releases).

Turns out it was unbelievably easy to use (we've started using devops at work and it's a really, really nice build system).

If you want to move forward with something like this we need to:

  1. Create an openhab/windows-utils repository
  2. I PR all the stuff to it
  3. Someone needs to setup a openHAB azure pipeline account and connect the windows utils repository to it (very easy to do - github marketplace and follow the instructions).

At that point - it will be setup to run whenever there is a commit. I probably create two pipelines - a build pipeline to simply ensure the build works and then a release pipeline to actually create the release. Neither would be difficult to do.

If you want me to help out - let me know..

KidSquid1 commented 3 years ago

Sure would be nice to have around...especially if it handles upgrades.

Is this project dead? Last comment from the developer is over a year ago.

Is this something that is going to roll out with V3?

KidSquid1 commented 3 years ago
Daniel100111 commented 3 years ago

As above. I've installed Openhab 3 and requested an update function within the UI. Not sure if this is possible though.

kaikreuzer commented 3 years ago

Is this project dead? Last comment from the developer is over a year ago. Is this something that is going to roll out with V3?

This is probably my fault as I failed to follow up 😢 .

@tmrobert8 My apologies. Would you still be interested to finish this work? I could try to arrange you access to Azure on behalf of the foundation for setting up the build parts of it.

wborn commented 11 months ago

What is the status of this? You can also create a GitHub Actions build using Windows nowadays.