0

I have the following .sh script that deletes Sierra, upon download, from the App store. This applies to any user on mac osx 10.10 or 10.11.

However can someone add the code so that the app (sierra.app) actually deletes as soon as it starts downloading as opposed to when its finished downloading which is what it presently does.

In addition the osascript display message does not display once it has deleted. How can I get that to work?

Here is the script.

#!/bin/bash

Version=$(sw_vers | grep ProductVersion | tail -c 7 | cut -d . -f 2)    

if [[ $Version -ge 12 ]]
then  
launchctl unload /Library/LaunchDaemons/net.infor.sierra.plist
rm -f /Library/LaunchDaemons/net.infor.sierra.plist
rm -f /usr/local/bin/sierra.sh
exit 0

else
rm -rf /Applications/Install\ macOS\ Sierra.app/
osascript -e 'tell app "System Events" to display dialog "macOS sierra is not allowed on computers at this time." with title "Technology Notice" buttons {"OK"} default button "OK" giving up after 30'
fi

Here is the plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com    /DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.infor.sierra.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/sierra.sh</string>
</array>
<key>KeepAlive</key>
<dict>
<key>PathState</key>
<dict>
    <key>/Applications/Install macOS Sierra.app/</key>
    <true/>
</dict>
</dict>
<key>OnDemand</key>
<true/>
</dict>
</plist>
  • Not an answer, just a comment, but FWIW, instead of using three pipes and three utilities to process the output of sw_vers, i.e. sw_vers | grep ProductVersion | tail -c 7 | cut -d . -f 2, just use awk by itself to do all what grep,tail and cut are doing, e.g.: Version=$(sw_vers | awk '{FS = "."};/ProductVersion/{print $2}') – user3439894 Sep 22 '16 at 16:17
  • Daemons run without a GUI. Agents can attach to the window server. – fd0 Sep 22 '16 at 17:04
  • fd0 How come when i create a test script to make a directory called Install macOS Sierra.app not only does the .app delete but the splash message appears? – sql1 Sep 23 '16 at 8:12
1

not really an answer, but maybe a hint as to where to go next...

To catch it earlier, you'd have to intercept it at the download folder. I'd guess the folder name will be different for everybody - mine is at
/private/var/folders/nc/c83zpk8x7kd9qrxrd3nnbfym0000gn/C/com.apple.appstore

You can find it from the App Store app > Debug > Show Download Folder... if you enable the debug menu with
defaults write com.apple.appstore ShowDebugMenu -bool true

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .