From 909a61fbe3a3fc4111316b06febed28a8b62f836 Mon Sep 17 00:00:00 2001 From: Theile Date: Mon, 19 Sep 2022 21:40:03 +0200 Subject: [PATCH] Improved icon checks and failovers --- ...=> -Progress 1st swiftDialog condition.sh} | 0 ...Dialog.sh => -Progress 1st swiftDialog.sh} | 0 ... -install swiftDialog direct condition.sh} | 0 ...rect.sh => -install swiftDialog direct.sh} | 0 .../Addigy condition notes.sh | 124 -------- .../App VFA SS github.sh | 83 +++++- .../App VFA SS.sh | 83 +++++- .../App browser-security.sh | 80 +++++- .../App normal SS multi-app.sh | 80 +++++- .../App normal SS.sh | 272 ++++++++++++++++++ .../App service Auto-install.sh} | 90 +++++- MDM/App-install/App service Auto-install.sh | 163 ++--------- 12 files changed, 656 insertions(+), 319 deletions(-) rename MDM/{-Progress 1st Dialog condition.sh => -Progress 1st swiftDialog condition.sh} (100%) rename MDM/{-Progress 1st Dialog.sh => -Progress 1st swiftDialog.sh} (100%) rename MDM/{-install Dialog direct condition.sh => -install swiftDialog direct condition.sh} (100%) rename MDM/{-install Dialog direct.sh => -install swiftDialog direct.sh} (100%) delete mode 100644 MDM/App-install with Dialog and dockutil/Addigy condition notes.sh rename MDM/{App-install with Dialog and dockutil => App-install with swiftDialog and dockutil}/App VFA SS github.sh (72%) rename MDM/{App-install with Dialog and dockutil => App-install with swiftDialog and dockutil}/App VFA SS.sh (67%) rename MDM/{App-install with Dialog and dockutil => App-install with swiftDialog and dockutil}/App browser-security.sh (66%) rename MDM/{App-install with Dialog and dockutil => App-install with swiftDialog and dockutil}/App normal SS multi-app.sh (66%) create mode 100644 MDM/App-install with swiftDialog and dockutil/App normal SS.sh rename MDM/{App-install with Dialog and dockutil/App normal SS.sh => App-install with swiftDialog and dockutil/App service Auto-install.sh} (62%) diff --git a/MDM/-Progress 1st Dialog condition.sh b/MDM/-Progress 1st swiftDialog condition.sh similarity index 100% rename from MDM/-Progress 1st Dialog condition.sh rename to MDM/-Progress 1st swiftDialog condition.sh diff --git a/MDM/-Progress 1st Dialog.sh b/MDM/-Progress 1st swiftDialog.sh similarity index 100% rename from MDM/-Progress 1st Dialog.sh rename to MDM/-Progress 1st swiftDialog.sh diff --git a/MDM/-install Dialog direct condition.sh b/MDM/-install swiftDialog direct condition.sh similarity index 100% rename from MDM/-install Dialog direct condition.sh rename to MDM/-install swiftDialog direct condition.sh diff --git a/MDM/-install Dialog direct.sh b/MDM/-install swiftDialog direct.sh similarity index 100% rename from MDM/-install Dialog direct.sh rename to MDM/-install swiftDialog direct.sh diff --git a/MDM/App-install with Dialog and dockutil/Addigy condition notes.sh b/MDM/App-install with Dialog and dockutil/Addigy condition notes.sh deleted file mode 100644 index 41d5d70..0000000 --- a/MDM/App-install with Dialog and dockutil/Addigy condition notes.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh - -# Addigy condition -# These are my notes for how I can extract all the label lines from Installomator.sh, evaluate those, and check if installed version is the latest version. -# This script contains functions from Installomator. -label="googlechromepkg" - -# PATH declaration -export PATH=/usr/bin:/bin:/usr/sbin:/sbin - -# Functions from Installomator -downloadURLFromGit() { # $1 git user name, $2 git repo name - gitusername=${1?:"no git user name"} - gitreponame=${2?:"no git repo name"} - - if [[ $type == "pkgInDmg" ]]; then - filetype="dmg" - elif [[ $type == "pkgInZip" ]]; then - filetype="zip" - else - filetype=$type - fi - - 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) - if [[ "$(echo $downloadURL | grep -ioE "https.*$archiveName")" == "" ]]; then - printlog "Trying GitHub API for download URL." - downloadURL=$(curl -sfL "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | awk -F '"' "/browser_download_url/ && /$archiveName\"/ { print \$4; exit }") - fi - else - downloadURL=https://github.com$(curl -sfL "https://github.com/$gitusername/$gitreponame/releases/latest" | tr '"' "\n" | grep -i "^/.*\/releases\/download\/.*\.$filetype" | head -1) - if [[ "$(echo $downloadURL | grep -ioE "https.*.$filetype")" == "" ]]; then - printlog "Trying GitHub API for download URL." - downloadURL=$(curl -sfL "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | awk -F '"' "/browser_download_url/ && /$filetype\"/ { print \$4; exit }") - fi - fi - if [ -z "$downloadURL" ]; then - cleanupAndExit 14 "could not retrieve download URL for $gitusername/$gitreponame" ERROR - else - echo "$downloadURL" - return 0 - fi -} - -versionFromGit() { - # credit: Søren Theilgaard (@theilgaard) - # $1 git user name, $2 git repo name - gitusername=${1?:"no git user name"} - gitreponame=${2?:"no git repo name"} - - #appNewVersion=$(curl -L --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | grep tag_name | cut -d '"' -f 4 | 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 - printlog "could not retrieve version number for $gitusername/$gitreponame" WARN - appNewVersion="" - else - echo "$appNewVersion" - return 0 - fi -} - - -# Handling of differences in xpath between Catalina and Big Sur -xpath() { - # the xpath tool changes in Big Sur and now requires the `-e` option - if [[ $(sw_vers -buildVersion) > "20A" ]]; then - /usr/bin/xpath -e $@ - # alternative: switch to xmllint (which is not perl) - #xmllint --xpath $@ - - else - /usr/bin/xpath $@ - fi -} - -# from @Pico: https://macadmins.slack.com/archives/CGXNNJXJ9/p1652222365989229?thread_ts=1651786411.413349&cid=CGXNNJXJ9 -getJSONValue() { - # $1: JSON string OR file path to parse (tested to work with up to 1GB string and 2GB file). - # $2: JSON key path to look up (using dot or bracket notation). - printf '%s' "$1" | /usr/bin/osascript -l 'JavaScript' \ - -e "let json = $.NSString.alloc.initWithDataEncoding($.NSFileHandle.fileHandleWithStandardInput.readDataToEndOfFile$(/usr/bin/uname -r | /usr/bin/awk -F '.' '($1 > 18) { print "AndReturnError(ObjC.wrap())" }'), $.NSUTF8StringEncoding)" \ - -e 'if ($.NSFileManager.defaultManager.fileExistsAtPath(json)) json = $.NSString.stringWithContentsOfFileEncodingError(json, $.NSUTF8StringEncoding, ObjC.wrap())' \ - -e "const value = JSON.parse(json.js)$([ -n "${2%%[.[]*}" ] && echo '.')$2" \ - -e 'if (typeof value === "object") { JSON.stringify(value, null, 4) } else { value }' -} - -# Mark: Script -labelScript=$(grep -E -m 1 -A 30 "^$label"'(\)|\|\\)$' "/usr/local/Installomator/Installomator.sh" | grep -B 30 -m 1 ";;") -echo $labelScript -eval $labelScript -echo $appNewVersion - - - -############################## -printLines=0; while read line; do; if [[ $printLines -eq 1 || "$(echo $line | grep -oE "^googlechromepkg")" != "" ]]; then; printLines=1; echo $line; fi; done < "/usr/local/Installomator/Installomator.sh" - -printLines=0; while read line; do; if [[ $printLines -eq 1 ]]; then; if [[ "$(echo $line | grep ";;")" == "" ]]; then; echo $line; else; printLines=0; fi ; elif [[ "$(echo $line | grep -oE "^googlechromepkg")" != "" ]]; then; printLines=1; fi; done < "/usr/local/Installomator/Installomator.sh" - -labelLines="$(printLines=0; while read line; do; if [[ $printLines -eq 1 ]]; then; if [[ "$(echo $line | grep ";;")" == "" ]]; then; echo $line; else; return; fi ; elif [[ "$(echo $line | grep -oE "^googlechromepkg")" != "" ]]; then; printLines=1; fi; done < "/usr/local/Installomator/Installomator.sh")"; echo $labelLines - -label="googlechromepkg";labelLines="$(printLines=0; while read line; do; if [[ $printLines -eq 1 ]]; then; if [[ "$(echo $line | grep ";;")" == "" ]]; then; echo $line; else; return; fi ; elif [[ "$(echo $line | grep -oE "^$label")" != "" ]]; then; printLines=1; fi; done < "/usr/local/Installomator/Installomator.sh")"; eval $labelLines ; echo $appNewVersion - - -label="googlechromepkg" -labelLines="$(printLines=0 -while read line; do - if [[ $printLines -eq 1 ]]; then - if [[ "$(echo $label | grep ";;")" == "" ]]; then - echo $line - else - return - fi - elif [[ "$(echo $line | grep -oE "^$label")" != "" ]]; then - printLines=1 - fi -done < "/usr/local/Installomator/Installomator.sh")" -eval $labelLines -echo $appNewVersion - - - - - - diff --git a/MDM/App-install with Dialog and dockutil/App VFA SS github.sh b/MDM/App-install with swiftDialog and dockutil/App VFA SS github.sh similarity index 72% rename from MDM/App-install with Dialog and dockutil/App VFA SS github.sh rename to MDM/App-install with swiftDialog and dockutil/App VFA SS github.sh index 7671062..fc983c8 100755 --- a/MDM/App-install with Dialog and dockutil/App VFA SS github.sh +++ b/MDM/App-install with swiftDialog and dockutil/App VFA SS github.sh @@ -81,7 +81,7 @@ dialog_command_file="/var/tmp/dialog.log" dialogApp="/Library/Application Support/Dialog/Dialog.app" dockutil="/usr/local/bin/dockutil" -installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space +installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space # Other installomatorOptions: # LOGGING=REQ @@ -105,9 +105,10 @@ installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_C # Fill the variable "item" above with a label. # Script will run this label through Installomator. ###################################################################### -# v. 10.1 : github-functions added. Improved appIcon handling. Can add the app to Dock using dockutil. -# v. 10 : Integration with Dialog and Installomator v. 10 -# v. 9.3 : Better logging handling and installomatorOptions fix. +# v. 10.0.2 : Improved icon checks and failovers +# v. 10.0.1 : github-functions added. Improved appIcon handling. Can add the app to Dock using dockutil. +# v. 10.0 : Integration with Dialog and Installomator v. 10 +# v. 9.3 : Better logging handling and installomatorOptions fix. ###################################################################### # Mark: Script @@ -178,7 +179,7 @@ if [[ $installomatorVersion -lt 10 ]] || [[ $(sw_vers -buildVersion) < "20A" ]]; echo "And macOS 11 Big Sur (build 20A) is required for Dialog. Installed build $(sw_vers -buildVersion)." installomatorNotify="NOTIFY=all" else - installomatorNotify="" + installomatorNotify="NOTIFY=silent" # check for Swift Dialog if [[ ! -d $dialogApp ]]; then echo "Cannot find dialog at $dialogApp" @@ -188,8 +189,7 @@ else fi # Configure and display swiftDialog - #itemName=$( ${destFile} ${item} RETURN_LABEL_NAME=1 LOGGING=REQ INSTALL=force | tail -1 || true ) - itemName="$name" + itemName=$( ${destFile} ${item} RETURN_LABEL_NAME=1 LOGGING=REQ INSTALL=force | tail -1 || true ) if [[ "$itemName" != "#" ]]; then message="Installing ${itemName}…" else @@ -197,6 +197,25 @@ else fi echo "$item $itemName" + #Check icon (expecting beginning with “http” to be web-link and “/” to be disk file) + echo "icon before check: $icon" + if [[ "$(echo ${icon} | grep -iE "^(http|ftp).*")" != "" ]]; then + echo "icon looks to be web-link" + if ! curl -sfL --output /dev/null -r 0-0 "${icon}" ; then + echo "ERROR: Cannot download link. Reset icon." + icon="" + fi + elif [[ "$(echo ${icon} | grep -iE "^\/.*")" != "" ]]; then + echo "icon looks to be a file" + if [[ ! -a "${icon}" ]]; then + echo "ERROR: Cannot find file. Reset icon." + icon="" + fi + else + echo "ERROR: Cannot figure out icon. Reset icon." + icon="" + fi + echo "icon after first check: $icon" # If no icon defined we are trying to search for installed app icon if [[ "$icon" == "" ]]; then appPath=$(mdfind "kind:application AND name:$itemName" | head -1 || true) @@ -205,12 +224,56 @@ else appIcon="${appIcon}.icns" fi icon="${appPath}/Contents/Resources/${appIcon}" - echo "${icon}" + echo "Icon before file check: ${icon}" if [ ! -f "${icon}" ]; then - icon="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + # Using LOGO variable to show logo in swiftDialog + case $LOGO in + appstore) + # Apple App Store on Mac + if [[ $(sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + ;; + jamf) + # Jamf Pro + LOGO_PATH="/Library/Application Support/JAMF/Jamf.app/Contents/Resources/AppIcon.icns" + ;; + mosyleb) + # Mosyle Business + LOGO_PATH="/Applications/Self-Service.app/Contents/Resources/AppIcon.icns" + ;; + mosylem) + # Mosyle Manager (education) + LOGO_PATH="/Applications/Manager.app/Contents/Resources/AppIcon.icns" + ;; + addigy) + # Addigy + LOGO_PATH="/Library/Addigy/macmanage/MacManage.app/Contents/Resources/atom.icns" + ;; + microsoft) + # Microsoft Endpoint Manager (Intune) + LOGO_PATH="/Library/Intune/Microsoft Intune Agent.app/Contents/Resources/AppIcon.icns" + ;; + ws1) + # Workspace ONE (AirWatch) + LOGO="/Applications/Workspace ONE Intelligent Hub.app/Contents/Resources/AppIcon.icns" + ;; + esac + if [[ ! -a "${LOGO_PATH}" ]]; then + printlog "ERROR in LOGO_PATH '${LOGO_PATH}', setting Mac App Store." + if [[ $(/usr/bin/sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + fi + icon="${LOGO_PATH}" fi fi - echo "${icon}" + echo "LOGO: $LOGO" + echo "icon: ${icon}" # display first screen open -a "$dialogApp" --args \ diff --git a/MDM/App-install with Dialog and dockutil/App VFA SS.sh b/MDM/App-install with swiftDialog and dockutil/App VFA SS.sh similarity index 67% rename from MDM/App-install with Dialog and dockutil/App VFA SS.sh rename to MDM/App-install with swiftDialog and dockutil/App VFA SS.sh index a7b84a7..dc7f0de 100755 --- a/MDM/App-install with Dialog and dockutil/App VFA SS.sh +++ b/MDM/App-install with swiftDialog and dockutil/App VFA SS.sh @@ -28,7 +28,7 @@ dialog_command_file="/var/tmp/dialog.log" dialogApp="/Library/Application Support/Dialog/Dialog.app" dockutil="/usr/local/bin/dockutil" -installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space +installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space # Other installomatorOptions: # LOGGING=REQ @@ -52,9 +52,10 @@ installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_C # Fill the variable "item" above with a label. # Script will run this label through Installomator. ###################################################################### -# v. 10.1 : Improved appIcon handling. Can add the app to Dock using dockutil -# v. 10 : Integration with Dialog and Installomator v. 10 -# v. 9.3 : Better logging handling and installomatorOptions fix. +# v. 10.0.2 : Improved icon checks and failovers +# v. 10.0.1 : Improved appIcon handling. Can add the app to Dock using dockutil +# v. 10.0 : Integration with Dialog and Installomator v. 10 +# v. 9.3 : Better logging handling and installomatorOptions fix. ###################################################################### # Mark: Script @@ -126,7 +127,7 @@ if [[ $installomatorVersion -lt 10 ]] || [[ $(sw_vers -buildVersion) < "20A" ]]; echo "And macOS 11 Big Sur (build 20A) is required for Dialog. Installed build $(sw_vers -buildVersion)." installomatorNotify="NOTIFY=all" else - installomatorNotify="" + installomatorNotify="NOTIFY=silent" # check for Swift Dialog if [[ ! -d $dialogApp ]]; then echo "Cannot find dialog at $dialogApp" @@ -136,8 +137,7 @@ else fi # Configure and display swiftDialog - #itemName=$( ${destFile} ${item} RETURN_LABEL_NAME=1 LOGGING=REQ INSTALL=force | tail -1 || true ) - itemName="$name" + itemName=$( ${destFile} ${item} RETURN_LABEL_NAME=1 LOGGING=REQ INSTALL=force | tail -1 || true ) if [[ "$itemName" != "#" ]]; then message="Installing ${itemName}…" else @@ -145,6 +145,25 @@ else fi echo "$item $itemName" + #Check icon (expecting beginning with “http” to be web-link and “/” to be disk file) + echo "icon before check: $icon" + if [[ "$(echo ${icon} | grep -iE "^(http|ftp).*")" != "" ]]; then + echo "icon looks to be web-link" + if ! curl -sfL --output /dev/null -r 0-0 "${icon}" ; then + echo "ERROR: Cannot download link. Reset icon." + icon="" + fi + elif [[ "$(echo ${icon} | grep -iE "^\/.*")" != "" ]]; then + echo "icon looks to be a file" + if [[ ! -a "${icon}" ]]; then + echo "ERROR: Cannot find file. Reset icon." + icon="" + fi + else + echo "ERROR: Cannot figure out icon. Reset icon." + icon="" + fi + echo "icon after first check: $icon" # If no icon defined we are trying to search for installed app icon if [[ "$icon" == "" ]]; then appPath=$(mdfind "kind:application AND name:$itemName" | head -1 || true) @@ -153,12 +172,56 @@ else appIcon="${appIcon}.icns" fi icon="${appPath}/Contents/Resources/${appIcon}" - echo "${icon}" + echo "Icon before file check: ${icon}" if [ ! -f "${icon}" ]; then - icon="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + # Using LOGO variable to show logo in swiftDialog + case $LOGO in + appstore) + # Apple App Store on Mac + if [[ $(sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + ;; + jamf) + # Jamf Pro + LOGO_PATH="/Library/Application Support/JAMF/Jamf.app/Contents/Resources/AppIcon.icns" + ;; + mosyleb) + # Mosyle Business + LOGO_PATH="/Applications/Self-Service.app/Contents/Resources/AppIcon.icns" + ;; + mosylem) + # Mosyle Manager (education) + LOGO_PATH="/Applications/Manager.app/Contents/Resources/AppIcon.icns" + ;; + addigy) + # Addigy + LOGO_PATH="/Library/Addigy/macmanage/MacManage.app/Contents/Resources/atom.icns" + ;; + microsoft) + # Microsoft Endpoint Manager (Intune) + LOGO_PATH="/Library/Intune/Microsoft Intune Agent.app/Contents/Resources/AppIcon.icns" + ;; + ws1) + # Workspace ONE (AirWatch) + LOGO="/Applications/Workspace ONE Intelligent Hub.app/Contents/Resources/AppIcon.icns" + ;; + esac + if [[ ! -a "${LOGO_PATH}" ]]; then + printlog "ERROR in LOGO_PATH '${LOGO_PATH}', setting Mac App Store." + if [[ $(/usr/bin/sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + fi + icon="${LOGO_PATH}" fi fi - echo "${icon}" + echo "LOGO: $LOGO" + echo "icon: ${icon}" # display first screen open -a "$dialogApp" --args \ diff --git a/MDM/App-install with Dialog and dockutil/App browser-security.sh b/MDM/App-install with swiftDialog and dockutil/App browser-security.sh similarity index 66% rename from MDM/App-install with Dialog and dockutil/App browser-security.sh rename to MDM/App-install with swiftDialog and dockutil/App browser-security.sh index d9eb405..707acc5 100755 --- a/MDM/App-install with Dialog and dockutil/App browser-security.sh +++ b/MDM/App-install with swiftDialog and dockutil/App browser-security.sh @@ -21,7 +21,7 @@ dialog_command_file="/var/tmp/dialog.log" dialogApp="/Library/Application Support/Dialog/Dialog.app" dockutil="/usr/local/bin/dockutil" -installomatorOptions="BLOCKING_PROCESS_ACTION=tell_user_then_quit NOTIFY=silent DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space +installomatorOptions="BLOCKING_PROCESS_ACTION=tell_user_then_quit DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space # Other installomatorOptions: # LOGGING=REQ @@ -45,9 +45,10 @@ installomatorOptions="BLOCKING_PROCESS_ACTION=tell_user_then_quit NOTIFY=silent # Fill the variable "item" above with a label. # Script will run this label through Installomator. ###################################################################### -# v. 10.1 : Improved appIcon handling. Can add the app to Dock using dockutil -# v. 10 : Integration with Dialog and Installomator v. 10 -# v. 9.3 : Better logging handling and installomatorOptions fix. +# v. 10.0.2 : Improved icon checks and failovers +# v. 10.0.1 : Improved appIcon handling. Can add the app to Dock using dockutil +# v. 10.0 : Integration with Dialog and Installomator v. 10 +# v. 9.3 : Better logging handling and installomatorOptions fix. ###################################################################### # Mark: Script @@ -118,7 +119,7 @@ if [[ $installomatorVersion -lt 10 ]] || [[ $(sw_vers -buildVersion) < "20A" ]]; echo "And macOS 11 Big Sur (build 20A) is required for Dialog. Installed build $(sw_vers -buildVersion)." installomatorNotify="NOTIFY=all" else - installomatorNotify="" + installomatorNotify="NOTIFY=silent" # check for Swift Dialog if [[ ! -d $dialogApp ]]; then echo "Cannot find dialog at $dialogApp" @@ -136,6 +137,25 @@ else fi echo "$item $itemName" + #Check icon (expecting beginning with “http” to be web-link and “/” to be disk file) + echo "icon before check: $icon" + if [[ "$(echo ${icon} | grep -iE "^(http|ftp).*")" != "" ]]; then + echo "icon looks to be web-link" + if ! curl -sfL --output /dev/null -r 0-0 "${icon}" ; then + echo "ERROR: Cannot download link. Reset icon." + icon="" + fi + elif [[ "$(echo ${icon} | grep -iE "^\/.*")" != "" ]]; then + echo "icon looks to be a file" + if [[ ! -a "${icon}" ]]; then + echo "ERROR: Cannot find file. Reset icon." + icon="" + fi + else + echo "ERROR: Cannot figure out icon. Reset icon." + icon="" + fi + echo "icon after first check: $icon" # If no icon defined we are trying to search for installed app icon if [[ "$icon" == "" ]]; then appPath=$(mdfind "kind:application AND name:$itemName" | head -1 || true) @@ -144,12 +164,56 @@ else appIcon="${appIcon}.icns" fi icon="${appPath}/Contents/Resources/${appIcon}" - echo "${icon}" + echo "Icon before file check: ${icon}" if [ ! -f "${icon}" ]; then - icon="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + # Using LOGO variable to show logo in swiftDialog + case $LOGO in + appstore) + # Apple App Store on Mac + if [[ $(sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + ;; + jamf) + # Jamf Pro + LOGO_PATH="/Library/Application Support/JAMF/Jamf.app/Contents/Resources/AppIcon.icns" + ;; + mosyleb) + # Mosyle Business + LOGO_PATH="/Applications/Self-Service.app/Contents/Resources/AppIcon.icns" + ;; + mosylem) + # Mosyle Manager (education) + LOGO_PATH="/Applications/Manager.app/Contents/Resources/AppIcon.icns" + ;; + addigy) + # Addigy + LOGO_PATH="/Library/Addigy/macmanage/MacManage.app/Contents/Resources/atom.icns" + ;; + microsoft) + # Microsoft Endpoint Manager (Intune) + LOGO_PATH="/Library/Intune/Microsoft Intune Agent.app/Contents/Resources/AppIcon.icns" + ;; + ws1) + # Workspace ONE (AirWatch) + LOGO="/Applications/Workspace ONE Intelligent Hub.app/Contents/Resources/AppIcon.icns" + ;; + esac + if [[ ! -a "${LOGO_PATH}" ]]; then + printlog "ERROR in LOGO_PATH '${LOGO_PATH}', setting Mac App Store." + if [[ $(/usr/bin/sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + fi + icon="${LOGO_PATH}" fi fi - echo "${icon}" + echo "LOGO: $LOGO" + echo "icon: ${icon}" # display first screen open -a "$dialogApp" --args \ diff --git a/MDM/App-install with Dialog and dockutil/App normal SS multi-app.sh b/MDM/App-install with swiftDialog and dockutil/App normal SS multi-app.sh similarity index 66% rename from MDM/App-install with Dialog and dockutil/App normal SS multi-app.sh rename to MDM/App-install with swiftDialog and dockutil/App normal SS multi-app.sh index 9d3d593..d54c94f 100644 --- a/MDM/App-install with Dialog and dockutil/App normal SS multi-app.sh +++ b/MDM/App-install with swiftDialog and dockutil/App normal SS multi-app.sh @@ -21,7 +21,7 @@ dialog_command_file="/var/tmp/dialog.log" dialogApp="/Library/Application Support/Dialog/Dialog.app" dockutil="/usr/local/bin/dockutil" -installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space +installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space # Other installomatorOptions: # LOGGING=REQ @@ -45,9 +45,10 @@ installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_C # Fill the variable "item" above with a label. # Script will run this label through Installomator. ###################################################################### -# v. 10.1 : Improved appIcon handling. Can add the app to Dock using dockutil -# v. 10 : Integration with Dialog and Installomator v. 10 -# v. 9.3 : Better logging handling and installomatorOptions fix. +# v. 10.0.2 : Improved icon checks and failovers +# v. 10.0.1 : Improved appIcon handling. Can add the app to Dock using dockutil +# v. 10.0 : Integration with Dialog and Installomator v. 10 +# v. 9.3 : Better logging handling and installomatorOptions fix. ###################################################################### # Mark: Script @@ -118,7 +119,7 @@ if [[ $installomatorVersion -lt 10 ]] || [[ $(sw_vers -buildVersion) < "20A" ]]; echo "And macOS 11 Big Sur (build 20A) is required for Dialog. Installed build $(sw_vers -buildVersion)." installomatorNotify="NOTIFY=all" else - installomatorNotify="" + installomatorNotify="NOTIFY=silent" # check for Swift Dialog if [[ ! -d $dialogApp ]]; then echo "Cannot find dialog at $dialogApp" @@ -136,6 +137,25 @@ else fi echo "$item $itemName" + #Check icon (expecting beginning with “http” to be web-link and “/” to be disk file) + echo "icon before check: $icon" + if [[ "$(echo ${icon} | grep -iE "^(http|ftp).*")" != "" ]]; then + echo "icon looks to be web-link" + if ! curl -sfL --output /dev/null -r 0-0 "${icon}" ; then + echo "ERROR: Cannot download link. Reset icon." + icon="" + fi + elif [[ "$(echo ${icon} | grep -iE "^\/.*")" != "" ]]; then + echo "icon looks to be a file" + if [[ ! -a "${icon}" ]]; then + echo "ERROR: Cannot find file. Reset icon." + icon="" + fi + else + echo "ERROR: Cannot figure out icon. Reset icon." + icon="" + fi + echo "icon after first check: $icon" # If no icon defined we are trying to search for installed app icon if [[ "$icon" == "" ]]; then appPath=$(mdfind "kind:application AND name:$itemName" | head -1 || true) @@ -144,12 +164,56 @@ else appIcon="${appIcon}.icns" fi icon="${appPath}/Contents/Resources/${appIcon}" - echo "${icon}" + echo "Icon before file check: ${icon}" if [ ! -f "${icon}" ]; then - icon="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + # Using LOGO variable to show logo in swiftDialog + case $LOGO in + appstore) + # Apple App Store on Mac + if [[ $(sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + ;; + jamf) + # Jamf Pro + LOGO_PATH="/Library/Application Support/JAMF/Jamf.app/Contents/Resources/AppIcon.icns" + ;; + mosyleb) + # Mosyle Business + LOGO_PATH="/Applications/Self-Service.app/Contents/Resources/AppIcon.icns" + ;; + mosylem) + # Mosyle Manager (education) + LOGO_PATH="/Applications/Manager.app/Contents/Resources/AppIcon.icns" + ;; + addigy) + # Addigy + LOGO_PATH="/Library/Addigy/macmanage/MacManage.app/Contents/Resources/atom.icns" + ;; + microsoft) + # Microsoft Endpoint Manager (Intune) + LOGO_PATH="/Library/Intune/Microsoft Intune Agent.app/Contents/Resources/AppIcon.icns" + ;; + ws1) + # Workspace ONE (AirWatch) + LOGO="/Applications/Workspace ONE Intelligent Hub.app/Contents/Resources/AppIcon.icns" + ;; + esac + if [[ ! -a "${LOGO_PATH}" ]]; then + printlog "ERROR in LOGO_PATH '${LOGO_PATH}', setting Mac App Store." + if [[ $(/usr/bin/sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + fi + icon="${LOGO_PATH}" fi fi - echo "${icon}" + echo "LOGO: $LOGO" + echo "icon: ${icon}" # display first screen open -a "$dialogApp" --args \ diff --git a/MDM/App-install with swiftDialog and dockutil/App normal SS.sh b/MDM/App-install with swiftDialog and dockutil/App normal SS.sh new file mode 100644 index 0000000..2c6a6fc --- /dev/null +++ b/MDM/App-install with swiftDialog and dockutil/App normal SS.sh @@ -0,0 +1,272 @@ +#!/bin/sh + +# Installation using Installomator with Dialog showing progress (and posibility of adding to the Dock) + +LOGO="mosyleb" # "mosyleb", "mosylem", "addigy", "microsoft", "ws1" + +item="cyberduck" # enter the software to install +# Examples: microsoftedge, brave, googlechromepkg, firefoxpkg + +# Dialog icon +icon="https://mosylebusinessweb.blob.core.windows.net/envoit-public/customcommand_icon-envoit_666767b6276ff1f31b1ff9719639cf36f761f29f63f2ff17fc.png" +# icon should be a file system path or an URL to an online PNG, so beginning with either “/” or “http”. +# In Mosyle an URL can be found by copy picture address from a Custom Command icon. + +# dockutil variables +addToDock="0" # with dockutil after installation (0 if not) +appPath="/Applications/Cyberduck.app" + +# Other variables +dialog_command_file="/var/tmp/dialog.log" +dialogApp="/Library/Application Support/Dialog/Dialog.app" +dockutil="/usr/local/bin/dockutil" + +installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space + +# Other installomatorOptions: +# LOGGING=REQ +# LOGGING=DEBUG +# LOGGING=WARN +# BLOCKING_PROCESS_ACTION=ignore +# BLOCKING_PROCESS_ACTION=tell_user +# BLOCKING_PROCESS_ACTION=tell_user_then_quit +# BLOCKING_PROCESS_ACTION=prompt_user +# BLOCKING_PROCESS_ACTION=prompt_user_loop +# BLOCKING_PROCESS_ACTION=prompt_user_then_kill +# BLOCKING_PROCESS_ACTION=quit +# BLOCKING_PROCESS_ACTION=kill +# IGNORE_APP_STORE_APPS=yes +# INSTALL=force +###################################################################### +# To be used as a script sent out from a MDM. +# Fill the variable "item" above with a label. +# Script will run this label through Installomator. +###################################################################### +# v. 10.0.2 : Improved icon checks and failovers +# v. 10.0.1 : Improved appIcon handling. Can add the app to Dock using dockutil +# v. 10.0 : Integration with Dialog and Installomator v. 10 +# v. 9.3 : Better logging handling and installomatorOptions fix. +###################################################################### + +# Mark: Script +# PATH declaration +export PATH=/usr/bin:/bin:/usr/sbin:/sbin + +echo "$(date +%F\ %T) [LOG-BEGIN] $item" + +dialogUpdate() { + # $1: dialog command + local dcommand="$1" + + if [[ -n $dialog_command_file ]]; then + echo "$dcommand" >> "$dialog_command_file" + echo "Dialog: $dcommand" + fi +} +checkCmdOutput () { + # $1: cmdOutput + local cmdOutput="$1" + exitStatus="$( echo "${cmdOutput}" | grep --binary-files=text -i "exit" | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' || true )" + if [[ ${exitStatus} -eq 0 ]] ; then + echo "${item} succesfully installed." + warnOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "warn" || true )" + echo "$warnOutput" + else + echo "ERROR installing ${item}. Exit code ${exitStatus}" + echo "$cmdOutput" + #errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + #echo "$errorOutput" + fi +} + +# Check the currently logged in user +currentUser=$(stat -f "%Su" /dev/console) +if [ -z "$currentUser" ] || [ "$currentUser" = "loginwindow" ] || [ "$currentUser" = "_mbsetupuser" ] || [ "$currentUser" = "root" ]; then + echo "ERROR. Logged in user is $currentUser! Cannot proceed." + exit 97 +fi +# Get the current user's UID for dockutil +uid=$(id -u "$currentUser") +# Find the home folder of the user +userHome="$(dscl . -read /users/${currentUser} NFSHomeDirectory | awk '{print $2}')" + +# Verify that Installomator has been installed +destFile="/usr/local/Installomator/Installomator.sh" +if [ ! -e "${destFile}" ]; then + echo "Installomator not found here:" + echo "${destFile}" + echo "Exiting." + exit 99 +fi + +# No sleeping +/usr/bin/caffeinate -d -i -m -u & +caffeinatepid=$! +caffexit () { + kill "$caffeinatepid" + pkill caffeinate + exit $1 +} + +# Mark: Installation begins +installomatorVersion="$(${destFile} version | cut -d "." -f1 || true)" + +if [[ $installomatorVersion -lt 10 ]] || [[ $(sw_vers -buildVersion) < "20A" ]]; then + echo "Installomator should be at least version 10 to support Dialog. Installed version $installomatorVersion." + echo "And macOS 11 Big Sur (build 20A) is required for Dialog. Installed build $(sw_vers -buildVersion)." + installomatorNotify="NOTIFY=all" +else + installomatorNotify="NOTIFY=silent" + # check for Swift Dialog + if [[ ! -d $dialogApp ]]; then + echo "Cannot find dialog at $dialogApp" + # Install using Installlomator + cmdOutput="$(${destFile} dialog LOGO=$LOGO BLOCKING_PROCESS_ACTION=ignore LOGGING=REQ NOTIFY=silent || true)" + checkCmdOutput $cmdOutput + fi + + # Configure and display swiftDialog + itemName=$( ${destFile} ${item} RETURN_LABEL_NAME=1 LOGGING=REQ INSTALL=force | tail -1 || true ) + if [[ "$itemName" != "#" ]]; then + message="Installing ${itemName}…" + else + message="Installing ${item}…" + fi + echo "$item $itemName" + + #Check icon (expecting beginning with “http” to be web-link and “/” to be disk file) + echo "icon before check: $icon" + if [[ "$(echo ${icon} | grep -iE "^(http|ftp).*")" != "" ]]; then + echo "icon looks to be web-link" + if ! curl -sfL --output /dev/null -r 0-0 "${icon}" ; then + echo "ERROR: Cannot download link. Reset icon." + icon="" + fi + elif [[ "$(echo ${icon} | grep -iE "^\/.*")" != "" ]]; then + echo "icon looks to be a file" + if [[ ! -a "${icon}" ]]; then + echo "ERROR: Cannot find file. Reset icon." + icon="" + fi + else + echo "ERROR: Cannot figure out icon. Reset icon." + icon="" + fi + echo "icon after first check: $icon" + # If no icon defined we are trying to search for installed app icon + if [[ "$icon" == "" ]]; then + appPath=$(mdfind "kind:application AND name:$itemName" | head -1 || true) + appIcon=$(defaults read "${appPath}/Contents/Info.plist" CFBundleIconFile || true) + if [[ "$(echo "$appIcon" | grep -io ".icns")" == "" ]]; then + appIcon="${appIcon}.icns" + fi + icon="${appPath}/Contents/Resources/${appIcon}" + echo "Icon before file check: ${icon}" + if [ ! -f "${icon}" ]; then + # Using LOGO variable to show logo in swiftDialog + case $LOGO in + appstore) + # Apple App Store on Mac + if [[ $(sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + ;; + jamf) + # Jamf Pro + LOGO_PATH="/Library/Application Support/JAMF/Jamf.app/Contents/Resources/AppIcon.icns" + ;; + mosyleb) + # Mosyle Business + LOGO_PATH="/Applications/Self-Service.app/Contents/Resources/AppIcon.icns" + ;; + mosylem) + # Mosyle Manager (education) + LOGO_PATH="/Applications/Manager.app/Contents/Resources/AppIcon.icns" + ;; + addigy) + # Addigy + LOGO_PATH="/Library/Addigy/macmanage/MacManage.app/Contents/Resources/atom.icns" + ;; + microsoft) + # Microsoft Endpoint Manager (Intune) + LOGO_PATH="/Library/Intune/Microsoft Intune Agent.app/Contents/Resources/AppIcon.icns" + ;; + ws1) + # Workspace ONE (AirWatch) + LOGO="/Applications/Workspace ONE Intelligent Hub.app/Contents/Resources/AppIcon.icns" + ;; + esac + if [[ ! -a "${LOGO_PATH}" ]]; then + printlog "ERROR in LOGO_PATH '${LOGO_PATH}', setting Mac App Store." + if [[ $(/usr/bin/sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + fi + icon="${LOGO_PATH}" + fi + fi + echo "LOGO: $LOGO" + echo "icon: ${icon}" + + # display first screen + open -a "$dialogApp" --args \ + --title none \ + --icon "$icon" \ + --message "$message" \ + --mini \ + --progress 100 \ + --position bottomright \ + --movable \ + --commandfile "$dialog_command_file" + + # give everything a moment to catch up + sleep 0.1 +fi + +# Install software using Installomator +cmdOutput="$(${destFile} ${item} LOGO=$LOGO ${installomatorOptions} ${installomatorNotify} || true)" +checkCmdOutput $cmdOutput + +# Mark: dockutil stuff +if [[ $addToDock -eq 1 ]]; then + dialogUpdate "progresstext: Adding to Dock" + if [[ ! -d $dockutil ]]; then + echo "Cannot find dockutil at $dockutil, trying installation" + # Install using Installlomator + cmdOutput="$(${destFile} dockutil LOGO=$LOGO BLOCKING_PROCESS_ACTION=ignore LOGGING=REQ NOTIFY=silent || true)" + checkCmdOutput $cmdOutput + fi + echo "Adding to Dock" + $dockutil --add "${appPath}" "${userHome}/Library/Preferences/com.apple.dock.plist" || true + sleep 1 +else + echo "Not adding to Dock." +fi + +# Mark: Ending +if [[ $installomatorVersion -lt 10 ]]; then + echo "Again skipping Dialog stuff." +else + # close and quit dialog + dialogUpdate "progress: complete" + dialogUpdate "progresstext: Done" + + # pause a moment + sleep 0.5 + + dialogUpdate "quit:" + + # let everything catch up + sleep 0.5 + + # just to be safe + #killall "Dialog" 2>/dev/null || true +fi + +echo "[$(DATE)][LOG-END]" + +caffexit $exitStatus diff --git a/MDM/App-install with Dialog and dockutil/App normal SS.sh b/MDM/App-install with swiftDialog and dockutil/App service Auto-install.sh similarity index 62% rename from MDM/App-install with Dialog and dockutil/App normal SS.sh rename to MDM/App-install with swiftDialog and dockutil/App service Auto-install.sh index 7326f4a..2748c0f 100644 --- a/MDM/App-install with Dialog and dockutil/App normal SS.sh +++ b/MDM/App-install with swiftDialog and dockutil/App service Auto-install.sh @@ -1,11 +1,11 @@ #!/bin/sh -# Installation using Installomator with Dialog showing progress (and posibility of adding to the Dock) +# Installation using Installomator -LOGO="mosyleb" # "mosyleb", "mosylem", "addigy", "microsoft", "ws1" +LOGO="addigy" # "mosyleb", "mosylem", "addigy", "microsoft", "ws1" -item="" # enter the software to install -# Examples: microsoftedge, brave, googlechromepkg, firefoxpkg +item="xink" # enter the software to install +# Examples: desktoppr, dockutil, supportapp, applenyfonts, applesfpro, applesfmono, applesfcompact, nomad, nudge, shield, xink # Dialog icon icon="" @@ -14,14 +14,14 @@ icon="" # dockutil variables addToDock="1" # with dockutil after installation (0 if not) -appPath="/Applications/.app" +appPath="/Applications/Xink.app" # Other variables dialog_command_file="/var/tmp/dialog.log" dialogApp="/Library/Application Support/Dialog/Dialog.app" dockutil="/usr/local/bin/dockutil" -installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space +installomatorOptions="BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space # Other installomatorOptions: # LOGGING=REQ @@ -45,9 +45,10 @@ installomatorOptions="BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=silent DIALOG_C # Fill the variable "item" above with a label. # Script will run this label through Installomator. ###################################################################### -# v. 10.1 : Improved appIcon handling. Can add the app to Dock using dockutil -# v. 10 : Integration with Dialog and Installomator v. 10 -# v. 9.3 : Better logging handling and installomatorOptions fix. +# v. 10.0.2 : Improved icon checks and failovers +# v. 10.0.1 : Can add the app to Dock using dockutil +# v. 10.0 : Integration with Dialog and Installomator v. 10 +# v. 9.3 : Better logging handling and installomatorOptions fix. ###################################################################### # Mark: Script @@ -118,7 +119,7 @@ if [[ $installomatorVersion -lt 10 ]] || [[ $(sw_vers -buildVersion) < "20A" ]]; echo "And macOS 11 Big Sur (build 20A) is required for Dialog. Installed build $(sw_vers -buildVersion)." installomatorNotify="NOTIFY=all" else - installomatorNotify="" + installomatorNotify="NOTIFY=silent" # check for Swift Dialog if [[ ! -d $dialogApp ]]; then echo "Cannot find dialog at $dialogApp" @@ -136,6 +137,25 @@ else fi echo "$item $itemName" + #Check icon (expecting beginning with “http” to be web-link and “/” to be disk file) + echo "icon before check: $icon" + if [[ "$(echo ${icon} | grep -iE "^(http|ftp).*")" != "" ]]; then + echo "icon looks to be web-link" + if ! curl -sfL --output /dev/null -r 0-0 "${icon}" ; then + echo "ERROR: Cannot download link. Reset icon." + icon="" + fi + elif [[ "$(echo ${icon} | grep -iE "^\/.*")" != "" ]]; then + echo "icon looks to be a file" + if [[ ! -a "${icon}" ]]; then + echo "ERROR: Cannot find file. Reset icon." + icon="" + fi + else + echo "ERROR: Cannot figure out icon. Reset icon." + icon="" + fi + echo "icon after first check: $icon" # If no icon defined we are trying to search for installed app icon if [[ "$icon" == "" ]]; then appPath=$(mdfind "kind:application AND name:$itemName" | head -1 || true) @@ -144,12 +164,56 @@ else appIcon="${appIcon}.icns" fi icon="${appPath}/Contents/Resources/${appIcon}" - echo "${icon}" + echo "Icon before file check: ${icon}" if [ ! -f "${icon}" ]; then - icon="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + # Using LOGO variable to show logo in swiftDialog + case $LOGO in + appstore) + # Apple App Store on Mac + if [[ $(sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + ;; + jamf) + # Jamf Pro + LOGO_PATH="/Library/Application Support/JAMF/Jamf.app/Contents/Resources/AppIcon.icns" + ;; + mosyleb) + # Mosyle Business + LOGO_PATH="/Applications/Self-Service.app/Contents/Resources/AppIcon.icns" + ;; + mosylem) + # Mosyle Manager (education) + LOGO_PATH="/Applications/Manager.app/Contents/Resources/AppIcon.icns" + ;; + addigy) + # Addigy + LOGO_PATH="/Library/Addigy/macmanage/MacManage.app/Contents/Resources/atom.icns" + ;; + microsoft) + # Microsoft Endpoint Manager (Intune) + LOGO_PATH="/Library/Intune/Microsoft Intune Agent.app/Contents/Resources/AppIcon.icns" + ;; + ws1) + # Workspace ONE (AirWatch) + LOGO="/Applications/Workspace ONE Intelligent Hub.app/Contents/Resources/AppIcon.icns" + ;; + esac + if [[ ! -a "${LOGO_PATH}" ]]; then + printlog "ERROR in LOGO_PATH '${LOGO_PATH}', setting Mac App Store." + if [[ $(/usr/bin/sw_vers -buildVersion) > "19" ]]; then + LOGO_PATH="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" + else + LOGO_PATH="/Applications/App Store.app/Contents/Resources/AppIcon.icns" + fi + fi + icon="${LOGO_PATH}" fi fi - echo "${icon}" + echo "LOGO: $LOGO" + echo "icon: ${icon}" # display first screen open -a "$dialogApp" --args \ diff --git a/MDM/App-install/App service Auto-install.sh b/MDM/App-install/App service Auto-install.sh index 8e0509a..5b56685 100644 --- a/MDM/App-install/App service Auto-install.sh +++ b/MDM/App-install/App service Auto-install.sh @@ -2,26 +2,12 @@ # Installation using Installomator -LOGO="addigy" # "mosyleb", "mosylem", "addigy", "microsoft", "ws1" +LOGO="mosyleb" # "mosyleb", "mosylem", "addigy", "microsoft", "ws1" -item="xink" # enter the software to install -# Examples: desktoppr, dockutil, supportapp, applenyfonts, applesfpro, applesfmono, applesfcompact, nomad, nudge, shield, xink +what="dockutil" # enter the software to install +# Examples: adobecreativeclouddesktop, textmate, vlc -# Dialog icon -icon="" -# icon should be a file system path or an URL to an online PNG. -# In Mosyle an URL can be found by copy picture address from a Custom Command icon. - -# dockutil variables -addToDock="1" # with dockutil after installation (0 if not) -appPath="/Applications/Xink.app" - -# Other variables -dialog_command_file="/var/tmp/dialog.log" -dialogApp="/Library/Application Support/Dialog/Dialog.app" -dockutil="/usr/local/bin/dockutil" - -installomatorOptions="BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent DIALOG_CMD_FILE=${dialog_command_file}" # Separated by space +installomatorOptions="BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent" # Separated by space # Other installomatorOptions: # LOGGING=REQ @@ -42,11 +28,9 @@ installomatorOptions="BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent DIALOG_CMD_FI # INSTALL=force ###################################################################### # To be used as a script sent out from a MDM. -# Fill the variable "item" above with a label. +# Fill the variable "what" above with a label. # Script will run this label through Installomator. ###################################################################### -# v. 10.1 : Can add the app to Dock using dockutil -# v. 10 : Integration with Dialog and Installomator v. 10 # v. 9.3 : Better logging handling and installomatorOptions fix. ###################################################################### @@ -54,43 +38,7 @@ installomatorOptions="BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent DIALOG_CMD_FI # PATH declaration export PATH=/usr/bin:/bin:/usr/sbin:/sbin -echo "$(date +%F\ %T) [LOG-BEGIN] $item" - -dialogUpdate() { - # $1: dialog command - local dcommand="$1" - - if [[ -n $dialog_command_file ]]; then - echo "$dcommand" >> "$dialog_command_file" - echo "Dialog: $dcommand" - fi -} -checkCmdOutput () { - # $1: cmdOutput - local cmdOutput="$1" - exitStatus="$( echo "${cmdOutput}" | grep --binary-files=text -i "exit" | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' || true )" - if [[ ${exitStatus} -eq 0 ]] ; then - echo "${item} succesfully installed." - warnOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "warn" || true )" - echo "$warnOutput" - else - echo "ERROR installing ${item}. Exit code ${exitStatus}" - echo "$cmdOutput" - #errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" - #echo "$errorOutput" - fi -} - -# Check the currently logged in user -currentUser=$(stat -f "%Su" /dev/console) -if [ -z "$currentUser" ] || [ "$currentUser" = "loginwindow" ] || [ "$currentUser" = "_mbsetupuser" ] || [ "$currentUser" = "root" ]; then - echo "ERROR. Logged in user is $currentUser! Cannot proceed." - exit 97 -fi -# Get the current user's UID for dockutil -uid=$(id -u "$currentUser") -# Find the home folder of the user -userHome="$(dscl . -read /users/${currentUser} NFSHomeDirectory | awk '{print $2}')" +echo "$(date +%F\ %T) [LOG-BEGIN] $what" # Verify that Installomator has been installed destFile="/usr/local/Installomator/Installomator.sh" @@ -110,97 +58,20 @@ caffexit () { exit $1 } -# Mark: Installation begins -installomatorVersion="$(${destFile} version | cut -d "." -f1 || true)" - -if [[ $installomatorVersion -lt 10 ]] || [[ $(sw_vers -buildVersion) < "20A" ]]; then - echo "Installomator should be at least version 10 to support Dialog. Installed version $installomatorVersion." - echo "And macOS 11 Big Sur (build 20A) is required for Dialog. Installed build $(sw_vers -buildVersion)." - installomatorNotify="NOTIFY=all" -else - installomatorNotify="" - # check for Swift Dialog - if [[ ! -d $dialogApp ]]; then - echo "Cannot find dialog at $dialogApp" - # Install using Installlomator - cmdOutput="$(${destFile} dialog LOGO=$LOGO BLOCKING_PROCESS_ACTION=ignore LOGGING=REQ NOTIFY=silent || true)" - checkCmdOutput $cmdOutput - fi - - # Configure and display swiftDialog - itemName=$( ${destFile} ${item} RETURN_LABEL_NAME=1 LOGGING=REQ INSTALL=force | tail -1 || true ) - if [[ "$itemName" != "#" ]]; then - message="Installing ${itemName}…" - else - message="Installing ${item}…" - fi - echo "$item $itemName" - - # If no icon defined we are trying to search for installed app icon - if [[ "$icon" == "" ]]; then - appPath=$(mdfind "kind:application AND name:$itemName" | head -1) - appIcon=$(defaults read "${appPath}/Contents/Info.plist" CFBundleIconFile) - icon="${appPath}/Contents/Resources/${appIcon}" - echo "${icon}" - if [ ! -f "${icon}" ]; then - icon="/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" - fi - fi - echo "${icon}" - - # display first screen - open -a "$dialogApp" --args \ - --title none \ - --icon "$icon" \ - --message "$message" \ - --mini \ - --progress 100 \ - --position bottomright \ - --movable \ - --commandfile "$dialog_command_file" - - # give everything a moment to catch up - sleep 0.1 -fi - # Install software using Installomator -cmdOutput="$(${destFile} ${item} LOGO=$LOGO ${installomatorOptions} ${installomatorNotify} || true)" -checkCmdOutput $cmdOutput +cmdOutput="$(${destFile} ${what} LOGO=$LOGO ${installomatorOptions} || true)" -# Mark: dockutil stuff -if [[ $addToDock -eq 1 ]]; then - dialogUpdate "progresstext: Adding to Dock" - if [[ ! -d $dockutil ]]; then - echo "Cannot find dockutil at $dockutil, trying installation" - # Install using Installlomator - cmdOutput="$(${destFile} dockutil LOGO=$LOGO BLOCKING_PROCESS_ACTION=ignore LOGGING=REQ NOTIFY=silent || true)" - checkCmdOutput $cmdOutput - fi - echo "Adding to Dock" - $dockutil --add "${appPath}" "${userHome}/Library/Preferences/com.apple.dock.plist" || true - sleep 1 +# Check result +exitStatus="$( echo "${cmdOutput}" | grep --binary-files=text -i "exit" | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' || true )" +if [[ ${exitStatus} -eq 0 ]] ; then + echo "${what} succesfully installed." + warnOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "warn" || true )" + echo "$warnOutput" else - echo "Not adding to Dock." -fi - -# Mark: Ending -if [[ $installomatorVersion -lt 10 ]]; then - echo "Again skipping Dialog stuff." -else - # close and quit dialog - dialogUpdate "progress: complete" - dialogUpdate "progresstext: Done" - - # pause a moment - sleep 0.5 - - dialogUpdate "quit:" - - # let everything catch up - sleep 0.5 - - # just to be safe - #killall "Dialog" 2>/dev/null || true + echo "ERROR installing ${what}. Exit code ${exitStatus}" + echo "$cmdOutput" + #errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + #echo "$errorOutput" fi echo "[$(DATE)][LOG-END]"