Whats your way to update OH2 with another nightly build?

Hi!
You can adjust the default sitemap in the services folder: https://github.com/cyberkov/my-openhab-config/blob/master/services/basicui.cfg
This setting is always picked up, even when the db gets lost.

I hope this helps :slight_smile:
Cheers Hannes

1 Like

Thank you, I will check this out before my next update.
Cheers,
Mike

I have just a about got my process to update a Windows OH2 system finished, thanks to everyone that has responded to my questions.

I have written a batch file that takes a backup copy and then prepares the openHAB directory structure for updating. Here it is in case it is of any help to anyone else.

@echo Please confirm that you have shut down openHAB. @echo =============================================== @echo This routine will backup openHAB and then prepare for updating to the latest snapshot. @echo ====================================================================================== pause cd\oh_backup del *.* /s /q cd\ xcopy c:\openhab\*.* c:\oh_backup /v /q /s /e /h rd c:\openhab\runtime /s /q del /s /f /q c:\openhab\userdata\cache\*.* for /f %%f in ('dir /ad /b c:\openhab\userdata\cache\') do rd /s /q c:\openhab\userdata\cache\%%f del /s /f /q c:\openhab\userdata\tmp\*.* for /f %%f in ('dir /ad /b c:\openhab\userdata\tmp\') do rd /s /q c:\openhab\userdata\tmp\%%f @echo Task completed pause

My last bit to solve is when extracting the new snapshot as it is easy to miss that addons.cfg and runtime.cfg are overwritten. I can take care of that by restoring these 2 files from my backup copy immediately after extracting the new snapshot.

My question is should I also do this for the keystore (wherever that is located) for when it might be used in future?

Cheers,
Mike.

This repo is no longer available. :frowning:

Yes, that’s right. I don’t use OH2 yet, so I don’t have a OH2-version for nightly update. My last working version for openHAB 1:

#!/bin/bash

# This version includes getting HABmin and
# functionality to get the latest Snapshot without knowing it's number, version or status (Snapshot or not)
# it also includes support for grafana

. /lib/lsb/init-functions

# by default getsnap gets information from /etc/default/getsnap
getsnapconf=/etc/default/getsnap.cfg
# ohpath is the real path of openHAB-files
ohpath=/opt/inst/
# buildpath is the web-adress of build-server
# buildpath=https://openhab.ci.cloudbees.com/job/openHAB/
# buildpath=https://openhab-ci.innoq.io/jenkins/view/openHAB/job/openhab-1/
buildpath=https://openhab-ci.innoq.io/jenkins/view/openHAB/job/
buildname=openhab-1-rc
if  [ "$#" -eq 0 ]
 then
  log_daemon_msg "Get lastStableBuild-Number of ${buildname}"
  number=`wget --quiet -O  - ${buildpath}${buildname}/lastStableBuild | sed -n 's/^\(.*\)\(<title>openhab-1-rc .\)\([0-9]\{2,4\}\)\(.*\)$/\3/p'`
  log_end_msg $?
  echo lastBuild-Number is ${number}
  webpath=${buildpath}${buildname}/lastStableBuild/artifact/distribution/target/
  echo ${webpath}
 else
  if  [ "$#" -ne 1 ]
   then
    echo "get Snapshot of openhab"
    echo ""
    echo "Usage: $(basename $0) [Snapshotnumber]"
    exit 1
  fi
  number=${1}
  webpath=${buildpath}${buildname}/${number}/artifact/distribution/target/
fi

log_daemon_msg "Get openHAB-Version-Number of ${buildname} ${number}"
wget  --quiet -O /tmp/getsnap.data ${buildpath}${buildname}/${number}/
version=`sed -n 's/^\(.*\)\(artifact\/distribution\/target\/distribution-\)\([0-9]\.[0-9]\.[0-9]\)\(.*\)$/\3/p' /tmp/getsnap.data`
snapshot=`sed -n 's/^\(.*\)\(artifact\/distribution\/target\/distribution-\)\([0-9]\.[0-9]\.[0-9]\)\(.*\)\(-runtime.zip.*\)$/\4/p' /tmp/getsnap.data`
# version=`wget --quiet -O - ${buildpath}${number}/ | sed -n 's/^\(.*\)\(artifact\/distribution\/target\/distribution-\)\([0-9]\.[0-9]\.[0-9]\)\(.*\)$/\3/p'`
# snapshot=`wget --quiet -O - ${buildpath}${number}/ | sed -n 's/^\(.*\)\(artifact\/distribution\/target\/distribution-\)\([0-9]\.[0-9]\.[0-9]\)\(.*\)\(-runtime.zip.*\)$/\4/p'`
log_end_msg $?
if [ -z "$version" ]
 then
  echo "fatal error!"
  echo "${number} not found on server!"
  exit 1
fi
echo Nightly-Version is ${version}
if [ -n "$snapshot" ]
 then
  echo and is a ${snapshot}
fi
dist=-${version}${snapshot}

# create path
mkdir ${ohpath}1.8.0-${number}
mkdir ${ohpath}1.8.0-${number}/zips
cd ${ohpath}1.8.0-${number}/zips

echo "Created Directory ${ohpath}${version}-${number}"
echo "let's download openHAB${dist}-${number}"

# get snapshot
  log_daemon_msg "getting runtime"
   wget --quiet ${webpath}distribution${dist}-runtime.zip
  log_end_msg $?
  log_daemon_msg "unzipping runtime"
   unzip -q distribution${dist}-runtime.zip -d ../runtime
  log_end_msg $?
  log_daemon_msg "getting addons"
   wget --quiet ${webpath}distribution${dist}-addons.zip
  log_end_msg $?
  log_daemon_msg "unzipping addons to addons_inactive"
   unzip -q distribution${dist}-addons.zip -d ../runtime/addons_inactive
  log_end_msg $?

while read line
 do
case ${line:0:1} in
 \#)
;;
 *)
  case ${line:0:-1} in
 macos_designer)
  log_daemon_msg "getting MacOSX-Designer"
   wget --quiet ${webpath}distribution${dist}-designer-macosx64.zip
  log_end_msg $?
  log_daemon_msg "unzipping MacOSX-Designer"
   unzip -q distribution${dist}-designer-macosx64.zip -d ../ide
  log_end_msg $?
