I've been given the below plist which points to a bash script.
The script is supposed to delete the installer (El capitan.app) after it has been downloaded to prevent people from upgrading to it.
It is not working and I am not sure what needs changing/tweaking, if anything, to the script. It fails to delete the downloaded installer.
I have placed the script in the location /usr/local/bin, filename blockelcapitan.sh and can also confirm that the launch dameon (stored in /Library/LaunchDaemons) is loaded as confirmed by using the command:
sudo launchctl list | grep net.
which shows a result of:
- 78 net.ORG.blockelcapitan
I need help with the script, I have no idea if it is correct or what needs adding/removing/changing.
#!/bin/bash
Version=$(sw_vers | grep ProductVersion | tail -c 7 | cut -d . -f 2)
if [[ $Version -ge 11 ]]
then
sudo launchctl unload /Library/LaunchDaemons/net.ORG.blockelcapitan.plist
sudo rm -rf /Library/LaunchDaemons/net.ORG.blockelcapitan.plist
sudo rm -rf /var/ORG/ElCapitan/
sudo rm -rf /var/db/receipts/net.ORG.pkg.BlockElCapitanLaunchDaemon.bom
sudo rm -rf /var/db/receipts/net.ORG.pkg.BlockElCapitanLaunchDaemon.plist
exit 0
fi
rm -rf /Applications/Install\ OS\ X\ El\ Capitan.app/
osascript -e 'display dialog "OS X El Capitan is not allowed on ORG computers at this time." with title "ORG Technology Notice" buttons {"OK"} default button "OK" giving up after 30'
Post-flight for installer PKG (you’ll want to use something like Packages for Mac to build a deployable .pkg):
#!/bin/bash
launchctl load -w /Library/LaunchDaemons/net.ORG.blockelcapitan.plist
Version=$(sw_vers | grep ProductVersion | tail -c 7 | cut -d . -f 2)
if [[ $Version -ge 11 ]]
then
sudo launchctl unload /Library/LaunchDaemons/net.ORG.blockelcapitan.plist
sudo rm -rf /Library/LaunchDaemons/net.ORG.blockelcapitan.plist
sudo rm -rf /var/ORG/ElCapitan/
sudo rm -rf /var/db/receipts/net.ORG.pkg.BlockElCapitanLaunchDaemon.bom
sudo rm -rf /var/db/receipts/net.ORG.pkg.BlockElCapitanLaunchDaemon.plist
exit 0
fi
Here is the actual launchdaemon itself:
<?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.ORG.blockelcapitan</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/blockelcapitan.sh</string>
</array>
<key>KeepAlive</key>
<dict>
<key>PathState</key>
<dict>
<key>/Applications/Install OS X El Capitan.app/</key>
<true/>
</dict>
</dict>
<key>OnDemand</key>
<true/>
</dict>
</plist>
rm
and theosascript
line after the first shebang! – klanomath Sep 6 '16 at 13:14