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] 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