;;
 linux32_designer)
  log_daemon_msg "getting Linux32bit-Designer"
   wget --quiet ${webpath}distribution${dist}-designer-linux.zip
  log_end_msg $?
  log_daemon_msg "unzipping Linux32bit-Designer"
   unzip -q distribution${dist}-designer-linux.zip -d ../ide
  log_end_msg $?
;;
 linux64_designer)
  log_daemon_msg "getting Linux64bit-Designer"
   wget --quiet ${webpath}distribution${dist}-designer-linux64bit.zip
  log_end_msg $?
  log_daemon_msg "unzipping Linux64bit-Designer"
   unzip -q distribution${dist}-designer-linux64bit.zip -d ../ide
  log_end_msg $?
;;
 windows_designer)
  log_daemon_msg "getting Windows-Designer"
   wget --quiet ${webpath}distribution${dist}-designer-win.zip
  log_end_msg $?
#  log_daemon_msg "unzipping Windows-Designer"
#   unzip -q distribution${dist}-designer-win.zip -d ../ide
#  log_end_msg $?
;;
 demo)
  log_daemon_msg "getting demo"
   wget --quiet ${webpath}distribution${dist}-demo.zip
  log_end_msg $?
  log_daemon_msg "unzipping demo"
  unzip -q distribution${dist}-demo.zip -d ../runtime/demo
  log_end_msg $?
;;
 greent)
  log_daemon_msg "getting greent"
   wget --quiet ${webpath}distribution${dist}-greent.zip
  log_end_msg $?
  log_daemon_msg "unzipping greent"
  unzip -q distribution${dist}-greent.zip -d ../runtime/webapps
  log_end_msg $?
;;
 habmin)
  log_daemon_msg "getting HABmin"
   wget -nv https://github.com/cdjackson/HABmin/archive/master.zip
  log_end_msg $?
  log_daemon_msg "unzipping HABmin"
   unzip -q master.zip -d ../runtime/webapps
   mv ../runtime/webapps/HABmin-master ../runtime/webapps/habmin
   mv ../runtime/webapps/habmin/addons/org.openhab.*.jar ../runtime/addons/
   if [ -e ../runtime/addons_inactive/org.openhab.binding.zwave${dist}.jar ]
     then
       mv ../runtime/addons_inactive/org.openhab.binding.zwave${dist}.jar ../runtime/addons/
   fi
  log_end_msg $?
