From f02bacc71ab59d7be1b41f15e87241abd5b8de3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Fri, 19 Nov 2021 12:31:43 +0100 Subject: [PATCH 1/2] MDM with caffeinate --- MDM/App script.sh | 13 ++++++++++--- MDM/App-loop script.sh | 19 ++++++++++++++++--- MDM/Installomator update.sh | 15 +++++++++++---- MDM/MDMAddigy CustomSoftware.sh | 13 ++++++++++--- MDM/MDMMosyle install.sh | 19 +++++++++++++------ MDM/Manual valuesfromarguments.sh | 15 +++++++++++---- 6 files changed, 71 insertions(+), 23 deletions(-) diff --git a/MDM/App script.sh b/MDM/App script.sh index 59926f0..a23fd95 100755 --- a/MDM/App script.sh +++ b/MDM/App script.sh @@ -7,6 +7,13 @@ what="brave" # enter the software to install # Script will run this label. ############################################### +# No sleeping +/usr/bin/caffeinate -d -i -m -u & +caffeinatepid=$! +caffexit () { + kill "$caffeinatepid" + exit $1 +} # Verify that Installomator has been installed destFile="/usr/local/Installomator/Installomator.sh" @@ -14,19 +21,19 @@ if [ ! -e "${destFile}" ]; then echo "Installomator not found here:" echo "${destFile}" echo "Exiting." - exit 99 + 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! echo "Error installing ${what}. Exit code $?" - exit $? + caffexit $? fi echo "[$(DATE)][LOG-END]" -exit 0 +caffexit 0 # notify behavior # NOTIFY=success diff --git a/MDM/App-loop script.sh b/MDM/App-loop script.sh index 2732267..f8b1025 100755 --- a/MDM/App-loop script.sh +++ b/MDM/App-loop script.sh @@ -7,13 +7,24 @@ what="microsoftteams microsoftyammer firefox bravebrowser cyberduck vlc signal" # Script will loop through these labels. ###################################################################### +# No sleeping +/usr/bin/caffeinate -d -i -m -u & +caffeinatepid=$! +caffexit () { + kill "$caffeinatepid" + exit $1 +} + +# 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." - exit 99 + caffexit 99 fi for item in $what; do @@ -22,13 +33,15 @@ for item in $what; do 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 $?" - # exit $? + let errorCount++ fi done +echo +echo "Errors: $errorCount" echo "[$(DATE)][LOG-END]" -exit 0 +caffexit $errorCount # notify behavior # NOTIFY=success diff --git a/MDM/Installomator update.sh b/MDM/Installomator update.sh index 47bedd3..fbc8327 100755 --- a/MDM/Installomator update.sh +++ b/MDM/Installomator update.sh @@ -5,13 +5,21 @@ what="installomator" # enter the software to install +# No sleeping +/usr/bin/caffeinate -d -i -m -u & +caffeinatepid=$! +caffexit () { + kill "$caffeinatepid" + 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." - exit 99 + caffexit 99 fi ${destFile} valuesfromarguments\ @@ -28,9 +36,8 @@ ${destFile} valuesfromarguments\ 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 $?" - exit $? + caffexit $? fi echo "[$(DATE)][LOG-END]" - -exit 0 +caffexit 0 diff --git a/MDM/MDMAddigy CustomSoftware.sh b/MDM/MDMAddigy CustomSoftware.sh index 3cb867c..864e2d4 100755 --- a/MDM/MDMAddigy CustomSoftware.sh +++ b/MDM/MDMAddigy CustomSoftware.sh @@ -15,6 +15,14 @@ what="supportapp xink textmate microsoftedge wwdc keka vlc " # enter the softwar # Script will loop through these labels and exit with number of errors. ###################################################################### +# No sleeping +/usr/bin/caffeinate -d -i -m -u & +caffeinatepid=$! +caffexit () { + kill "$caffeinatepid" + exit $1 +} + # Count errors errorCount=0 @@ -24,7 +32,7 @@ if [ ! -e "${destFile}" ]; then echo "Installomator not found here:" echo "${destFile}" echo "Exiting." - exit 99 + caffexit 99 fi for item in $what; do @@ -34,7 +42,6 @@ for item in $what; do # Error handling echo "[$(DATE)] Error installing ${item}. Exit code $?" let errorCount++ - # exit $? fi done @@ -42,7 +49,7 @@ echo echo "Errors: $errorCount" echo "[$(DATE)][LOG-END]" -exit $errorCount +caffexit $errorCount # Mark: Conditions # Install on success diff --git a/MDM/MDMMosyle install.sh b/MDM/MDMMosyle install.sh index 9de5f69..5a628f7 100644 --- a/MDM/MDMMosyle install.sh +++ b/MDM/MDMMosyle install.sh @@ -7,7 +7,15 @@ what="handbrake theunarchiver microsoftoffice365" # Covered by Mosyle Catalog: "brave firefox googlechrome microsoftedge microsoftteams signal sublimetext vlc webex zoom" among others ###################################################################### -## Code here +## Mark: Code here + +# No sleeping +/usr/bin/caffeinate -d -i -m -u & +caffeinatepid=$! +caffexit () { + kill "$caffeinatepid" + exit $1 +} # Mark: Condition for Installomator installation @@ -19,12 +27,12 @@ if [[ "$TARGET_VERSION" != "$INSTALLED_VERSION" ]]; then TMPDIR=$(mktemp -d ) if ! cd "$TMPDIR"; then echo "error changing directory $TMPDIR" - exit 98 + caffexit 98 fi NAME=$TMPDIR/$(date +%s).pkg if ! curl -fsL "$URLDOWNLOAD" -o "$NAME"; then echo "error downloading $URLDOWNLOAD to $NAME." - exit 97 + caffexit 97 fi installer -pkg "$NAME" -target / rm -rf "$TMPDIR" @@ -44,7 +52,7 @@ if [ ! -e "${destFile}" ]; then echo "Installomator not found here:" echo "${destFile}" echo "Exiting." - exit 99 + caffexit 99 fi for item in $what; do @@ -54,7 +62,6 @@ for item in $what; do # Error handling echo "[$(DATE)] Error installing ${item}. Exit code $?" let errorCount++ - # exit $? fi done @@ -62,4 +69,4 @@ echo echo "Errors: $errorCount" echo "[$(DATE)][LOG-END]" -exit $errorCount +caffexit $errorCount diff --git a/MDM/Manual valuesfromarguments.sh b/MDM/Manual valuesfromarguments.sh index b46a5fd..f435825 100755 --- a/MDM/Manual valuesfromarguments.sh +++ b/MDM/Manual valuesfromarguments.sh @@ -4,13 +4,21 @@ what="valuesfromarguments" # enter the software to install +# No sleeping +/usr/bin/caffeinate -d -i -m -u & +caffeinatepid=$! +caffexit () { + kill "$caffeinatepid" + 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." - exit 99 + caffexit 99 fi ${destFile} valuesfromarguments \ @@ -26,9 +34,8 @@ ${destFile} valuesfromarguments \ 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 $?" - exit $? + caffexit $? fi echo "[$(DATE)][LOG-END]" - -exit 0 +caffexit 0 From 305987e54a0edb1c348cfbdea8a97875e0ec35d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Mon, 22 Nov 2021 09:29:52 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47f9de..0cdc219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v0.8 - `buildLabel.sh` has been improved to build GitHub software labels much easier. In essense if the URL contains github.com, then it will try to find if it's the latest version or if variable `archiveName` is needed for finding the software. Also improved messaging throughout the script, as well as handling a situation where a pkg does not include a “DIstribution” file, but a “PackageInfo”. +- MDM script extended with `caffeinate` so Mac will not go to sleep during the time it takes installomator to run. Especially during setup, this can be handy. ## v0.7