From 902175fa0944975060ff64690ba3e96cdf675515 Mon Sep 17 00:00:00 2001 From: Adam Codega Date: Thu, 21 Apr 2022 09:49:24 -0400 Subject: [PATCH 1/4] Create installInstallomator.sh --- MDM/installInstallomator.sh | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 MDM/installInstallomator.sh diff --git a/MDM/installInstallomator.sh b/MDM/installInstallomator.sh new file mode 100644 index 0000000..d6f4ed6 --- /dev/null +++ b/MDM/installInstallomator.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# This script is an MDM/management platform agnostic way to install Installomator +# The only requirement is an Internet connection. + +# Get the URL of the latest PKG From the Installomator GitHub repo +url=$(curl --silent --fail "https://api.github.com/repos/Installomator/Installomator/releases/latest" | awk -F '"' "/browser_download_url/ && /pkg\"/ { print \$4; exit }") +# Expected Team ID of the downloaded PKG +expectedTeamID="JME5BW3F3R" +exitCode=0 + +# Check for Installomator and install if not found +if [ ! -e "/usr/local/Installomator/Installomator.sh" ]; then + echo "Installomator not found. Installing." + # Create temporary working directory + workDirectory=$( /usr/bin/basename "$0" ) + tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" ) + echo "Created working directory '$tempDirectory'" + # Download the installer package + echo "Downloading Installomator package" + /usr/bin/curl --location --silent "$url" -o "$tempDirectory/Installomator.pkg" + # Verify the download + teamID=$(/usr/sbin/spctl -a -vv -t install "$tempDirectory/Installomator.pkg" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()') + echo "Team ID for downloaded package: $teamID" + # Install the package if Team ID validates + if [ "$expectedTeamID" = "$teamID" ] || [ "$expectedTeamID" = "" ]; then + echo "Package verified. Installing package Installomator.pkg" + /usr/sbin/installer -pkg "$tempDirectory/Installomator.pkg" -target / + exitCode=0 + else + echo "Package verification failed before package installation could start. Download link may be invalid. Aborting." + exitCode=1 + exit $exitCode + fi + # Remove the temporary working directory when done + echo "Deleting working directory '$tempDirectory' and its contents" + /bin/rm -Rf "$tempDirectory" +else + echo "Installomator already installed." +fi + +exit $exitCode From 3449c24508a000243c034867eaa82c7246083a6d Mon Sep 17 00:00:00 2001 From: Adam Codega Date: Thu, 21 Apr 2022 09:50:11 -0400 Subject: [PATCH 2/4] Update and rename installInstallomator.sh to InstallInstallomator.sh --- MDM/{installInstallomator.sh => InstallInstallomator.sh} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename MDM/{installInstallomator.sh => InstallInstallomator.sh} (91%) diff --git a/MDM/installInstallomator.sh b/MDM/InstallInstallomator.sh similarity index 91% rename from MDM/installInstallomator.sh rename to MDM/InstallInstallomator.sh index d6f4ed6..173f705 100644 --- a/MDM/installInstallomator.sh +++ b/MDM/InstallInstallomator.sh @@ -1,7 +1,7 @@ #!/bin/bash -# This script is an MDM/management platform agnostic way to install Installomator -# The only requirement is an Internet connection. +# This script is meant to povide the simplest MDM/management platform agnostic way to install Installomator +# The only requirement is an Internet connection # Get the URL of the latest PKG From the Installomator GitHub repo url=$(curl --silent --fail "https://api.github.com/repos/Installomator/Installomator/releases/latest" | awk -F '"' "/browser_download_url/ && /pkg\"/ { print \$4; exit }") From ae7db2621c11542cc9976bd184dedc573589571c Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Fri, 17 Jun 2022 15:49:00 +0200 Subject: [PATCH 3/4] removed absolute paths from commands --- MDM/InstallInstallomator.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/MDM/InstallInstallomator.sh b/MDM/InstallInstallomator.sh index 173f705..382ae2c 100644 --- a/MDM/InstallInstallomator.sh +++ b/MDM/InstallInstallomator.sh @@ -3,6 +3,8 @@ # This script is meant to povide the simplest MDM/management platform agnostic way to install Installomator # The only requirement is an Internet connection +export PATH=/usr/bin:/bin:/usr/sbin:/sbin + # Get the URL of the latest PKG From the Installomator GitHub repo url=$(curl --silent --fail "https://api.github.com/repos/Installomator/Installomator/releases/latest" | awk -F '"' "/browser_download_url/ && /pkg\"/ { print \$4; exit }") # Expected Team ID of the downloaded PKG @@ -13,20 +15,20 @@ exitCode=0 if [ ! -e "/usr/local/Installomator/Installomator.sh" ]; then echo "Installomator not found. Installing." # Create temporary working directory - workDirectory=$( /usr/bin/basename "$0" ) - tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" ) + workDirectory=$( basename "$0" ) + tempDirectory=$( mktemp -d ) echo "Created working directory '$tempDirectory'" # Download the installer package echo "Downloading Installomator package" - /usr/bin/curl --location --silent "$url" -o "$tempDirectory/Installomator.pkg" + curl --location --silent "$url" -o "$tempDirectory/Installomator.pkg" # Verify the download - teamID=$(/usr/sbin/spctl -a -vv -t install "$tempDirectory/Installomator.pkg" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()') + teamID=$(spctl -a -vv -t install "$tempDirectory/Installomator.pkg" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()') echo "Team ID for downloaded package: $teamID" # Install the package if Team ID validates if [ "$expectedTeamID" = "$teamID" ] || [ "$expectedTeamID" = "" ]; then echo "Package verified. Installing package Installomator.pkg" - /usr/sbin/installer -pkg "$tempDirectory/Installomator.pkg" -target / - exitCode=0 + installer -pkg "$tempDirectory/Installomator.pkg" -target / -verbose + exitCode=$? else echo "Package verification failed before package installation could start. Download link may be invalid. Aborting." exitCode=1 @@ -34,7 +36,7 @@ if [ ! -e "/usr/local/Installomator/Installomator.sh" ]; then fi # Remove the temporary working directory when done echo "Deleting working directory '$tempDirectory' and its contents" - /bin/rm -Rf "$tempDirectory" + rm -Rf "$tempDirectory" else echo "Installomator already installed." fi From 158a30b6f1fa7b41a632b04c689863b37133cd61 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Fri, 17 Jun 2022 15:50:01 +0200 Subject: [PATCH 4/4] removed unused variable --- MDM/InstallInstallomator.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MDM/InstallInstallomator.sh b/MDM/InstallInstallomator.sh index 382ae2c..9bb131f 100644 --- a/MDM/InstallInstallomator.sh +++ b/MDM/InstallInstallomator.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # This script is meant to povide the simplest MDM/management platform agnostic way to install Installomator # The only requirement is an Internet connection @@ -15,7 +15,6 @@ exitCode=0 if [ ! -e "/usr/local/Installomator/Installomator.sh" ]; then echo "Installomator not found. Installing." # Create temporary working directory - workDirectory=$( basename "$0" ) tempDirectory=$( mktemp -d ) echo "Created working directory '$tempDirectory'" # Download the installer package