;;
*)
  log_daemon_msg "activated ${line}"
  mv ../runtime/addons_inactive/org.openhab.${line:0:-1}${dist}.jar ../runtime/addons/
  log_end_msg $?
;;
esac
;;
esac
done < ${getsnapconf}

cd ../runtime
touch ./${number}

echo "create links..."
# link configs, images and databases
mv ./configurations ./configurations_old
mv ./etc ./etc_old
mv ./webapps/images ./webapps/images_old

ln -s ${ohpath}configurations/ ./configurations
ln -s ${ohpath}etc/ ./etc
ln -s ${ohpath}webapps/images/ ./webapps/images
if [ -e ${ohpath}webapps/grafana ]
  then
    ln -s ${ohpath}webapps/grafana/ ./webapps/grafana
fi
if [ -e ${ohpath}webapps/weather-data ]
  then
    ln -s ${ohpath}webapps/weather-data/ ./webapps/weather-data
fi
if [ -e ${ohpath}webapps/static/uuid ]
  then
    cp ${ohpath}webapps/static/uuid ./webapps/static/
fi
if [ -e ${ohpath}webapps/static/secret ]
  then
    cp ${ohpath}webapps/static/secret ./webapps/static/
fi

chmod 755 ./start*.sh

echo "copy default.cfg and logback.xml"
cp configurations_old/openhab_default.cfg ./configurations
mv configurations/logback.xml ./configurations/logback.xml.old
mv configurations/logback_debug.xml ./configurations/logback_debug.xml.old
cp configurations_old/logback.xml ./configurations
cp configurations_old/logback_debug.xml ./configurations

mv /oh/openhab /oh/openhab_old-${number}
ln -s ${ohpath}${version}-${number}/runtime /oh/openhab

echo "ready to switch to openHAB${dist}-${number}"

exit 0

and the config (/etc/default/getsnap.cfg)

###########################################################
# at least runtime and addons will be downloaded;         #
# if more then one designer is downloaded,                #
# the versions will overwrite files in path /ohpath/ide/  #
# getsnap will get the files in order                     #
###########################################################
# linux32_designer
# linux64_designer
# macos_designer
windows_designer
demo
greent
###########################################################
#                                                         #
# starting addons from here;                              #
# Lines with # will be ignored                            #
# no spaces at start of line!                             #
# no spaces at end of line!                               #
#                                                         #
###########################################################
action.squeezebox
binding.astro
binding.exec
binding.http
binding.knx
#binding.mpd
binding.networkhealth
binding.ntp
binding.squeezebox
binding.tcp
binding.vdr
binding.wol
binding.yamahareceiver
binding.weather
io.squeezeserver
#persistence.db4o
#persistence.gcal
persistence.logging
persistence.rrd4j
persistence.mysql*
persistence.influxdb
persistence.influxdb08
#action.xmpp
###########################################################
#                                                         #
# getting habmin at the end; this will reduce errors      #
# caused by double-trying to move zwave-binding if in     #
# list above                                              #
#                                                         #
###########################################################
#
habmin

@chris and @xsnrg

I tried below steps to update OH2, but sometimes face problem.
1 Habmin stay still the old version.
2 within Habmin, can not see items which are defined in demo2.sitemap.

$mkdir hab down
$cd hab

$rm -rf /tmp/
$rm -rf /cache/
$cp /conf ./ -dpR
$cp /userdata ./ -dpR

