Some Simple Shell Scripts to Install Mac Apps for Intune

Here are some typical shell script codes for mac application installation

#!/bin/bash

# Check if Rosetta has been installed

if [ $(/usr/bin/pgrep oahd) ]; then 
	echo 'rosetta installed' 
else
	/usr/sbin/softwareupdate --install-rosetta --agree-to-license
fi

# Download the installer and Unzip
cd /tmp
curl -o ./xxx.zip https://xxx.com/xxx.zip
unzip -o -j -d /tmp/ xxx.zip

# Do the install for pkg installer
sudo installer -pkg /tmp/xxx.pkg -target /

# Install DMG package
# You only need the following code if if requires a manual click yes for the license, otherwise remove yes|PAGER=cat

yes | PAGER=cat  hdiutil attach /tmp/xxx.dmg
cp -rf /Volumes/xxx*.app /Applications
hdiutil detach -force  /Volumes/xxx/
# Do the cert install and trust
sudo security add-trusted-cert -d -r trustAsRoot -k /Library/Keychains/System.Keychain /tmp/ndes_cert.cer
rm /tmp/ndes_cert.cer
# Check if EasyEdit already installed with version 0.3.6
VERSION=$(defaults read /Applications/EasyEdit.app/Contents/Info.plist CFBundleShortVersionString)
echo "the current EasyEdit version is $VERSION"

if [ "$VERSION" = "0.3.6" ]; then
    echo "The installer cannot proceed, versioin is 0.3.6"
    exit 1
fi

# Close EasyEdit App
killall EasyEdit

cd /tmp
curl -o ./EasyEdit.zip https://xxx.com/EasyEdit-0.3.6-mac.zip
unzip -o -d /Applications/ EasyEdit.zip

Leave a Comment