mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
Merge branch 'main' into pr/664
This commit is contained in:
230
Installomator.sh
230
Installomator.sh
@@ -34,7 +34,6 @@ NOTIFY=success
|
|||||||
# - silent no notifications
|
# - silent no notifications
|
||||||
# - all all notifications (great for Self Service installation)
|
# - all all notifications (great for Self Service installation)
|
||||||
|
|
||||||
|
|
||||||
# behavior when blocking processes are found
|
# behavior when blocking processes are found
|
||||||
BLOCKING_PROCESS_ACTION=tell_user
|
BLOCKING_PROCESS_ACTION=tell_user
|
||||||
# options:
|
# options:
|
||||||
@@ -139,6 +138,26 @@ IGNORE_DND_APPS=""
|
|||||||
# IGNORE_DND_APPS="firefox,Google Chrome,Safari,Microsoft Edge,Opera,Amphetamine,caffeinate"
|
# IGNORE_DND_APPS="firefox,Google Chrome,Safari,Microsoft Edge,Opera,Amphetamine,caffeinate"
|
||||||
|
|
||||||
|
|
||||||
|
# Swift Dialog integration
|
||||||
|
|
||||||
|
# These variables will allow Installomator to communicate progress with Swift Dialog
|
||||||
|
# https://github.com/bartreardon/swiftDialog
|
||||||
|
|
||||||
|
# This requires Swift Dialog 2.11.2 or higher.
|
||||||
|
|
||||||
|
DIALOG_CMD_FILE=""
|
||||||
|
# When this variable is set, Installomator will write Swift Dialog commands to this path.
|
||||||
|
# Installomator will not launch Swift Dialog. The process calling Installomator will have
|
||||||
|
# launch and configure Swift Dialog to listen to this file.
|
||||||
|
# See `MDM/swiftdialog_example.sh` for an example.
|
||||||
|
|
||||||
|
DIALOG_LIST_ITEM_NAME=""
|
||||||
|
# When this variable is set, progress for downloads and installs will be sent to this
|
||||||
|
# listitem.
|
||||||
|
# When the variable is unset, progress will be sent to Swift Dialog's main progress bar.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# NOTE: How labels work
|
# NOTE: How labels work
|
||||||
|
|
||||||
# Each workflow label needs to be listed in the case statement below.
|
# Each workflow label needs to be listed in the case statement below.
|
||||||
@@ -302,8 +321,8 @@ if [[ $(/usr/bin/arch) == "arm64" ]]; then
|
|||||||
rosetta2=no
|
rosetta2=no
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
VERSION="10.0beta1"
|
VERSION="10.0beta2"
|
||||||
VERSIONDATE="2022-08-12"
|
VERSIONDATE="2022-08-31"
|
||||||
|
|
||||||
# MARK: Functions
|
# MARK: Functions
|
||||||
|
|
||||||
@@ -321,12 +340,15 @@ cleanupAndExit() { # $1 = exit code, $2 message, $3 level
|
|||||||
printlog "Debugging enabled, Deleting tmpDir output was:\n$deleteTmpOut" DEBUG
|
printlog "Debugging enabled, Deleting tmpDir output was:\n$deleteTmpOut" DEBUG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# If we closed any processes, reopen the app again
|
# If we closed any processes, reopen the app again
|
||||||
reopenClosedProcess
|
reopenClosedProcess
|
||||||
if [[ -n $2 && $1 -ne 0 ]]; then
|
if [[ -n $2 && $1 -ne 0 ]]; then
|
||||||
printlog "ERROR: $2" $3
|
printlog "ERROR: $2" $3
|
||||||
|
updateDialog "fail" "Error ($1; $2)"
|
||||||
else
|
else
|
||||||
printlog "$2" $3
|
printlog "$2" $3
|
||||||
|
updateDialog "success" ""
|
||||||
fi
|
fi
|
||||||
printlog "################## End Installomator, exit code $1 \n" REQ
|
printlog "################## End Installomator, exit code $1 \n" REQ
|
||||||
|
|
||||||
@@ -470,7 +492,7 @@ downloadURLFromGit() { # $1 git user name, $2 git repo name
|
|||||||
downloadURL=https://github.com$(curl -sL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -o "\/$gitusername\/$gitreponame.*\.$filetype")
|
downloadURL=https://github.com$(curl -sL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -o "\/$gitusername\/$gitreponame.*\.$filetype")
|
||||||
fi
|
fi
|
||||||
if [ -z "$downloadURL" ]; then
|
if [ -z "$downloadURL" ]; then
|
||||||
cleanupAndExit 9 "could not retrieve download URL for $gitusername/$gitreponame" ERROR
|
cleanupAndExit 14 "could not retrieve download URL for $gitusername/$gitreponame" ERROR
|
||||||
else
|
else
|
||||||
echo "$downloadURL"
|
echo "$downloadURL"
|
||||||
return 0
|
return 0
|
||||||
@@ -586,7 +608,7 @@ getAppVersion() {
|
|||||||
printlog "Replacing App Store apps, no matter the version" WARN
|
printlog "Replacing App Store apps, no matter the version" WARN
|
||||||
appversion=0
|
appversion=0
|
||||||
else
|
else
|
||||||
cleanupAndExit 1 "App previously installed from App Store, and we respect that" ERROR
|
cleanupAndExit 23 "App previously installed from App Store, and we respect that" ERROR
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@@ -735,6 +757,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
|
|||||||
|
|
||||||
# verify with spctl
|
# verify with spctl
|
||||||
printlog "Verifying: $appPath" INFO
|
printlog "Verifying: $appPath" INFO
|
||||||
|
updateDialog "wait" "Verifying..."
|
||||||
printlog "App size: $(du -sh "$appPath")" DEBUG
|
printlog "App size: $(du -sh "$appPath")" DEBUG
|
||||||
appVerify=$(spctl -a -vv "$appPath" 2>&1 )
|
appVerify=$(spctl -a -vv "$appPath" 2>&1 )
|
||||||
appVerifyStatus=$(echo $?)
|
appVerifyStatus=$(echo $?)
|
||||||
@@ -783,7 +806,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
|
|||||||
printlog "notifying"
|
printlog "notifying"
|
||||||
displaynotification "$message" "Error updating $name!"
|
displaynotification "$message" "Error updating $name!"
|
||||||
fi
|
fi
|
||||||
cleanupAndExit 6 "Installed macOS is too old for this app." ERROR
|
cleanupAndExit 15 "Installed macOS is too old for this app." ERROR
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -842,7 +865,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
|
|||||||
deduplicatelogs "$CLIoutput"
|
deduplicatelogs "$CLIoutput"
|
||||||
|
|
||||||
if [ $CLIstatus -ne 0 ] ; then
|
if [ $CLIstatus -ne 0 ] ; then
|
||||||
cleanupAndExit 3 "Error installing $mountname/$CLIInstaller $CLIArguments error:\n$logoutput" ERROR
|
cleanupAndExit 16 "Error installing $mountname/$CLIInstaller $CLIArguments error:\n$logoutput" ERROR
|
||||||
else
|
else
|
||||||
printlog "Succesfully ran $mountname/$CLIInstaller $CLIArguments" INFO
|
printlog "Succesfully ran $mountname/$CLIInstaller $CLIArguments" INFO
|
||||||
fi
|
fi
|
||||||
@@ -880,6 +903,7 @@ installFromDMG() {
|
|||||||
installFromPKG() {
|
installFromPKG() {
|
||||||
# verify with spctl
|
# verify with spctl
|
||||||
printlog "Verifying: $archiveName"
|
printlog "Verifying: $archiveName"
|
||||||
|
updateDialog "wait" "Verifying..."
|
||||||
printlog "File list: $(ls -lh "$archiveName")" DEBUG
|
printlog "File list: $(ls -lh "$archiveName")" DEBUG
|
||||||
printlog "File type: $(file "$archiveName")" DEBUG
|
printlog "File type: $(file "$archiveName")" DEBUG
|
||||||
spctlOut=$(spctl -a -vv -t install "$archiveName" 2>&1 )
|
spctlOut=$(spctl -a -vv -t install "$archiveName" 2>&1 )
|
||||||
@@ -947,8 +971,29 @@ installFromPKG() {
|
|||||||
|
|
||||||
# install pkg
|
# install pkg
|
||||||
printlog "Installing $archiveName to $targetDir"
|
printlog "Installing $archiveName to $targetDir"
|
||||||
|
|
||||||
|
if [[ $DIALOG_CMD_FILE != "" ]]; then
|
||||||
|
# pipe
|
||||||
|
pipe="$tmpDir/installpipe"
|
||||||
|
# initialise named pipe for installer output
|
||||||
|
initNamedPipe create $pipe
|
||||||
|
|
||||||
|
# run the pipe read in the background
|
||||||
|
readPKGInstallPipe $pipe "$DIALOG_CMD_FILE" & installPipePID=$!
|
||||||
|
printlog "listening to output of installer with pipe $pipe and command file $DIALOG_CMD_FILE on PID $installPipePID" DEBUG
|
||||||
|
|
||||||
|
pkgInstall=$(installer -verboseR -pkg "$archiveName" -tgt "$targetDir" 2>&1 | tee $pipe)
|
||||||
|
pkgInstallStatus=$pipestatus[1]
|
||||||
|
# because we are tee-ing the output, we want the pipe status of the first command in the chain, not the most recent one
|
||||||
|
killProcess $installPipePID
|
||||||
|
|
||||||
|
else
|
||||||
pkgInstall=$(installer -verbose -dumplog -pkg "$archiveName" -tgt "$targetDir" 2>&1)
|
pkgInstall=$(installer -verbose -dumplog -pkg "$archiveName" -tgt "$targetDir" 2>&1)
|
||||||
pkgInstallStatus=$(echo $?)
|
pkgInstallStatus=$(echo $?)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
pkgEndTime=$(date "+$LogDateFormat")
|
pkgEndTime=$(date "+$LogDateFormat")
|
||||||
pkgInstall+=$(echo "\nOutput of /var/log/install.log below this line.\n")
|
pkgInstall+=$(echo "\nOutput of /var/log/install.log below this line.\n")
|
||||||
@@ -1040,7 +1085,7 @@ installPkgInZip() {
|
|||||||
printlog "Found pkg(s):\n$findfiles" DEBUG
|
printlog "Found pkg(s):\n$findfiles" DEBUG
|
||||||
filearray=( ${(f)findfiles} )
|
filearray=( ${(f)findfiles} )
|
||||||
if [[ ${#filearray} -eq 0 ]]; then
|
if [[ ${#filearray} -eq 0 ]]; then
|
||||||
cleanupAndExit 20 "couldn't find pkg in zip $archiveName" ERROR
|
cleanupAndExit 21 "couldn't find pkg in zip $archiveName" ERROR
|
||||||
fi
|
fi
|
||||||
# it is now safe to overwrite archiveName for installFromPKG
|
# it is now safe to overwrite archiveName for installFromPKG
|
||||||
archiveName="${filearray[1]}"
|
archiveName="${filearray[1]}"
|
||||||
@@ -1053,7 +1098,7 @@ installPkgInZip() {
|
|||||||
findfiles=$(find "$tmpDir" -iname "$pkgName")
|
findfiles=$(find "$tmpDir" -iname "$pkgName")
|
||||||
filearray=( ${(f)findfiles} )
|
filearray=( ${(f)findfiles} )
|
||||||
if [[ ${#filearray} -eq 0 ]]; then
|
if [[ ${#filearray} -eq 0 ]]; then
|
||||||
cleanupAndExit 20 "couldn't find pkg “$pkgName” in zip $archiveName" ERROR
|
cleanupAndExit 21 "couldn't find pkg “$pkgName” in zip $archiveName" ERROR
|
||||||
fi
|
fi
|
||||||
# it is now safe to overwrite archiveName for installFromPKG
|
# it is now safe to overwrite archiveName for installFromPKG
|
||||||
archiveName="${filearray[1]}"
|
archiveName="${filearray[1]}"
|
||||||
@@ -1076,7 +1121,7 @@ installAppInDmgInZip() {
|
|||||||
findfiles=$(find "$tmpDir" -iname "*.dmg" -maxdepth 2 )
|
findfiles=$(find "$tmpDir" -iname "*.dmg" -maxdepth 2 )
|
||||||
filearray=( ${(f)findfiles} )
|
filearray=( ${(f)findfiles} )
|
||||||
if [[ ${#filearray} -eq 0 ]]; then
|
if [[ ${#filearray} -eq 0 ]]; then
|
||||||
cleanupAndExit 20 "couldn't find dmg in zip $archiveName" ERROR
|
cleanupAndExit 22 "couldn't find dmg in zip $archiveName" ERROR
|
||||||
fi
|
fi
|
||||||
archiveName="$(basename ${filearray[1]})"
|
archiveName="$(basename ${filearray[1]})"
|
||||||
# it is now safe to overwrite archiveName for installFromDMG
|
# it is now safe to overwrite archiveName for installFromDMG
|
||||||
@@ -1128,7 +1173,8 @@ runUpdateTool() {
|
|||||||
|
|
||||||
finishing() {
|
finishing() {
|
||||||
printlog "Finishing..."
|
printlog "Finishing..."
|
||||||
sleep 10 # wait a moment to let spotlight catch up
|
|
||||||
|
sleep 3 # wait a moment to let spotlight catch up
|
||||||
getAppVersion
|
getAppVersion
|
||||||
|
|
||||||
if [[ -z $appversion ]]; then
|
if [[ -z $appversion ]]; then
|
||||||
@@ -1176,6 +1222,116 @@ hasDisplaySleepAssertion() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initNamedPipe() {
|
||||||
|
# create or delete a named pipe
|
||||||
|
# commands are "create" or "delete"
|
||||||
|
|
||||||
|
local cmd=$1
|
||||||
|
local pipe=$2
|
||||||
|
case $cmd in
|
||||||
|
"create")
|
||||||
|
if [[ -e $pipe ]]; then
|
||||||
|
rm $pipe
|
||||||
|
fi
|
||||||
|
# make named pipe
|
||||||
|
mkfifo -m 644 $pipe
|
||||||
|
;;
|
||||||
|
"delete")
|
||||||
|
# clean up
|
||||||
|
rm $pipe
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
readDownloadPipe() {
|
||||||
|
# reads from a previously created named pipe
|
||||||
|
# output from curl with --progress-bar. % downloaded is read in and then sent to the specified log file
|
||||||
|
local pipe=$1
|
||||||
|
local log=${2:-$DIALOG_CMD_FILE}
|
||||||
|
# set up read from pipe
|
||||||
|
while IFS= read -k 1 -u 0 char; do
|
||||||
|
if [[ $char =~ [0-9] ]]; then
|
||||||
|
keep=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $char == % ]]; then
|
||||||
|
updateDialog $progress "Downloading..."
|
||||||
|
progress=""
|
||||||
|
keep=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $keep == 1 ]]; then
|
||||||
|
progress="$progress$char"
|
||||||
|
fi
|
||||||
|
done < $pipe
|
||||||
|
}
|
||||||
|
|
||||||
|
readPKGInstallPipe() {
|
||||||
|
# reads from a previously created named pipe
|
||||||
|
# output from installer with -verboseR. % install status is read in and then sent to the specified log file
|
||||||
|
local pipe=$1
|
||||||
|
local log=${2:-$DIALOG_CMD_FILE}
|
||||||
|
local appname=${3:-$name}
|
||||||
|
|
||||||
|
while read -k 1 -u 0 char; do
|
||||||
|
if [[ $char == % ]]; then
|
||||||
|
keep=1
|
||||||
|
fi
|
||||||
|
if [[ $char =~ [0-9] && $keep == 1 ]]; then
|
||||||
|
progress="$progress$char"
|
||||||
|
fi
|
||||||
|
if [[ $char == . && $keep == 1 ]]; then
|
||||||
|
updateDialog $progress "Installing..."
|
||||||
|
progress=""
|
||||||
|
keep=0
|
||||||
|
fi
|
||||||
|
done < $pipe
|
||||||
|
}
|
||||||
|
|
||||||
|
killProcess() {
|
||||||
|
# will silently kill the specified PID
|
||||||
|
builtin kill $1 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDialog() {
|
||||||
|
local state=$1
|
||||||
|
local message=$2
|
||||||
|
local listitem=${3:-$DIALOG_LIST_ITEM_NAME}
|
||||||
|
local cmd_file=${4:-$DIALOG_CMD_FILE}
|
||||||
|
local progress=""
|
||||||
|
|
||||||
|
if [[ $state =~ '^[0-9]' \
|
||||||
|
|| $state == "reset" \
|
||||||
|
|| $state == "increment" \
|
||||||
|
|| $state == "complete" \
|
||||||
|
|| $state == "indeterminate" ]]; then
|
||||||
|
progress=$state
|
||||||
|
fi
|
||||||
|
|
||||||
|
# when to cmdfile is set, do nothing
|
||||||
|
if [[ $$cmd_file == "" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $listitem == "" ]]; then
|
||||||
|
# no listitem set, update main progress bar and progress text
|
||||||
|
if [[ $progress != "" ]]; then
|
||||||
|
echo "progress: $progress" >> $cmd_file
|
||||||
|
fi
|
||||||
|
if [[ $message != "" ]]; then
|
||||||
|
echo "progresstext: $name - $message" >> $cmd_file
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# list item has a value, so we update the progress and text in the list
|
||||||
|
if [[ $progress != "" ]]; then
|
||||||
|
echo "listitem: title: $listitem, statustext: $message, progress: $progress" >> $cmd_file
|
||||||
|
else
|
||||||
|
echo "listitem: title: $listitem, statustext: $message, status: $state" >> $cmd_file
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
# MARK: check minimal macOS requirement
|
# MARK: check minimal macOS requirement
|
||||||
autoload is-at-least
|
autoload is-at-least
|
||||||
|
|
||||||
@@ -1185,6 +1341,7 @@ if ! is-at-least 10.14 $installedOSversion; then
|
|||||||
exit 98
|
exit 98
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# MARK: argument parsing
|
# MARK: argument parsing
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
if [[ -z $label ]]; then # check if label is set inside script
|
if [[ -z $label ]]; then # check if label is set inside script
|
||||||
@@ -1202,7 +1359,7 @@ fi
|
|||||||
while [[ -n $1 ]]; do
|
while [[ -n $1 ]]; do
|
||||||
if [[ $1 =~ ".*\=.*" ]]; then
|
if [[ $1 =~ ".*\=.*" ]]; then
|
||||||
# if an argument contains an = character, send it to eval
|
# if an argument contains an = character, send it to eval
|
||||||
printlog "setting variable from argument $1" WARN
|
printlog "setting variable from argument $1" INFO
|
||||||
eval $1
|
eval $1
|
||||||
else
|
else
|
||||||
# assume it's a label
|
# assume it's a label
|
||||||
@@ -1277,6 +1434,16 @@ if [[ "$(whoami)" != "root" && "$DEBUG" -eq 0 ]]; then
|
|||||||
cleanupAndExit 6 "not running as root, exiting" ERROR
|
cleanupAndExit 6 "not running as root, exiting" ERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# check Swift Dialog presence and version
|
||||||
|
DIALOG_CMD="/usr/local/bin/dialog"
|
||||||
|
|
||||||
|
if [[ ! -x $DIALOG_CMD ]]; then
|
||||||
|
# Swift Dialog is not installed, clear cmd file variable to ignore
|
||||||
|
printlog "SwiftDialog is not installed, clear cmd file var"
|
||||||
|
DIALOG_CMD_FILE=""
|
||||||
|
fi
|
||||||
|
|
||||||
# MARK: labels in case statement
|
# MARK: labels in case statement
|
||||||
case $label in
|
case $label in
|
||||||
longversion)
|
longversion)
|
||||||
@@ -3288,7 +3455,7 @@ macports)
|
|||||||
archiveName="Catalina.pkg"
|
archiveName="Catalina.pkg"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
cleanupAndExit 1 "macOS 10.14 or earlier not supported by Installomator."
|
cleanupAndExit 98 "macOS 10.14 or earlier not supported by Installomator."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
downloadURL=$(downloadURLFromGit macports macports-base)
|
downloadURL=$(downloadURLFromGit macports macports-base)
|
||||||
@@ -4993,9 +5160,10 @@ vlc)
|
|||||||
vmwarehorizonclient)
|
vmwarehorizonclient)
|
||||||
name="VMware Horizon Client"
|
name="VMware Horizon Client"
|
||||||
type="dmg"
|
type="dmg"
|
||||||
downloadURL=$(curl -fsL "https://my.vmware.com/channel/public/api/v1.0/dlg/details?locale=en_US&downloadGroup=CART21FQ2_MAC_800&productId=1027&rPId=48989" | grep -o 'Url.*..dmg"' | cut -d '"' -f3)
|
downloadGroup=$(curl -fsL "https://my.vmware.com/channel/public/api/v1.0/products/getRelatedDLGList?locale=en_US&category=desktop_end_user_computing&product=vmware_horizon_clients&version=horizon_8&dlgType=PRODUCT_BINARY" | grep -o '[^"]*_MAC_[^"]*')
|
||||||
appNewVersion=$(curl -fsL "https://my.vmware.com/channel/public/api/v1.0/dlg/details?locale=en_US&downloadGroup=CART21FQ2_MAC_800&productId=1027&rPId=48989" | sed 's/.*-\(.*\)-.*/\1/')
|
fileName=$(curl -fsL "https://my.vmware.com/channel/public/api/v1.0/dlg/details?locale=en_US&category=desktop_end_user_computing&product=vmware_horizon_clients&dlgType=PRODUCT_BINARY&downloadGroup=${downloadGroup}" | grep -o '"fileName":"[^"]*"' | cut -d: -f2 | sed 's/"//g')
|
||||||
expectedTeamID="EG7KH642X6"
|
downloadURL="https://download3.vmware.com/software/$downloadGroup/${fileName}"
|
||||||
|
appNewVersion=$(curl -fsL "https://my.vmware.com/channel/public/api/v1.0/dlg/details?locale=en_US&downloadGroup=${downloadGroup}" | grep -o '[^"]*\.dmg[^"]*' | sed 's/.*-\(.*\)-.*/\1/') expectedTeamID="EG7KH642X6"
|
||||||
;;
|
;;
|
||||||
vscodium)
|
vscodium)
|
||||||
name="VSCodium"
|
name="VSCodium"
|
||||||
@@ -5328,7 +5496,7 @@ fi
|
|||||||
if [[ ${INTERRUPT_DND} = "no" ]]; then
|
if [[ ${INTERRUPT_DND} = "no" ]]; then
|
||||||
# Check if a fullscreen app is active
|
# Check if a fullscreen app is active
|
||||||
if hasDisplaySleepAssertion; then
|
if hasDisplaySleepAssertion; then
|
||||||
cleanupAndExit 1 "active display sleep assertion detected, aborting" ERROR
|
cleanupAndExit 24 "active display sleep assertion detected, aborting" ERROR
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -5442,7 +5610,7 @@ fi
|
|||||||
# MARK: change directory to temporary working directory
|
# MARK: change directory to temporary working directory
|
||||||
printlog "Changing directory to $tmpDir" DEBUG
|
printlog "Changing directory to $tmpDir" DEBUG
|
||||||
if ! cd "$tmpDir"; then
|
if ! cd "$tmpDir"; then
|
||||||
cleanupAndExit 1 "error changing directory $tmpDir" ERROR
|
cleanupAndExit 13 "error changing directory $tmpDir" ERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# MARK: get installed version
|
# MARK: get installed version
|
||||||
@@ -5478,6 +5646,8 @@ fi
|
|||||||
# MARK: check if this is an Update and we can use updateTool
|
# MARK: check if this is an Update and we can use updateTool
|
||||||
if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then
|
if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then
|
||||||
printlog "appversion & updateTool"
|
printlog "appversion & updateTool"
|
||||||
|
updateDialog "wait" "Updating..."
|
||||||
|
|
||||||
if [[ $DEBUG -ne 1 ]]; then
|
if [[ $DEBUG -ne 1 ]]; then
|
||||||
if runUpdateTool; then
|
if runUpdateTool; then
|
||||||
finishing
|
finishing
|
||||||
@@ -5504,8 +5674,28 @@ else
|
|||||||
displaynotification "Downloading new $name" "Download in progress …"
|
displaynotification "Downloading new $name" "Download in progress …"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $DIALOG_CMD_FILE != "" ]]; then
|
||||||
|
# pipe
|
||||||
|
pipe="$tmpDir/downloadpipe"
|
||||||
|
# initialise named pipe for curl output
|
||||||
|
initNamedPipe create $pipe
|
||||||
|
|
||||||
|
# run the pipe read in the background
|
||||||
|
readDownloadPipe $pipe "$DIALOG_CMD_FILE" & downloadPipePID=$!
|
||||||
|
printlog "listening to output of curl with pipe $pipe and command file $DIALOG_CMD_FILE on PID $downloadPipePID" DEBUG
|
||||||
|
|
||||||
|
curlDownload=$(curl -fL -# --show-error ${curlOptions} "$downloadURL" -o "$archiveName" 2>&1 | tee $pipe)
|
||||||
|
# because we are tee-ing the output, we want the pipe status of the first command in the chain, not the most recent one
|
||||||
|
curlDownloadStatus=$(echo $pipestatus[1])
|
||||||
|
killProcess $downloadPipePID
|
||||||
|
|
||||||
|
else
|
||||||
|
printlog "No Dialog connection, just download" DEBUG
|
||||||
curlDownload=$(curl -v -fsL --show-error ${curlOptions} "$downloadURL" -o "$archiveName" 2>&1)
|
curlDownload=$(curl -v -fsL --show-error ${curlOptions} "$downloadURL" -o "$archiveName" 2>&1)
|
||||||
curlDownloadStatus=$(echo $?)
|
curlDownloadStatus=$(echo $?)
|
||||||
|
fi
|
||||||
|
|
||||||
deduplicatelogs "$curlDownload"
|
deduplicatelogs "$curlDownload"
|
||||||
if [[ $curlDownloadStatus -ne 0 ]]; then
|
if [[ $curlDownloadStatus -ne 0 ]]; then
|
||||||
#if ! curl --location --fail --silent "$downloadURL" -o "$archiveName"; then
|
#if ! curl --location --fail --silent "$downloadURL" -o "$archiveName"; then
|
||||||
@@ -5547,8 +5737,10 @@ if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
|
|||||||
printlog "notifying"
|
printlog "notifying"
|
||||||
if [[ $updateDetected == "YES" ]]; then
|
if [[ $updateDetected == "YES" ]]; then
|
||||||
displaynotification "Updating $name" "Installation in progress …"
|
displaynotification "Updating $name" "Installation in progress …"
|
||||||
|
updateDialog "wait" "Updating..."
|
||||||
else
|
else
|
||||||
displaynotification "Installing $name" "Installation in progress …"
|
displaynotification "Installing $name" "Installation in progress …"
|
||||||
|
updateDialog "wait" "Installing..."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -5585,6 +5777,8 @@ case $type in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
updateDialog "wait" "Finishing..."
|
||||||
|
|
||||||
# MARK: Finishing — print installed application location and version
|
# MARK: Finishing — print installed application location and version
|
||||||
finishing
|
finishing
|
||||||
|
|
||||||
|
|||||||
@@ -160,10 +160,10 @@ downloadURLFromGit() { # $1 git user name, $2 git repo name
|
|||||||
|
|
||||||
if [ -n "$archiveName" ]; then
|
if [ -n "$archiveName" ]; then
|
||||||
#downloadURL=$(curl -L --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | awk -F '"' "/browser_download_url/ && /$archiveName\"/ { print \$4; exit }")
|
#downloadURL=$(curl -L --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | awk -F '"' "/browser_download_url/ && /$archiveName\"/ { print \$4; exit }")
|
||||||
downloadURL=https://github.com$(curl -sL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -o "\/$gitusername\/$gitreponame.*$archiveName.*")
|
downloadURL=https://github.com$(curl -sfL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -i "^/.*\/releases\/download\/.*$archiveName" | head -1)
|
||||||
else
|
else
|
||||||
#downloadURL=$(curl -L --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | awk -F '"' "/browser_download_url/ && /$filetype\"/ { print \$4; exit }")
|
#downloadURL=$(curl -L --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | awk -F '"' "/browser_download_url/ && /$filetype\"/ { print \$4; exit }")
|
||||||
downloadURL=https://github.com$(curl -sL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -o "\/$gitusername\/$gitreponame.*\.$filetype")
|
downloadURL=https://github.com$(curl -sfL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -i "^/.*\/releases\/download\/.*\.$filetype" | head -1)
|
||||||
fi
|
fi
|
||||||
if [ -z "$downloadURL" ]; then
|
if [ -z "$downloadURL" ]; then
|
||||||
cleanupAndExit 14 "could not retrieve download URL for $gitusername/$gitreponame" ERROR
|
cleanupAndExit 14 "could not retrieve download URL for $gitusername/$gitreponame" ERROR
|
||||||
|
|||||||
7
fragments/labels/cocoapods.sh
Normal file
7
fragments/labels/cocoapods.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
cocoapods)
|
||||||
|
name="CocoaPods"
|
||||||
|
type="bz2"
|
||||||
|
downloadURL="$(downloadURLFromGit CocoaPods CocoaPods-app)"
|
||||||
|
appNewVersion="$(versionFromGit CocoaPods CocoaPods-app)"
|
||||||
|
expectedTeamID="AX2Q2BH2XR"
|
||||||
|
;;
|
||||||
@@ -15,6 +15,29 @@ fi
|
|||||||
|
|
||||||
# MARK: application download and installation starts here
|
# MARK: application download and installation starts here
|
||||||
|
|
||||||
|
# Debug output of all variables in a label
|
||||||
|
printlog "name=${name}" DEBUG
|
||||||
|
printlog "appName=${appName}" DEBUG
|
||||||
|
printlog "type=${type}" DEBUG
|
||||||
|
printlog "archiveName=${archiveName}" DEBUG
|
||||||
|
printlog "downloadURL=${downloadURL}" DEBUG
|
||||||
|
printlog "curlOptions=${curlOptions}" DEBUG
|
||||||
|
printlog "appNewVersion=${appNewVersion}" DEBUG
|
||||||
|
printlog "appCustomVersion function: $(if type 'appCustomVersion' 2>/dev/null | grep -q 'function'; then echo "Defined. ${appCustomVersion}"; else; echo "Not defined"; fi)" DEBUG
|
||||||
|
printlog "versionKey=${versionKey}" DEBUG
|
||||||
|
printlog "packageID=${packageID}" DEBUG
|
||||||
|
printlog "pkgName=${pkgName}" DEBUG
|
||||||
|
printlog "choiceChangesXML=${choiceChangesXML}" DEBUG
|
||||||
|
printlog "expectedTeamID=${expectedTeamID}" DEBUG
|
||||||
|
printlog "blockingProcesses=${blockingProcesses}" DEBUG
|
||||||
|
printlog "installerTool=${installerTool}" DEBUG
|
||||||
|
printlog "CLIInstaller=${CLIInstaller}" DEBUG
|
||||||
|
printlog "CLIArguments=${CLIArguments}" DEBUG
|
||||||
|
printlog "updateTool=${updateTool}" DEBUG
|
||||||
|
printlog "updateToolArguments=${updateToolArguments}" DEBUG
|
||||||
|
printlog "updateToolRunAsCurrentUser=${updateToolRunAsCurrentUser}" DEBUG
|
||||||
|
#printlog "Company=${Company}" DEBUG # Not used
|
||||||
|
|
||||||
if [[ ${INTERRUPT_DND} = "no" ]]; then
|
if [[ ${INTERRUPT_DND} = "no" ]]; then
|
||||||
# Check if a fullscreen app is active
|
# Check if a fullscreen app is active
|
||||||
if hasDisplaySleepAssertion; then
|
if hasDisplaySleepAssertion; then
|
||||||
@@ -75,7 +98,7 @@ printlog "Label type: $type" INFO
|
|||||||
# MARK: extract info from data
|
# MARK: extract info from data
|
||||||
if [ -z "$archiveName" ]; then
|
if [ -z "$archiveName" ]; then
|
||||||
case $type in
|
case $type in
|
||||||
dmg|pkg|zip|tbz)
|
dmg|pkg|zip|tbz|bz2)
|
||||||
archiveName="${name}.$type"
|
archiveName="${name}.$type"
|
||||||
;;
|
;;
|
||||||
pkgInDmg)
|
pkgInDmg)
|
||||||
@@ -101,7 +124,7 @@ fi
|
|||||||
|
|
||||||
if [ -z "$targetDir" ]; then
|
if [ -z "$targetDir" ]; then
|
||||||
case $type in
|
case $type in
|
||||||
dmg|zip|tbz|app*)
|
dmg|zip|tbz|bz2|app*)
|
||||||
targetDir="/Applications"
|
targetDir="/Applications"
|
||||||
;;
|
;;
|
||||||
pkg*)
|
pkg*)
|
||||||
@@ -282,7 +305,7 @@ case $type in
|
|||||||
zip)
|
zip)
|
||||||
installFromZIP
|
installFromZIP
|
||||||
;;
|
;;
|
||||||
tbz)
|
tbz|bz2)
|
||||||
installFromTBZ
|
installFromTBZ
|
||||||
;;
|
;;
|
||||||
pkgInDmg)
|
pkgInDmg)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
10.0beta1
|
10.0beta2
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ echo "archivePath: $archivePath"
|
|||||||
# So we want to investigate which one has the filename
|
# So we want to investigate which one has the filename
|
||||||
try1archiveName=${${archiveTempName##*/}%%\?*}
|
try1archiveName=${${archiveTempName##*/}%%\?*}
|
||||||
try2archiveName=${${archivePath##*/}%%\?*}
|
try2archiveName=${${archivePath##*/}%%\?*}
|
||||||
fileName_re='^([a-zA-Z0-9\_.%-]*)\.(dmg|pkg|zip|tbz|gz)$' # regular expression for matching
|
fileName_re='^([a-zA-Z0-9\_.%-]*)\.(dmg|pkg|zip|tbz|gz|bz2)$' # regular expression for matching
|
||||||
if [[ "${try1archiveName}" =~ $fileName_re ]]; then
|
if [[ "${try1archiveName}" =~ $fileName_re ]]; then
|
||||||
archiveName=${try1archiveName}
|
archiveName=${try1archiveName}
|
||||||
elif [[ "${try2archiveName}" =~ $fileName_re ]]; then
|
elif [[ "${try2archiveName}" =~ $fileName_re ]]; then
|
||||||
@@ -293,7 +293,7 @@ if [ "$archiveExt" = "pkg" ]; then
|
|||||||
elif [ "$archiveExt" = "dmg" ]; then
|
elif [ "$archiveExt" = "dmg" ]; then
|
||||||
echo "Diskimage found"
|
echo "Diskimage found"
|
||||||
dmgInvestigation
|
dmgInvestigation
|
||||||
elif [ "$archiveExt" = "zip" ] || [ "$archiveExt" = "tbz" ]; then
|
elif [ "$archiveExt" = "zip" ] || [ "$archiveExt" = "tbz" ] || [ "$archiveExt" = "bz2" ]; then
|
||||||
echo "Compressed file found"
|
echo "Compressed file found"
|
||||||
# unzip the archive
|
# unzip the archive
|
||||||
tar -xf "$archiveName"
|
tar -xf "$archiveName"
|
||||||
|
|||||||
@@ -52,9 +52,22 @@ downloadURLFromGit() { # $1 git user name, $2 git repo name
|
|||||||
gitusername=${1?:"no git user name"}
|
gitusername=${1?:"no git user name"}
|
||||||
gitreponame=${2?:"no git repo name"}
|
gitreponame=${2?:"no git repo name"}
|
||||||
|
|
||||||
|
if [[ $type == "pkgInDmg" ]]; then
|
||||||
|
filetype="dmg"
|
||||||
|
elif [[ $type == "pkgInZip" ]]; then
|
||||||
|
filetype="zip"
|
||||||
|
else
|
||||||
|
filetype=$type
|
||||||
|
fi
|
||||||
|
|
||||||
#githubPart="$gitusername/$gitreponame/releases/download"
|
#githubPart="$gitusername/$gitreponame/releases/download"
|
||||||
#echo "$githubPart"
|
#echo "$githubPart"
|
||||||
downloadURL="https://github.com/$gitusername/$gitreponame/releases/latest"
|
#downloadURL="https://github.com/$gitusername/$gitreponame/releases/latest"
|
||||||
|
if [ -n "$archiveName" ]; then
|
||||||
|
downloadURL=https://github.com$(curl -sfL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -i "^/.*\/releases\/download\/.*$archiveName" | head -1)
|
||||||
|
else
|
||||||
|
downloadURL=https://github.com$(curl -sfL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -i "^/.*\/releases\/download\/.*\.$filetype" | head -1)
|
||||||
|
fi
|
||||||
echo "$downloadURL"
|
echo "$downloadURL"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -63,7 +76,7 @@ versionFromGit() { # $1 git user name, $2 git repo name
|
|||||||
gitusername=${1?:"no git user name"}
|
gitusername=${1?:"no git user name"}
|
||||||
gitreponame=${2?:"no git repo name"}
|
gitreponame=${2?:"no git repo name"}
|
||||||
|
|
||||||
appNewVersion=$(curl --silent --fail "https://github.com/$gitusername/$gitreponame/releases/latest" | sed -E 's/.*tag\/(.*)\">.*/\1/g' | sed 's/[^0-9\.]//g')
|
appNewVersion=$(curl -sLI "https://github.com/$gitusername/$gitreponame/releases/latest" | grep -i "^location" | tr "/" "\n" | tail -1 | sed 's/[^0-9\.]//g')
|
||||||
if [ -z "$appNewVersion" ]; then
|
if [ -z "$appNewVersion" ]; then
|
||||||
printlog "could not retrieve version number for $gitusername/$gitreponame: $appNewVersion"
|
printlog "could not retrieve version number for $gitusername/$gitreponame: $appNewVersion"
|
||||||
exit 9
|
exit 9
|
||||||
@@ -182,13 +195,14 @@ for fixedArch in i386 arm64; do
|
|||||||
|
|
||||||
#caseLabel
|
#caseLabel
|
||||||
if cat "${labels_dir}/${label}.sh" | grep -v -E '^[a-z0-9\_-]*(\)|\|\\)$' | grep -v ";;" > checkLabelCurrent.sh; then
|
if cat "${labels_dir}/${label}.sh" | grep -v -E '^[a-z0-9\_-]*(\)|\|\\)$' | grep -v ";;" > checkLabelCurrent.sh; then
|
||||||
|
INSTALL=force # This is only to prevent various Microsoft labels from running "msupdate --list"
|
||||||
source checkLabelCurrent.sh
|
source checkLabelCurrent.sh
|
||||||
|
|
||||||
echo "Name: $name"
|
echo "Name: $name"
|
||||||
echo "Download URL: $downloadURL"
|
echo "Download URL: $downloadURL"
|
||||||
echo "Type: $type"
|
echo "Type: $type"
|
||||||
case $type in
|
case $type in
|
||||||
dmg|pkg|zip|tbz)
|
dmg|pkg|zip|tbz|bz2)
|
||||||
expectedExtension="$type"
|
expectedExtension="$type"
|
||||||
;;
|
;;
|
||||||
pkgInDmg)
|
pkgInDmg)
|
||||||
|
|||||||
Reference in New Issue
Block a user