Introducing curlOptions to labels.

This commit is contained in:
Søren Theilgaard
2022-01-11 11:54:54 +01:00
parent 732181c3a6
commit 01eabca204
3 changed files with 268 additions and 1 deletions

View File

@@ -6,7 +6,7 @@
- New variable `RETURN_LABEL_NAME`. If given the value `1`, like `RETURN_LABEL_NAME=1` then Installomator only returns the name of the label. It makes for a better user friendly message for displaying in DEPNotify if that is integrated. - New variable `RETURN_LABEL_NAME`. If given the value `1`, like `RETURN_LABEL_NAME=1` then Installomator only returns the name of the label. It makes for a better user friendly message for displaying in DEPNotify if that is integrated.
- Changed logic if `IGNORE_APP_STORE_APPS=yes`. Before this version a label like `microsoftonedrive` that was installed from App Store, and that we want to replace with the “ordinary” version, Installomator would still use `updateTool`, even though `IGNORE_APP_STORE_APPS=yes`. So we would have to have `INSTALL=force` in order to have the app replaced, as `updateTool` would be used. But now if `IGNORE_APP_STORE_APPS=yes` then `updateTool` will be not set, and the App Store app will be replaced. BUT if the installed software was not from App Store, then `updateTool` will not be used, and it would be a kind of a forced install (in the example of `microsoftonedrive`), except if the version is the same (where installation is skipped). - Changed logic if `IGNORE_APP_STORE_APPS=yes`. Before this version a label like `microsoftonedrive` that was installed from App Store, and that we want to replace with the “ordinary” version, Installomator would still use `updateTool`, even though `IGNORE_APP_STORE_APPS=yes`. So we would have to have `INSTALL=force` in order to have the app replaced, as `updateTool` would be used. But now if `IGNORE_APP_STORE_APPS=yes` then `updateTool` will be not set, and the App Store app will be replaced. BUT if the installed software was not from App Store, then `updateTool` will not be used, and it would be a kind of a forced install (in the example of `microsoftonedrive`), except if the version is the same (where installation is skipped).
- Added variable `SYSTEMOWNER` that is used when copying files when installing. Default `0` is to change owner of the app to the current user on the Mac, like this user was installing this app themselves. When using `1` we will put “root:wheel” on the app, which can be useful for shared machines. - Added variable `SYSTEMOWNER` that is used when copying files when installing. Default `0` is to change owner of the app to the current user on the Mac, like this user was installing this app themselves. When using `1` we will put “root:wheel” on the app, which can be useful for shared machines.
- Installomator will normally use `curl`without any headers to download files. But in the `buildLabel.sh` script it was necessary to add extra headers to get the correct download URLs from some servers, and as we get more experienced, various servers require different headers. In this version 3 set of extra headers has been added, so a download will be tried 4 times, but with different headers. Same sets of headers are also in `buildLabel.sh` in the same order. That has made it possible for the "mocha"-software-labels to work. - Added option `curlOptions` to the labels. It can be filled with extra headers need for downloading the specific software. See “mocha”-software-labels. By default Installomator use `curl` without any headers to download files, but in the `buildLabel.sh` script it was necessary to add extra headers to get the correct download URLs from some servers, and as we get more experienced, various servers require different headers. So 3 different sets of headers have been added to `buildLabel.sh` so a download will be tried 4 times. Browsers like Safari and Brave can be used to inspect which headers are needed for software to donwload.
## v8.0 ## v8.0

View File

@@ -3,5 +3,14 @@ mochatn3270)
type="appInDmgInZip" type="appInDmgInZip"
downloadURL="https://mochasoft.dk/tn3270.dmg.zip" downloadURL="https://mochasoft.dk/tn3270.dmg.zip"
appNewVersion="" appNewVersion=""
curlOptions="-H \"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15\" \
-H \"accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\" \
-H \"accept-encoding: gzip, deflate, br\" \
-H \"accept-language: en-US,en;q=0.9\" \
-H \"sec-fetch-dest: document\" \
-H \"sec-fetch-mode: navigate\" \
-H \"sec-fetch-user: ?1\" \
-H \"sec-gpc: 1\" \
-H \"upgrade-insecure-requests: 1\" "
expectedTeamID="RR9F5EPNVW" expectedTeamID="RR9F5EPNVW"
;; ;;

258
fragments/main.sh Normal file
View File

