This an init script that I use to test core modifications on the openhab docker image.
This way I just need to move the jars into my userdata/runtime_swap (and remove userdata/tmp and userdata/cache folders) and restart the image.
In case it’s useful for any one else.
#!/bin/bash
RUNTIME_CUSTOM_JARS=/openhab/userdata/runtime_swap/*.jar
for file in $RUNTIME_CUSTOM_JARS; do
if [ "$RUNTIME_CUSTOM_JARS" = "$file" ]; then
echo "no runtime to replace"
exit 0
fi
filename="${file##*/}"
name="${filename%%.jar}"
packagename="${name%%-*}"
runtime_jar=$(find /openhab/runtime/ -path "*/$packagename/*.jar")
if [ -n "$runtime_jar" ]
then
echo "replacing $runtime_jar by $file"
cp "$file" "$runtime_jar"
else
echo "no runtime jar found for file $file"
fi
done
Per say, you do not need to make clean start after update, in some cases it is sufficient just to update specific core module through update xyz file:abc.jar where xyz is core bundle id and abc.jar is updated version. More importantly, if you do a restart updated bundle should take part in boot process.
Most reliable (also slowest) way is doing a clean start. If you run docker you can do docker cp my.jar openhab-container-id:/path which will allow you doing it without scripts inside docker.
The motivation for me to do it like this is to have an easy way to do this with multiple bundles on a remote server just through FileZilla and Portainer.