new dialogURL and expectedDialogTeamID variables

Updated variables to better avoid conflict with variables used in your scripts
This commit is contained in:
Adam Codega
2022-03-03 13:35:53 -05:00
committed by GitHub
parent 0d2fef6a42
commit f5c1d69efc

View File

@@ -2,9 +2,9 @@
function dialogCheck(){ function dialogCheck(){
# Get the URL of the latest PKG From the Dialog GitHub repo # Get the URL of the latest PKG From the Dialog GitHub repo
url=$(curl --silent --fail "https://api.github.com/repos/bartreardon/Dialog/releases/latest" | awk -F '"' "/browser_download_url/ && /pkg\"/ { print \$4; exit }") dialogURL=$(curl --silent --fail "https://api.github.com/repos/bartreardon/Dialog/releases/latest" | awk -F '"' "/browser_download_url/ && /pkg\"/ { print \$4; exit }")
# Expected Team ID of the downloaded PKG # Expected Team ID of the downloaded PKG
expectedTeamID="PWA5E9TQ59" expectedDialogTeamID="PWA5E9TQ59"
# Check for Dialog and install if not found # Check for Dialog and install if not found
if [ ! -e "/Library/Application Support/Dialog/Dialog.app" ]; then if [ ! -e "/Library/Application Support/Dialog/Dialog.app" ]; then
@@ -13,11 +13,11 @@ function dialogCheck(){
workDirectory=$( /usr/bin/basename "$0" ) workDirectory=$( /usr/bin/basename "$0" )
tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" ) tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" )
# Download the installer package # Download the installer package
/usr/bin/curl --location --silent "$url" -o "$tempDirectory/Dialog.pkg" /usr/bin/curl --location --silent "$dialogURL" -o "$tempDirectory/Dialog.pkg"
# Verify the download # Verify the download
teamID=$(/usr/sbin/spctl -a -vv -t install "$tempDirectory/Dialog.pkg" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()') teamID=$(/usr/sbin/spctl -a -vv -t install "$tempDirectory/Dialog.pkg" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()')
# Install the package if Team ID validates # Install the package if Team ID validates
if [ "$expectedTeamID" = "$teamID" ] || [ "$expectedTeamID" = "" ]; then if [ "$expectedDialogTeamID" = "$teamID" ] || [ "$expectedDialogTeamID" = "" ]; then
/usr/sbin/installer -pkg "$tempDirectory/Dialog.pkg" -target / /usr/sbin/installer -pkg "$tempDirectory/Dialog.pkg" -target /
else else
# displayAppleScript # uncomment this if you're using my displayAppleScript function # displayAppleScript # uncomment this if you're using my displayAppleScript function