@@ -0,0 +1,258 @@
*)
# unknown label
#printlog "unknown label $label"
cleanupAndExit 1 "unknown label $label"
;;
esac
# Are we only asked to return label name
if [[ $RETURN_LABEL_NAME -eq 1 ]]; then
printlog "Only returning label name."
printlog "$name"
echo "$name"
exit
fi
# MARK: application download and installation starts here
printlog "BLOCKING_PROCESS_ACTION=${BLOCKING_PROCESS_ACTION}"
printlog "NOTIFY=${NOTIFY}"
# Finding LOGO to use in dialogs
case $LOGO in
appstore)
# Apple App Store on Mac
if [[ $(sw_vers -buildVersion) > "19" ]]; then
LOGO="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns"
else
LOGO="/Applications/App Store.app/Contents/Resources/AppIcon.icns"
fi
;;
jamf)
# Jamf Pro
LOGO="/Library/Application Support/JAMF/Jamf.app/Contents/Resources/AppIcon.icns"
;;
mosyleb)
# Mosyle Business
LOGO="/Applications/Self-Service.app/Contents/Resources/AppIcon.icns"
;;
mosylem)
# Mosyle Manager (education)
LOGO="/Applications/Manager.app/Contents/Resources/AppIcon.icns"
;;
addigy)
# Addigy
LOGO="/Library/Addigy/macmanage/MacManage.app/Contents/Resources/atom.icns"
;;
esac
if [[ ! -a "${LOGO}" ]]; then
if [[ $(sw_vers -buildVersion) > "19" ]]; then
LOGO="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns"
else
LOGO="/Applications/App Store.app/Contents/Resources/AppIcon.icns"
fi
fi
printlog "LOGO=${LOGO}"
# MARK: extract info from data
if [ -z "$archiveName" ]; then
case $type in
dmg|pkg|zip|tbz)
archiveName="${name}.$type"
;;
pkgInDmg)
archiveName="${name}.dmg"
;;
*InZip)
archiveName="${name}.zip"
;;
updateronly)
;;
*)
printlog "Cannot handle type $type"
cleanupAndExit 99
;;
esac
fi
if [ -z "$appName" ]; then
# when not given derive from name
appName="$name.app"
fi
if [ -z "$targetDir" ]; then
case $type in
dmg|zip|tbz|app*)
targetDir="/Applications"
;;
pkg*)
targetDir="/"
;;
updateronly)
;;
*)
printlog "Cannot handle type $type"
cleanupAndExit 99
;;
esac
fi
if [[ -z $blockingProcesses ]]; then
printlog "no blocking processes defined, using $name as default"
blockingProcesses=( $name )
fi
# MARK: determine tmp dir
if [ "$DEBUG" -eq 1 ]; then
# for debugging use script dir as working directory
tmpDir=$(dirname "$0")
else
# create temporary working directory
tmpDir=$(mktemp -d )
fi
# MARK: change directory to temporary working directory
printlog "Changing directory to $tmpDir"
if ! cd "$tmpDir"; then
printlog "error changing directory $tmpDir"
cleanupAndExit 1
fi
# MARK: get installed version
getAppVersion
printlog "appversion: $appversion"
# MARK: Exit if new version is the same as installed version (appNewVersion specified)
if [[ "$type" != "updateronly" && ($INSTALL == "force" || $IGNORE_APP_STORE_APPS == "yes") ]]; then
printlog "Label is not of type “updateronly”, and its set to use force to install or ignoring app store apps, so not using updateTool."
updateTool=""
fi
if [[ -n $appNewVersion ]]; then
printlog "Latest version of $name is $appNewVersion"
if [[ $appversion == $appNewVersion ]]; then
if [[ $DEBUG -ne 1 ]]; then
printlog "There is no newer version available."
if [[ $INSTALL != "force" ]]; then
message="$name, version $appNewVersion, is the latest version."
if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
printlog "notifying"
displaynotification "$message" "No update for $name!"
fi
cleanupAndExit 0 "No newer version."
fi
else
printlog "DEBUG mode 1 enabled, not exiting, but there is no new version of app."
fi
fi
else
printlog "Latest version not specified."
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 -ne 1 ]]; 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 1 enabled, not running update tool"
fi
fi
# MARK: download the archive
if [ -f "$archiveName" ] && [ "$DEBUG" -eq 1 ]; then
printlog "$archiveName exists and DEBUG mode 1 enabled, skipping download"
else
# download
printlog "Downloading $downloadURL to $archiveName"
if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
printlog "notifying"
if [[ $updateDetected == "YES" ]]; then
displaynotification "Downloading $name update" "Download in progress …"
else
displaynotification "Downloading new $name" "Download in progress …"
fi
fi
if ! curl -fsL ${=curlOptions} "$downloadURL" -o "$archiveName"; then
printlog "error downloading $downloadURL"
message="$name update/installation failed. This will be logged, so IT can follow up."
if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
printlog "notifying"
if [[ $updateDetected == "YES" ]]; then
displaynotification "$message" "Error updating $name"
else
displaynotification "$message" "Error installing $name"
fi
fi
cleanupAndExit 2
fi
fi
# MARK: when user is logged in, and app is running, prompt user to quit app
if [[ $BLOCKING_PROCESS_ACTION == "ignore" ]]; then
printlog "ignoring blocking processes"
else
if [[ $currentUser != "loginwindow" ]]; then
if [[ ${#blockingProcesses} -gt 0 ]]; then
if [[ ${blockingProcesses[1]} != "NONE" ]]; then
checkRunningProcesses
fi
fi
fi
fi
# MARK: install the download
printlog "Installing $name"
if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
printlog "notifying"
if [[ $updateDetected == "YES" ]]; then
displaynotification "Updating $name" "Installation in progress …"
else
displaynotification "Installing $name" "Installation in progress …"
fi
fi
if [ -n "$installerTool" ]; then
# installerTool defined, and we use that for installation
printlog "installerTool used: $installerTool"
appName="$installerTool"
fi
case $type in
dmg)
installFromDMG
;;
pkg)
installFromPKG
;;
zip)
installFromZIP
;;
tbz)
installFromTBZ
;;
pkgInDmg)
installPkgInDmg
;;
pkgInZip)
installPkgInZip
;;
appInDmgInZip)
installAppInDmgInZip
;;
*)
printlog "Cannot handle type $type"
cleanupAndExit 99
;;
esac
# MARK: Finishing — print installed application location and version
finishing
# all done!
cleanupAndExit 0