infmac

Q: Launchagent

Hello

 

Can someone help me out with how to ensure that a plist stays loaded after a reboot of the OS please. The script works fine but after a reboot the plsit is not loaded as confirmed by using the    sudo launchctl list   command.

 

I would add that the postflight script is :

 

#!/bin/bash

sudo launchctl load -w /Library/LaunchAgents/net.sierra.plist

 

Here is the plist that is stored at /library/launchagents.

I also enclose the script below that.

 

Many thanks.

 

<?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>Program</key>

    <string>/usr/local/bin/sierra.sh</string>

    <key>WatchPaths</key>

    <array>

        <string>/Applications</string>

    </array>

</dict>

</plist>

 

 

 

#!/bin/bash

 

if [[ -e "/Applications/Install macOS Sierra.app" ]]

then

 

        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

fi

exit 0

MacBook Pro with Retina display, OS X Yosemite (10.10.3)

Posted on Sep 28, 2016 6:04 AM