Some Simple Shell Scripts to Install Mac Apps for Intune

Here are some typical shell script codes for mac application installation


# Check if Rosetta has been installed

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

# Download the installer and Unzip
cd /tmp
curl -o ./
unzip -o -j -d /tmp/

# 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/ 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

# Close EasyEdit App
killall EasyEdit

cd /tmp
curl -o ./
unzip -o -d /Applications/

Leave a Comment