From bef74b6a8020109c299195f80dcba3a6b37bbb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Tue, 11 May 2021 21:22:15 +0200 Subject: [PATCH 1/4] versionKey update Checked opera and vlc labels --- Installomator.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index 545a928..cbe623c 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -114,6 +114,12 @@ REOPEN="yes" # If given, it will be compared to installed version, to see if download is different. # It does not check for newer or not, only different. # +# - versionKey: (optional) +# How we get version number from app. Possible values: +# - CFBundleShortVersionString +# - CFBundleVersion +# Not all software titles uses fields the same. Opera uses the latter. +# # - expectedTeamID: (required) # 10-digit developer team ID. # Obtain the team ID by running: @@ -332,7 +338,7 @@ getAppVersion() { if [[ ${#filteredAppPaths} -eq 1 ]]; then installedAppPath=$filteredAppPaths[1] #appversion=$(mdls -name kMDItemVersion -raw $installedAppPath ) - appversion=$(defaults read $installedAppPath/Contents/Info.plist CFBundleShortVersionString) #Not dependant on Spotlight indexing + appversion=$(defaults read $installedAppPath/Contents/Info.plist $versionKey) #Not dependant on Spotlight indexing printlog "found app at $installedAppPath, version $appversion" else printlog "could not determine location of $appName" @@ -480,7 +486,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir # versioncheck # credit: Søren Theilgaard (@theilgaard) - appNewVersion=$(defaults read $appPath/Contents/Info.plist CFBundleShortVersionString) + appNewVersion=$(defaults read $appPath/Contents/Info.plist $versionKey) if [[ $appversion == $appNewVersion ]]; then printlog "Downloaded version of $name is $appNewVersion, same as installed." if [[ $INSTALL != "force" ]]; then @@ -797,6 +803,10 @@ label=${label:l} printlog "################## Start Installomator v. $VERSION" printlog "################## $label" +# How we get version number from app +# (alternative is "CFBundleVersion", that can be used in labels) +versionKey="CFBundleShortVersionString" + # get current user currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }') @@ -2009,8 +2019,9 @@ openvpnconnectv3) opera) name="Opera" type="dmg" - downloadURL="https://get.geo.opera.com/ftp/pub/opera/desktop/"$( curl -fs "https://get.geo.opera.com/ftp/pub/opera/desktop/" | grep href | tail -1 | tr '"' '\n' | grep "/" | head -1 )"mac/Opera_"$( curl -fs "https://get.geo.opera.com/ftp/pub/opera/desktop/" | grep href | tail -1 | tr '"' '\n' | grep "/" | head -1 | sed -E 's/^([0-9.]*)\//\1/g' )"_Setup.dmg" - appNewVersion="$( curl -fs "https://get.geo.opera.com/ftp/pub/opera/desktop/" | grep href | tail -1 | tr '"' '\n' | grep "/" | head -1 | sed -E 's/^([0-9]*\.[0-9]*).*\//\1/g' )" + downloadURL=$(curl -fsIL "$(curl -fs "$(curl -fsIL "https://download.opera.com/download/get/?partner=www&opsys=MacOS" | grep -i "^location" | cut -d " " -f2 | tail -1 | tr -d '\r')" | grep download.opera.com | grep -io "https.*yes" | sed 's/\&/\&/g')" | grep -i "^location" | cut -d " " -f2 | tr -d '\r') + appNewVersion="$(curl -fs "https://get.geo.opera.com/ftp/pub/opera/desktop/" | grep "href=\"\d" | sort -V | tail -1 | tr '"' '\n' | grep "/" | head -1 | tr -d '/')" + versionKey="CFBundleVersion" expectedTeamID="A2P9LX4JPN" ;; pacifist) @@ -2383,8 +2394,10 @@ taskpaper) teamviewer) name="TeamViewer" type="pkgInDmg" + packageID="com.teamviewer.teamviewer" pkgName="Install TeamViewer.app/Contents/Resources/Install TeamViewer.pkg" downloadURL="https://download.teamviewer.com/download/TeamViewer.dmg" + appNewVersion=$(curl -fs "https://www.teamviewer.com/en/download/mac-os/" | grep "Current version" | cut -d " " -f3 | cut -d "<" -f1) expectedTeamID="H7UGFBUGV6" ;; teamviewerhost) @@ -2392,6 +2405,7 @@ teamviewerhost) type="pkgInDmg" packageID="com.teamviewer.teamviewerhost" pkgName="Install TeamViewerHost.app/Contents/Resources/Install TeamViewerHost.pkg" downloadURL="https://download.teamviewer.com/download/TeamViewerHost.dmg" + appNewVersion=$(curl -fs "https://www.teamviewer.com/en/download/mac-os/" | grep "Current version" | cut -d " " -f3 | cut -d "<" -f1) expectedTeamID="H7UGFBUGV6" #blockingProcessesMaxCPU="5" # Future feature #Company="TeamViewer GmbH" @@ -2401,6 +2415,7 @@ teamviewerqs) name="TeamViewerQS" type="dmg" downloadURL="https://download.teamviewer.com/download/TeamViewerQS.dmg" + appNewVersion=$(curl -fs "https://www.teamviewer.com/en/download/mac-os/" | grep "Current version" | cut -d " " -f3 | cut -d "<" -f1) appName="TeamViewerQS.app" expectedTeamID="H7UGFBUGV6" ;; From 932013b34bfe0d6f2857147bae4bead75da7990e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Tue, 11 May 2021 21:50:39 +0200 Subject: [PATCH 2/4] Update Installomator.sh --- Installomator.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index cbe623c..20790e5 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -2394,10 +2394,8 @@ taskpaper) teamviewer) name="TeamViewer" type="pkgInDmg" - packageID="com.teamviewer.teamviewer" pkgName="Install TeamViewer.app/Contents/Resources/Install TeamViewer.pkg" downloadURL="https://download.teamviewer.com/download/TeamViewer.dmg" - appNewVersion=$(curl -fs "https://www.teamviewer.com/en/download/mac-os/" | grep "Current version" | cut -d " " -f3 | cut -d "<" -f1) expectedTeamID="H7UGFBUGV6" ;; teamviewerhost) @@ -2405,7 +2403,6 @@ teamviewerhost) type="pkgInDmg" packageID="com.teamviewer.teamviewerhost" pkgName="Install TeamViewerHost.app/Contents/Resources/Install TeamViewerHost.pkg" downloadURL="https://download.teamviewer.com/download/TeamViewerHost.dmg" - appNewVersion=$(curl -fs "https://www.teamviewer.com/en/download/mac-os/" | grep "Current version" | cut -d " " -f3 | cut -d "<" -f1) expectedTeamID="H7UGFBUGV6" #blockingProcessesMaxCPU="5" # Future feature #Company="TeamViewer GmbH" @@ -2415,7 +2412,6 @@ teamviewerqs) name="TeamViewerQS" type="dmg" downloadURL="https://download.teamviewer.com/download/TeamViewerQS.dmg" - appNewVersion=$(curl -fs "https://www.teamviewer.com/en/download/mac-os/" | grep "Current version" | cut -d " " -f3 | cut -d "<" -f1) appName="TeamViewerQS.app" expectedTeamID="H7UGFBUGV6" ;; From e64fe9fcda90013f3f2912309e158bbc5670bf40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 12 May 2021 11:17:07 +0200 Subject: [PATCH 3/4] appCustomVersion(){} This can be used in a label now. --- Installomator.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index 20790e5..4aabbc8 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -118,7 +118,13 @@ REOPEN="yes" # How we get version number from app. Possible values: # - CFBundleShortVersionString # - CFBundleVersion -# Not all software titles uses fields the same. Opera uses the latter. +# Not all software titles uses fields the same. +# See Opera label. +# +# - appCustomVersion(){}: (optional function) +# This function can be added to your label, if a specific custom +# mechanism hs to be used for getting the installed version. +# See labels zulujdk11, zulujdk13, zulujdk15 # # - expectedTeamID: (required) # 10-digit developer team ID. @@ -310,7 +316,15 @@ xpath() { getAppVersion() { - # modified by: Søren Theilgaard (@theilgaard) + # modified by: Søren Theilgaard (@theilgaard) and Isaac Ordonez + + # If label contain function appCustomVersion, we use that and return + if type 'appCustomVersion' 2>/dev/null | grep -q 'function'; then + appversion=$(appCustomVersion) + printlog "Custom App Version detection is used, found $appversion" + return + fi + # pkgs contains a version number, then we don't have to search for an app if [[ $packageID != "" ]]; then appversion="$(pkgutil --pkg-info-plist ${packageID} 2>/dev/null | grep -A 1 pkg-version | tail -1 | sed -E 's/.*>([0-9.]*)<.*/\1/g')" @@ -1586,6 +1600,7 @@ installomator_st) packageID="dk.theilgaard.pkg.Installomator" downloadURL=$(downloadURLFromGit theile Installomator ) appNewVersion=$(versionFromGit theile Installomator ) + #appCustomVersion(){/usr/local/bin/Installomator.sh version | tail -1 | awk '{print $4}'} expectedTeamID="L8W73B6AH3" blockingProcesses=( NONE ) ;; @@ -2625,7 +2640,7 @@ wireshark) name="Wireshark" type="dmg" downloadURL="https://1.as.dl.wireshark.org/osx/Wireshark%20Latest%20Intel%2064.dmg" - appNewVersion=$(curl -fs https://www.wireshark.org/download.html | grep "Stable Release" | grep -o "(.*.)" | cut -f2 | head -1 | awk -F'[()]' '{print $2}') + appNewVersion=$(curl -fs https://www.wireshark.org/download.html | grep "Stable Release" | grep -o "(.*.)" | cut -f2 | head -1 | awk -F '[()]' '{print $2}') expectedTeamID="7Z6EMTD2C6" ;; xink) @@ -2690,8 +2705,8 @@ zulujdk11) downloadURL=$(curl -fs "https://www.azul.com/downloads/zulu-community/" | xmllint --html --format - 2>/dev/null | tr , '\n' | grep -o "https:.*/zulu11.*ca-jdk11.*aarch64.dmg" | sed 's/\\//g') fi expectedTeamID="TDTHCUPYFR" - #appCustomVersion(){ java -version 2>&1 | grep Runtime | awk '{print $4}' | sed -e "s/.*Zulu//" | cut -d '-' -f 1 | sed -e "s/+/\./" } - #appNewVersion=$(echo "$downloadURL" | cut -d "-" -f 1 | sed -e "s/.*zulu//") # Cannot be compared to anything + appCustomVersion(){ java -version 2>&1 | grep Runtime | awk '{print $4}' | sed -e "s/.*Zulu//" | cut -d '-' -f 1 | sed -e "s/+/\./" } + appNewVersion=$(echo "$downloadURL" | cut -d "-" -f 1 | sed -e "s/.*zulu//") # Cannot be compared to anything #Company="Azul" #PatchSkip="YES" ;; @@ -2705,8 +2720,8 @@ zulujdk13) downloadURL=$(curl -fs "https://www.azul.com/downloads/zulu-community/" | xmllint --html --format - 2>/dev/null | tr , '\n' | grep -o "https:.*/zulu13.*ca-jdk13.*aarch64.dmg" | sed 's/\\//g') fi expectedTeamID="TDTHCUPYFR" - #appCustomVersion(){ java -version 2>&1 | grep Runtime | awk '{print $4}' | sed -e "s/.*Zulu//" | cut -d '-' -f 1 | sed -e "s/+/\./" } - #appNewVersion=$(echo "$downloadURL" | cut -d "-" -f 1 | sed -e "s/.*zulu//") # Cannot be compared to anything + appCustomVersion(){ java -version 2>&1 | grep Runtime | awk '{print $4}' | sed -e "s/.*Zulu//" | cut -d '-' -f 1 | sed -e "s/+/\./" } + appNewVersion=$(echo "$downloadURL" | cut -d "-" -f 1 | sed -e "s/.*zulu//") # Cannot be compared to anything #Company="Azul" #PatchSkip="YES" ;; @@ -2720,8 +2735,8 @@ zulujdk15) downloadURL=$(curl -fs "https://www.azul.com/downloads/zulu-community/" | xmllint --html --format - 2>/dev/null | tr , '\n' | grep -o "https:.*/zulu15.*ca-jdk15.*aarch64.dmg" | sed 's/\\//g') fi expectedTeamID="TDTHCUPYFR" - #appCustomVersion(){ java -version 2>&1 | grep Runtime | awk '{print $4}' | sed -e "s/.*Zulu//" | cut -d '-' -f 1 | sed -e "s/+/\./" } - #appNewVersion=$(echo "$downloadURL" | cut -d "-" -f 1 | sed -e "s/.*zulu//") # Cannot be compared to anything + appCustomVersion(){ java -version 2>&1 | grep Runtime | awk '{print $4}' | sed -e "s/.*Zulu//" | cut -d '-' -f 1 | sed -e "s/+/\./" } + appNewVersion=$(echo "$downloadURL" | cut -d "-" -f 1 | sed -e "s/.*zulu//") # Cannot be compared to anything #Company="Azul" #PatchSkip="YES" ;; From cad509accd23e8d725b60e843fe373fe041f4832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Mon, 17 May 2021 13:08:48 +0200 Subject: [PATCH 4/4] Force install improvements If using INSTALL=force, the script will not be using updateTool, but will reinstall instead. microsoftteams label was still having appNewVersion that does not work, so that has been commented out. --- Installomator.sh | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index 4aabbc8..0eb87c2 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -3010,7 +3010,7 @@ microsoftteams) type="pkg" #packageID="com.microsoft.teams" downloadURL="https://go.microsoft.com/fwlink/?linkid=869428" - appNewVersion=$(curl -fs https://macadmins.software/latest.xml | xpath '//latest/package[id="com.microsoft.teams.standalone"]/version' 2>/dev/null | sed -E 's/([0-9.]*) .*/\1/') + #appNewVersion=$(curl -fs https://macadmins.software/latest.xml | xpath '//latest/package[id="com.microsoft.teams.standalone"]/version' 2>/dev/null | sed -E 's/([0-9.]*) .*/\1/') # Still using macadmin.software for version, as the path does not contain the version in a matching format. packageID can be used, but version is the same. expectedTeamID="UBF8T346G9" blockingProcesses=( Teams "Microsoft Teams Helper" ) @@ -3202,23 +3202,9 @@ if ! cd "$tmpDir"; then cleanupAndExit 1 fi -# MARK: check if this is an Update and we can use updateTool +# MARK: get installed version getAppVersion printlog "appversion: $appversion" -if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then - printlog "appversion & updateTool" - if [[ $DEBUG -eq 0 ]]; then - if runUpdateTool; then - finishing - cleanupAndExit 0 - elif [[ $type == "updateronly" ]];then - printlog "type is $type so we end here." - cleanupAndExit 0 - fi # otherwise continue - else - printlog "DEBUG mode enabled, not running update tool" - fi -fi # MARK: Exit if new version is the same as installed version (appNewVersion specified) # credit: Søren Theilgaard (@theilgaard) @@ -3235,7 +3221,8 @@ if [[ -n $appNewVersion ]]; then fi cleanupAndExit 0 "No newer version." else - printlog "Using force to install anyway." + printlog "Using force to install anyway. Not using updateTool." + updateTool="" fi else printlog "DEBUG mode enabled, not exiting, but there is no new version of app." @@ -3243,6 +3230,26 @@ if [[ -n $appNewVersion ]]; then fi else printlog "Latest version not specified." + if [[ $INSTALL == "force" ]]; then + printlog "Using force to install, so not using updateTool." + updateTool="" + fi +fi + +# MARK: check if this is an Update and we can use updateTool +if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then + printlog "appversion & updateTool" + if [[ $DEBUG -eq 0 ]]; then + if runUpdateTool; then + finishing + cleanupAndExit 0 + elif [[ $type == "updateronly" ]];then + printlog "type is $type so we end here." + cleanupAndExit 0 + fi # otherwise continue + else + printlog "DEBUG mode enabled, not running update tool" + fi fi # MARK: download the archive