Q: launchagent
Hello
Can someone help me out with displaying a message after a Launchagent and script has done its job please.
So the user has logged in and the following script deletes Sierra, upon download, from the App store. This applies to any user on mac osx 10.10 or 10.11. However once it has deleted I cannot get the osascript message to display to the user? Please help.
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/LaunchAgents/net.sierra.plist
rm -f /Library/LaunchAgents/net.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.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>
thanks
Posted on Sep 26, 2016 6:18 AM