How to update OH2 on Synology and save all settings?
Hi,
If that can help you, here is the script that Iām using to upgrade my OH2 on synology DSM6 to the latest snapshot.
This script is saved in my public/OpenHAB2 folder (where addons & conf directories are)
The steps are quite simple:
-
Stop Openhab2 package
-
Run the sh script as root user
-
Start Openhab2 package
PUBLIC_CONF="/volume1/public/OpenHAB2/conf"
PUBLIC_ADDONS="/volume1/public/OpenHAB2/addons"
SYNOPKG_PKGDEST="/volume1/@appstore/OpenHAB2"
# backup current installation with settings
TIMESTAMP=`date +%Y%m%d_%H%M%S`;
sudo mv ${SYNOPKG_PKGDEST} /${SYNOPKG_PKGDEST}-backup-$TIMESTAMP
# download new version (please replace URL)
cd /tmp
wget https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-online/target/openhab-online-2.0.0-SNAPSHOT.zip
sudo 7z x openhab-online-2.0.0-SNAPSHOT.zip -o${SYNOPKG_PKGDEST}
rm openhab-online-2.0.0-SNAPSHOT.zip
# restore configuration and userdata
#sudo cp -arv /volume1/@appstore/OpenHAB2-backup-$TIMESTAMP/conf /volume1/@appstore/OpenHAB2/
sudo cp -arv ${SYNOPKG_PKGDEST}-backup-$TIMESTAMP/userdata ${SYNOPKG_PKGDEST}/
#if configdir exists in public folder -> create a symbolic link
if [ -d ${PUBLIC_CONF} ]; then
rm -r ${SYNOPKG_PKGDEST}/conf
ln -s ${PUBLIC_CONF} ${SYNOPKG_PKGDEST}
fi
#if public addons dir exists in public folder -> create a symbolic link
if [ -d ${PUBLIC_ADDONS} ]; then
rm -r ${SYNOPKG_PKGDEST}/addons
ln -s ${PUBLIC_ADDONS} ${SYNOPKG_PKGDEST}
fi
# fix permissions
sudo chown -hR openhab2:users ${SYNOPKG_PKGDEST}
BUT be aware that since a few days, the OH2 folder structure has changed a bit and Iāve NOT validated this script with the new folders structure. So letās say that the script is fine with OH2B4 and previous
Thank you for your script.
Im not experienced script user, can you tell is it will work with latest oh2 snapshot?
Is it possible to add this script to synology package center start-stop-remove menu as new menu item āupdateā?
Hi,
Iām using this script when I want to upgrade to the latest snapshot (this is the refered URL in the command WGET)
This command tell which package to download. In this case, the latest successfull build of the OH2 online distro. But you can change this URL if you prefer the offline distro or what ever version of OH2.
Iāve recently and sucessfully used it with the new ādisruptiveā updates of OH2 like:
- replacement-of-mapdb-by-jsondb
- Information about installed add-ons is lost when userdata/cache is deleted
- new-folder-structure
To be complete, Iāll update the script to clear tmp and cache.
Regarding your question to integrate this upgrade script in the syno package, it would really be a good point. However, @cniweb is managing the syno package and as far as I know, the syno package is not yet u-pt-odate with OH2 B4 version or latest version. I guess @cniweb is working on it but donāt hesitate to introduce your request on https://github.com/openhab/openhab-syno-spk
HI,
if that could help, here is an updated version of the script Iām running :
PUBLIC_CONF="/volume1/public/OpenHAB2/conf"
PUBLIC_ADDONS="/volume1/public/OpenHAB2/addons"
SYNOPKG_PKGDEST="/volume1/@appstore/OpenHAB2"
# Remove tmp, logs & cache dirs
if [ -d ${SYNOPKG_PKGDEST}/userdata/tmp ]; then
rm -r -f ${SYNOPKG_PKGDEST}/userdata/tmp
fi
if [ -d ${SYNOPKG_PKGDEST}/userdata/cache ]; then
rm -r -f ${SYNOPKG_PKGDEST}/userdata/cache
fi
if [ -d ${SYNOPKG_PKGDEST}/userdata/log ]; then
rm -r -f ${SYNOPKG_PKGDEST}/userdata/log
fi
if [ -d ${SYNOPKG_PKGDEST}/userdata/logs ]; then
rm -r -f ${SYNOPKG_PKGDEST}/userdata/logs
fi
# backup current installation with settings
TIMESTAMP=`date +%Y%m%d_%H%M%S`;
sudo mv ${SYNOPKG_PKGDEST} /${SYNOPKG_PKGDEST}-backup-$TIMESTAMP
# download new version (please replace URL)
cd /tmp
wget https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-online/target/openhab-online-2.0.0-SNAPSHOT.zip
sudo 7z x openhab-online-2.0.0-SNAPSHOT.zip -o${SYNOPKG_PKGDEST}
rm openhab-online-2.0.0-SNAPSHOT.zip
# restore configuration and userdata
sudo cp -arv ${SYNOPKG_PKGDEST}-backup-$TIMESTAMP/userdata ${SYNOPKG_PKGDEST}/
#if configdir exists in public folder -> create a symbolic link
if [ -d ${PUBLIC_CONF} ]; then
rm -r ${SYNOPKG_PKGDEST}/conf
ln -s ${PUBLIC_CONF} ${SYNOPKG_PKGDEST}
fi
#if public addons dir exists in public folder -> create a symbolic link
if [ -d ${PUBLIC_ADDONS} ]; then
rm -r ${SYNOPKG_PKGDEST}/addons
ln -s ${PUBLIC_ADDONS} ${SYNOPKG_PKGDEST}
fi
# fix permissions
sudo chown -hR openhab2:users ${SYNOPKG_PKGDEST}
outdated, can this be updated somehow as the included script does not work for Syno installs , in DMS6 there is no unzip anymore only 7zip
Yann @yphyph01
Do you have an updated version?