Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022-10-11 Node-RED version-check script - experimental branch - PR 3… #614

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions scripts/nodered_version_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# the name of this script is
SCRIPT=$(basename "$0")

# default image is
DEFAULTIMAGE="iotstack-nodered:latest"

# zero or one arguments supported
if [ "$#" -gt 1 ]; then
echo "Usage: $SCRIPT {image:tag}"
echo " eg: $SCRIPT $DEFAULTIMAGE"
exit -1
fi

# image can be passed as first argument, else default
IMAGE=${1:-"$DEFAULTIMAGE"}

# fetch latest version details from GitHub
LATEST=$(wget -O - -q https://raw.githubusercontent.com/node-red/node-red-docker/master/package.json | jq -r .version)

# figure out the version in the local image
INSTALLED=$(docker image inspect "$IMAGE" | jq -r .[0].Config.Labels[\"org.label-schema.version\"])

# compare versions and report result
if [ "$INSTALLED" = "$LATEST" ] ; then

echo "Node-Red is up-to-date (version $INSTALLED)"

else

/bin/cat <<-COLLECT_TEXT
====================================================================
Node-Red version number has changed on GitHub:
Local Version: $INSTALLED
GitHub Version: $LATEST
This means a new version MIGHT be available on Dockerhub. Check here:
https://hub.docker.com/r/nodered/node-red/tags?page=1&ordering=last_updated
When an updated version is actually avaliable, proceed like this:
$ REBUILD nodered
$ UP nodered
$ docker system prune
====================================================================
COLLECT_TEXT

fi