From f8a3104470bacb371fd1566dbe822e92d08a779b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 30 Mar 2022 13:39:23 +0200 Subject: [PATCH] MDM scripts updated --- MDM/App script.sh | 40 ++++++++++++++------- MDM/App-loop script.sh | 50 +++++++++++++++++--------- MDM/Installomator update.sh | 46 ++++++++++++------------ MDM/MDMAddigy CustomSoftware.sh | 53 ++++++++++++++++++---------- MDM/MDMMosyle install.sh | 22 +++++++----- MDM/Manual valuesfromarguments.sh | 58 +++++++++++++++++++------------ 6 files changed, 167 insertions(+), 102 deletions(-) diff --git a/MDM/App script.sh b/MDM/App script.sh index a33a43a..c7b4a10 100755 --- a/MDM/App script.sh +++ b/MDM/App script.sh @@ -5,8 +5,28 @@ what="brave" # enter the software to install # To be used as a script sent out from a MDM. # Fill the variable "what" above with a label. # Script will run this label. +LOGO="appstore" # or "addigy", "microsoft", "mosyleb", "mosylem" +###################################################################### +# Parameters for reinstall/initial install (owner root:wheel): +# "BLOCKING_PROCESS_ACTION=quit_kill INSTALL=force IGNORE_APP_STORE_APPS=yes SYSTEMOWNER=1" +# Parameters for Self Service installed app: +# "BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=all" +# Parameters for security important apps, like browsers (run automaticaly every day): +# "BLOCKING_PROCESS_ACTION=tell_user_then_kill" +# Update of service apps (run automatically): +# "BLOCKING_PROCESS_ACTION=quit_kill NOTIFY=silent" +parameters="BLOCKING_PROCESS_ACTION=tell_user_then_kill NOTIFY=all" ############################################### +# 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=$! @@ -16,18 +36,14 @@ caffexit () { exit $1 } -# 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." - caffexit 99 -fi - -${destFile} ${what} LOGO=mosyleb BLOCKING_PROCESS_ACTION=tell_user #NOTIFY=all #INSTALL=force -if [ $? != 0 ]; then -# This is currently not working in Mosyle, that will ignore script errors. Please request support for this from Mosyle! +cmdOutput="$(${destFile} ${what} LOGO=$LOGO $parameters LOGGING=WARN || true)" +# 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} -ne 0 ]] ; then + echo -e "Error installing ${what}. Exit code ${exitStatus}" + #echo "$cmdOutput" + errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + echo "$errorOutput" echo "Error installing ${what}. Exit code $?" caffexit $? fi diff --git a/MDM/App-loop script.sh b/MDM/App-loop script.sh index 17ce761..8fb33e7 100755 --- a/MDM/App-loop script.sh +++ b/MDM/App-loop script.sh @@ -1,11 +1,31 @@ #!/bin/zsh # Installation using Installomator -what="microsoftteams microsoftyammer firefox bravebrowser cyberduck vlc signal" # enter the software to install separated with spaces +whatList="microsoftteams microsoftyammer firefox bravebrowser cyberduck vlc signal" # enter the software to install separated with spaces # To be used as a script sent out from a MDM. -# Fill the variable "what" above with labels separated by space " ". +# Fill the variable "whatList" above with labels separated by space " ". # Script will loop through these labels. +LOGO="appstore" # or "addigy", "microsoft", "mosyleb", "mosylem" ###################################################################### +# Parameters for reinstall/initial install (owner root:wheel): +# "BLOCKING_PROCESS_ACTION=quit_kill INSTALL=force IGNORE_APP_STORE_APPS=yes SYSTEMOWNER=1" +# Parameters for Self Service installed app: +# "BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=all" +# Parameters for security important apps, like browsers (run automaticaly every day): +# "BLOCKING_PROCESS_ACTION=tell_user_then_kill" +# Update of service apps (run automatically): +# "BLOCKING_PROCESS_ACTION=quit_kill NOTIFY=silent" +parameters="BLOCKING_PROCESS_ACTION=tell_user NOTIFY=all" +###################################################################### + +# 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 & @@ -19,21 +39,17 @@ caffexit () { # Count errors errorCount=0 -# 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." - caffexit 99 -fi - -for item in $what; do - #echo $item - ${destFile} ${item} LOGO=mosyleb BLOCKING_PROCESS_ACTION=tell_user #NOTIFY=all #INSTALL=force - if [ $? != 0 ]; then - # This is currently not working in Mosyle, that will ignore script errors. Please request support for this from Mosyle! - echo "[$(DATE)] Error installing ${item}. Exit code $?" +for what in $whatList; do + #echo $what + # Install software using Installomator + cmdOutput="$(${destFile} ${what} LOGO=$LOGO $parameters LOGGING=WARN || true)" + # 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} -ne 0 ]] ; then + echo -e "Error installing ${what}. Exit code ${exitStatus}" + #echo "$cmdOutput" + errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + echo "$errorOutput" let errorCount++ fi done diff --git a/MDM/Installomator update.sh b/MDM/Installomator update.sh index 70fe71f..5b6bb67 100755 --- a/MDM/Installomator update.sh +++ b/MDM/Installomator update.sh @@ -1,9 +1,18 @@ #!/bin/bash # Updating Installomator # Usefull to push out after deployment if earlier version was deployed in DEP profile -# Currently script uses valuesfromarguments as a label is not included before next release, so this can be used to install to version 0.7 what="installomator" # enter the software to install +LOGO="appstore" # or "addigy", "microsoft", "mosyleb", "mosylem" + +# 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 & @@ -14,30 +23,19 @@ caffexit () { exit $1 } -# 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." - caffexit 99 -fi +# Install software using Installomator +cmdOutput="$(${destFile} ${what} LOGO=$LOGO BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent LOGGING=req || true)" -${destFile} valuesfromarguments\ - name=Installomator \ - type=pkg \ - packageID=com.scriptingosx.Installomator \ - downloadURL=https://github.com/Installomator/Installomator/releases/download/v0.7release/Installomator-0.7.0.pkg \ - appNewVersion=0.7 \ - expectedTeamID=JME5BW3F3R \ - BLOCKING_PROCESS_ACTION=ignore \ - NOTIFY=silent - -# ${destFile} ${what} BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent -if [ $? != 0 ]; then -# This is currently not working in Mosyle, that will ignore script errors. Please request support for this from Mosyle! - echo "Error installing ${what}. Exit code $?" - caffexit $? +# 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 -e "${what} succesfully installed.\n" +else + echo -e "Error installing ${what}. Exit code ${exitStatus}\n" + #echo "$cmdOutput" + errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + echo "$errorOutput" + caffexit $exitStatus fi echo "[$(DATE)][LOG-END]" diff --git a/MDM/MDMAddigy CustomSoftware.sh b/MDM/MDMAddigy CustomSoftware.sh index 8feb85a..e7918fd 100755 --- a/MDM/MDMAddigy CustomSoftware.sh +++ b/MDM/MDMAddigy CustomSoftware.sh @@ -5,15 +5,34 @@ # Mark: Installation script # Just click “Add” to autogenerate the installer script line by clicking the “Add”-button next to the Installer PKG, replace with first line below -/usr/sbin/installer -pkg "/Library/Addigy/ansible/packages/Installomator (0.7.0)/Installomator-0.7.0.pkg" -target / +/usr/sbin/installer -pkg "/Library/Addigy/ansible/packages/Installomator (9.1.0)/Installomator-9.1.pkg" -target / # Installation using Installomator -what="supportapp xink textmate microsoftedge wwdc keka vlc " # enter the software to installed separated with spaces +whatList="supportapp xink textmate microsoftedge wwdc keka vlc " # enter the software to installed separated with spaces # To be used as a script sent out from a MDM. -# Fill the variable "what" above with labels separated by space " ". +# Fill the variable "whatList" above with labels separated by space " ". # Script will loop through these labels and exit with number of errors. ###################################################################### +# Parameters for reinstall/initial install (owner root:wheel): +# "BLOCKING_PROCESS_ACTION=quit_kill INSTALL=force IGNORE_APP_STORE_APPS=yes SYSTEMOWNER=1" +# Parameters for Self Service installed app: +# "BLOCKING_PROCESS_ACTION=prompt_user NOTIFY=all" +# Parameters for security important apps, like browsers (run automaticaly every day): +# "BLOCKING_PROCESS_ACTION=tell_user_then_kill" +# Update of service apps (run automatically): +# "BLOCKING_PROCESS_ACTION=quit_kill NOTIFY=silent" +parameters="BLOCKING_PROCESS_ACTION=quit_kill INSTALL=force IGNORE_APP_STORE_APPS=yes" +###################################################################### + +# 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 & @@ -27,21 +46,17 @@ caffexit () { # Count errors errorCount=0 -# 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." - caffexit 99 -fi - -for item in $what; do - #echo $item - ${destFile} ${item} LOGO=addigy NOTIFY=silent BLOCKING_PROCESS_ACTION=quit_kill #INSTALL=force - if [ $? != 0 ]; then - # Error handling - echo "[$(DATE)] Error installing ${item}. Exit code $?" +for what in $whatList; do + #echo $what + # Install software using Installomator + cmdOutput="$(${destFile} ${what} LOGO=addigy $parameters || true)" + # 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} -ne 0 ]] ; then + echo -e "Error installing ${what}. Exit code ${exitStatus}" + #echo "$cmdOutput" + errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + echo "$errorOutput" let errorCount++ fi done @@ -56,7 +71,7 @@ caffexit $errorCount # Install on success # Remember to fill out the correct “TARGET_VERSION” and “PKG_ID”, and click "Install on succes". PKG_ID="com.scriptingosx.Installomator" -TARGET_VERSION="8.0" +TARGET_VERSION="9.1" vercomp () { if [[ $1 == $2 ]]; then diff --git a/MDM/MDMMosyle install.sh b/MDM/MDMMosyle install.sh index 6c6f9ca..27f9d8d 100644 --- a/MDM/MDMMosyle install.sh +++ b/MDM/MDMMosyle install.sh @@ -1,10 +1,11 @@ PKG_ID="com.scriptingosx.Installomator" -TARGET_VERSION="8.0" +TARGET_VERSION="9.1" URLDOWNLOAD="%MosyleCDNFile:blah-blah-blah%" ###################################################################### -# Installation using Installomator (enter the software to install separated with spaces in the "what"-variable) -what="handbrake theunarchiver microsoftoffice365" +# Installation using Installomator (enter the software to install separated with spaces in the "whatList"-variable) +whatList="handbrake theunarchiver microsoftoffice365" # Covered by Mosyle Catalog: "brave firefox googlechrome microsoftedge microsoftteams signal sublimetext vlc webex zoom" among others +LOGO="mosyleb" # or "mosylem" ###################################################################### ## Mark: Code here @@ -56,12 +57,17 @@ if [ ! -e "${destFile}" ]; then caffexit 99 fi -for item in $what; do +for what in $whatList; do #echo $item - ${destFile} ${item} LOGO=mosyle NOTIFY=all BLOCKING_PROCESS_ACTION=tell_user #NOTIFY=silent BLOCKING_PROCESS_ACTION=quit_kill #INSTALL=force - if [ $? != 0 ]; then - # Error handling - echo "[$(DATE)] Error installing ${item}. Exit code $?" + # Install software using Installomator + cmdOutput="$(${destFile} ${what} LOGO=$LOGO NOTIFY=all BLOCKING_PROCESS_ACTION=tell_user || true)" # NOTIFY=silent BLOCKING_PROCESS_ACTION=quit_kill INSTALL=force + # 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} -ne 0 ]] ; then + echo "Error installing ${what}. Exit code ${exitStatus}" + #echo "$cmdOutput" + errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + echo "$errorOutput" let errorCount++ fi done diff --git a/MDM/Manual valuesfromarguments.sh b/MDM/Manual valuesfromarguments.sh index 706f81f..ee80291 100755 --- a/MDM/Manual valuesfromarguments.sh +++ b/MDM/Manual valuesfromarguments.sh @@ -1,8 +1,20 @@ #!/bin/bash +# Software + # Installation using Installomator # Example of installing software using valuesfromarguments to install a custom software -what="valuesfromarguments" # enter the software to install +LOGO="appstore" # or "addigy", "microsoft", "mosyleb", "mosylem" +############################################### + +# 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 & @@ -13,29 +25,31 @@ caffexit () { exit $1 } -# 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." - caffexit 99 -fi +# Variables to calculate +downloadURL="https://craft-assets.invisionapp.com/CraftManager/production/CraftManager.zip" +appNewVersion=$(curl -fs https://craft-assets.invisionapp.com/CraftManager/production/appcast.xml | xpath -e '//rss/channel/item[1]/enclosure/@sparkle:shortVersionString' 2>/dev/null | cut -d '"' -f2) -${destFile} valuesfromarguments \ - name=\"Zoho\ WorkDrive\" \ - type=dmg \ - downloadURL=https://files-accl.zohopublic.com/public/wdbin/download/46f971e4fc4a32b68ad5d7dade38a7d2 \ - appNewVersion=2.6.25 \ - expectedTeamID=TZ824L8Y37 \ - BLOCKING_PROCESS_ACTION=quit \ - NOTIFY=all +# Install software using Installomator +cmdOutput="$(${destFile} valuesfromarguments LOGO=$LOGO \ + name=CraftManager \ + type=zip \ + downloadURL=$downloadURL \ + appNewVersion=$appNewVersion \ + expectedTeamID=VRXQSNCL5W \ + BLOCKING_PROCESS_ACTION=prompt_user \ + LOGGING=REQ \ + NOTIFY=all || true)" -# ${destFile} ${what} BLOCKING_PROCESS_ACTION=ignore NOTIFY=silent -if [ $? != 0 ]; then -# This is currently not working in Mosyle, that will ignore script errors. Please request support for this from Mosyle! - echo "Error installing ${what}. Exit code $?" - caffexit $? +# 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 -e "${what} succesfully installed.\n" +else + echo -e "Error installing ${what}. Exit code ${exitStatus}\n" + #printlog "$cmdOutput" + errorOutput="$( echo "${cmdOutput}" | grep --binary-files=text -i "error" || true )" + echo "$errorOutput" + caffexit $exitStatus fi echo "[$(DATE)][LOG-END]"