Creative Force - Kelvin/Hue Auto Updates

Tony1
New Contributor

For any who wants to keep Kelvin/Hue apps update to date, Creative force didn't seem to have a way of updating that the app without admin rights and the app updates a few times a month. So instead of always going updating the latest package into Jamf, here is a script to download/update the latest version. Can have it run once a week to check the versions or run when needed. For the "Hue" app just replace and "Kelvins" with it.

 

#!/bin/bash

# Download latest yaml file for latest version number

curl -o /tmp/kelvinversion.yml https://download.creativeforce.io/released-files.3x/prod/hue/mac/latest-mac.yml

# Now check yaml file version
# Path to yaml file

yaml_file="/tmp/kelvinversion.yml"

# Get yaml version

version_yaml=$(awk '/^version:/ {print $2}' "$yaml_file")

# If the output of the command is empty, then the version key is not present in the YAML file

if [ -z "$version_yaml" ]; then
echo "Version information not found in the YAML file"
else
# If the output of the command is not empty, print the version number

echo "The version is $version_yaml"
fi

# Set the path to the application

app_path="/Applications/Kelvin.app"

# Run the command to get the version information using the defaults command

version_app=$(defaults read "$app_path/Contents/Info.plist" CFBundleShortVersionString)

# If the output of the command is empty, then the application is not installed or the path is incorrect

if [ -z "$version_app" ]; then
echo "Application is not installed or the path is incorrect"
else
# If the output of the command is not empty, print the version number

echo "The version of Kelvin is $version_app"
fi

# Compare the version numbers

if [[ "$version_yaml" == "$version_app" ]]; then
echo "The newest version is installed"
exit 0
else
echo "The newest version is not installed"
fi

# If the versions do not match continue to install app

echo "Installing newest version"

# Get newest download url
# Set the URL and the new version number

url="https://download.creativeforce.io/released-files.3x/prod/kelvin/mac/Kelvin-4.14.1-mac.pkg?time=5"
new_version="$version_yaml"

# Extract the old version number from the URL

old_version=$(echo "$url" | sed -E 's/.*Kelvin-([0-9]+\.[0-9]+\.[0-9]+)-mac.pkg.*/\1/g')

# Replace the old version number with the new version number in the URL

new_url=$(echo "$url" | sed -E "s/Kelvin-$old_version-mac.pkg/Kelvin-$new_version-mac.pkg/g")

# Print the old and new URLs for verification
echo "Old URL: $url"
echo "New URL: $new_url"

# Download Kelvin Package

curl "$new_url" -o /tmp/installer.pkg

# Install Package

installer -pkg /tmp/installer.pkg -target /

exit 0

2 REPLIES 2

Tony1
New Contributor

Typo in the url for the yaml file - https://download.creativeforce.io/released-files.3x/prod/kelvin/mac/latest-mac.yml is the correct one

schoeM
New Contributor II

Hey Tony,

I'm using your script to update Kelvin, and it works like a charm, thank you so much. This program is a otherwise a pain to keep updated.

Unfortunately Creative Force messed with the version numbers for Hue, including the stain "-legacy" (as in 4.14.0-legacy) into the YAML-file. This string shouldn't be in the download URL, and I fear I couldn't get awk to not include those characters. Is there anything you could do to help here?

Best
Morgan