From 6258de8bef3a4384e91587d8ae64a26fd8708698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 10 Nov 2021 21:46:37 +0100 Subject: [PATCH] Create MDMMosyle install.sh --- MDM/MDMMosyle install.sh | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 MDM/MDMMosyle install.sh diff --git a/MDM/MDMMosyle install.sh b/MDM/MDMMosyle install.sh new file mode 100644 index 0000000..9de5f69 --- /dev/null +++ b/MDM/MDMMosyle install.sh @@ -0,0 +1,65 @@ +PKG_ID="com.scriptingosx.Installomator" +TARGET_VERSION="0.7.0" +URLDOWNLOAD="%MosyleCDNFile:blah-blah-blah%" +###################################################################### +# Installation using Installomator (enter the software to install separated with spaces in the "what"-variable) +what="handbrake theunarchiver microsoftoffice365" +# Covered by Mosyle Catalog: "brave firefox googlechrome microsoftedge microsoftteams signal sublimetext vlc webex zoom" among others +###################################################################### + +## Code here + +# Mark: Condition for Installomator installation + +INSTALLED_VERSION="$(pkgutil --pkg-info $PKG_ID 2>/dev/null | grep -i "^version" | awk '{print $2}')" + +echo "Current Version: ${INSTALLED_VERSION}" + +if [[ "$TARGET_VERSION" != "$INSTALLED_VERSION" ]]; then + TMPDIR=$(mktemp -d ) + if ! cd "$TMPDIR"; then + echo "error changing directory $TMPDIR" + exit 98 + fi + NAME=$TMPDIR/$(date +%s).pkg + if ! curl -fsL "$URLDOWNLOAD" -o "$NAME"; then + echo "error downloading $URLDOWNLOAD to $NAME." + exit 97 + fi + installer -pkg "$NAME" -target / + rm -rf "$TMPDIR" +else + echo "Installomator version $INSTALLED_VERSION already installed!" +fi + + +# Mark: Start Installomator label(s) installation + +# 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 +fi + +for item in $what; 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 $?" + let errorCount++ + # exit $? + fi +done + +echo +echo "Errors: $errorCount" +echo "[$(DATE)][LOG-END]" + +exit $errorCount