$cd …
$./makeHAB (this is your script without the designer part located at
https://github.com/xsnrg/OpenHAB2-tools)
$cd hab
$vi conf/services/addons.cfg
$./start.sh

Basically,
1 I copy userdata/ conf/ directory under old OH2 to hab/.
2 run makeHAB which is your script
3 edit addons.cfg

Please correct me if I do something wrong and please give some suggestion if possible.
Thank you very much.

Re: HABmin version

I haven’t done this yet, but I suspect that you will need to delete the existing habmin jar file from the addons directory. You may need to do this before you update to the latest build, but not sure.

Then restart openHAB and install HABmin from the Paper UI.

I did it this morning, and you are correct. Delete from addons directory, and install using PaperUI, or add to your conf/services/addons.cfg file before you restart OH.

Thank you for your idea.

1 I got if deleting habmin under addons/ and restart.

1 Should I do this?
# A comma-separated list of UIs to install (e.g. “basic,paper”)
ui = basic, paper, habmin

2 However, I manually copy here

3 I can not find habmin in my paper UI.

Thank you.

Yes. This is what I have in my addons.cfg

When you ran makeHAB, are you sure it deleted the userdata/tmp and userdata/cache directories in the main openhab directory?

Thank you very much.

Yes.
But never mind, it seems work by manual copying. Thank you, though.

I think you are saying install by PaperUI or add to your conf/services/addons.cfg file instead of both of them.

However, one thing is not reasonable to me is that another binding called orvibo, which I also add into conf/services/addons.cfg, is installed automatically without touching PaperUI.
However, same thing does not happen on Hambin.

Thank you.

I am not sure how far along you are at this point, but wanted to let you know a few things that may help.

First, you should not copy the Habmin jar into addons any more. In the last evening or so, Habmin has become available to install either from addons.cfg or through PaperUI. I recommend through addons.cfg as it just becomes automatic at that point. If you put it in addons.cfg, then should see it in PaperUI as well, as “installed”. Note that depending on your internet speed, it may take some time for it to install, so give it some time.

Second, the script is made to be configurable. If you liked where you had stuff installed, you could have left it there. I default to /opt as the base, which seems sane for most systems, but it should work where ever you want it to go. Just change the HAB variable at the top.

Finally, using the script does work well, but one thing to know about it is when you start the online distribution, it has to download a lot of stuff. This means that all the dependencies are not there right away and need to get loaded over time. This does lead to some exceptions and timeouts in the logs. After everything is downloaded, I do recommend restarting OpenHAB again, and the log should be much cleaner.

Hope this helps

1 Like

I find it that it is good to keep:

./runtime/karaf/bin/oh2_dir_layout

If you are not following the standard (Like I have the logs in /var/log/openhab2 etc.

Regards, S

1 Like

@Seaside, thank you so much for this hint. Just switched from the apt-get version to the snapshot zip-file as suggested by @Kai because some of my files seemed to be old (e.g. PaperUI) although I was using the apt-get procedure as described on the docs-portal. By uploading the directory structure via FTP from my PC obviously the dir_layout file got overwritten - and I wasn’t able to start my service anymore and the error message showing up was not “end-user-like” ;-). Because of your hint, I found out where to change the entries - and now it’s running again. THANK YOU!

@Boby
Glad it helped.
I’m using a different approach now when updating to latest snapshot.
I should probably update my apt-repo so I can use snapshots from there.

What I do is the following:

wget "https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-offline/target/openhab2-offline-2.0.0-SNAPSHOT.deb"
 dpkg -i openhab2-offline-2.0.0-SNAPSHOT.deb
rm -rf /var/lib/openhab2/cache/*
rm -rf /var/lib/openhab2/tmp/*

Doing this the oh2_dir_layout will be untouched.

Regards, S

@Seaside, thank you once more.
Are these four commands sufficient? Or do I need to consider some other commands/changes as well? If so, I’d use this way instead since it’s easier (less steps).

One thing is still unsolved : After I had the snapshot running again, all bindings, persistences and transformations were “uninstalled” - and I had to install them via PaperUI again. Is this common?

Thank you!

A lot changed since this thread was started.
On a debian/ubuntu based Linux system the repository based snapshot installation is a stable and tested process and should be the recommended method. No need to do manual installations and upgrades and follow certain steps which may change over time. Everything is taken care of by the deb installation steps.

@Seaside: Deletion of the cache and tmp folder is part of the latest deb improvement: https://github.com/openhab/openhab-distro/pull/286

@Boby to still address your question: these four commands should be enough. Maybe you would do good to manually stop openhab2 beforehand and only start it after the deletions. The problem with uninstalled addons should not normally be the case. You can work around that by installing your addons through services/addons.cfg.

I’m going to close this thread. Please contact me if you do not agree! I’m not infallible :wink:


The installation and upgrade process is documented at docs.openhab.org. The article will be updated as soon as changes are needed, e.g. when openHAB 2 reaches it’s final release.

http://docs.openhab.org/installation/linux.html#package-repository-installation