ACCCEM

Q: Automatic Updates via Terminal

Hello,

 

Just wondering if anyone out there has any experience customising App Store automatic updates via Terminal.

 

I do know that using the following command (softwareupdate --schedule off), will completely disable automatic updates. What I'm trying to do however, is use Terminal to customise automatic updates even further.

 

What I'd like to have done is this:

 

- Enable Automatically check for updates

-> Enable Install system data files and security updates

 

Screen Shot 2014-11-21 at 11.47.21 am.png

 

Does anyone know of a terminal command to configure automatic updates as show above? I could simply do this through the GUI but I'd rather send out the terminal command to our Mac users remotely.

 

Cheers!

Posted on Nov 20, 2014 5:51 PM

Close

Q: Automatic Updates via Terminal

  • All replies
  • Helpful answers

  • by Linc Davis,

    Linc Davis Linc Davis Nov 20, 2014 9:13 PM in response to ACCCEM
    Level 10 (207,926 points)
    Applications
    Nov 20, 2014 9:13 PM in response to ACCCEM

    As an example:

    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled YES
  • by iampob,

    iampob iampob Dec 23, 2014 10:26 AM in response to Linc Davis
    Level 1 (0 points)
    Dec 23, 2014 10:26 AM in response to Linc Davis

    Thanks Linc,

     

    That enables/disables the "Automatically check for updates" (think we can also use softwareupdate --schedule on)


    but i can't find anything to disable/enable "Install system data files and security updates"

     

    When ticking it on/off it makes no changes to /Library/Preferences/com.apple.SoftwareUpdate.plist so i'm wondering where it changes ?

     

    ACCCEM, did you have any success with this ?

     

    Thanks, Andy

  • by ACCCEM,

    ACCCEM ACCCEM Dec 23, 2014 2:07 PM in response to iampob
    Level 1 (0 points)
    Dec 23, 2014 2:07 PM in response to iampob

    Hi iampob,

     

    I had some success but it was through trial and error. I couldn't ever get a consistent result. I tried reasoning that whatever configuration was set in the App Store preferences, those changes would be subsequently written to the com.apple.SoftwareUpdate.plist file.

     

    After getting the App Store preferences set, I decided to take a peek into the plist file and noticed that some of the settings were configured while others simply were not present. In either case, here's what I did with moderate success (please note that I'm using a piece of software called "Packages" that builds distribution files):

     

    1. Configure the App Store preferences as needed

    2. Create a shell script with the following command:

     

    sudo cp -av /tmp/"com.apple.SoftwareUpdate.plist" /Library/Preferences

     

    (please note that the /tmp directory as seen above is one that I created in the "Packages" application)

     

    3. Create my distribution file with all necessary files

    4. Deploy .mpkg file that's created

     

     

     

    Alternately, you could simply copy the com.apple.SoftwareUpdate.plist file from /LibraryPreferences from the source computer (after configuration) and paste it on your target machine in the same location.

     

    This may/may not help you. I'm in the dark with it still.

  • by iampob,

    iampob iampob Jan 2, 2015 9:18 AM in response to ACCCEM
    Level 1 (0 points)
    Jan 2, 2015 9:18 AM in response to ACCCEM

    Hi Accem

     

    Thanks for the detailed response!

     

    I think this is the route i'm going to go down, this post has some really great info on some of the specifics in that Plist,

    I'm going to do some testing now, will report back.

     

    Cheers,

    Andy

  • by Barney-15E,

    Barney-15E Barney-15E Jan 2, 2015 10:23 AM in response to ACCCEM
    Level 8 (49,722 points)
    Mac OS X
    Jan 2, 2015 10:23 AM in response to ACCCEM

    Did you open the plist or run

    sudo defaults read /Library/Preferences/com.apple.SoftwareUpdate

    to see if there is a setting for that option?

     

    Also, based on that other link from iampob, do the same for the com.apple.commerce plist

     

    I'm not at a Mac to check those myself.

  • by touchdown100,

    touchdown100 touchdown100 Jan 31, 2015 1:12 PM in response to ACCCEM
    Level 1 (0 points)
    Jan 31, 2015 1:12 PM in response to ACCCEM

    I have just written an Applescript that will do just what you are asking. I have posted it here for you. It still needs some work, as in it could be shortened a bit plus some of the code could be technically better but it works.

    I had a problem whereby OS X Yosemite would not check for updates on t's own. it would only do so if I did it manually. I tried everything I could think of so finally wrote a script to do so which I then add to a calendar reminder so that on that day/time the script will run triggering the checks. The script get's the settings from the ones you set in app store settings(screen shot above)

    hope it helps

     

    -- Apple script to check for Updates in OS X Yosemite.

    -- For some reason OS X Yosemite does not do this for all people

    -- Copyright Dawson  2015 all rights and copy rights will be retained by me at all times

    -- though the user is entitled to make any edits as required

     

    -- tell finder to read the file com.apple.SoftwareUpdate.plist and copy it to a variable.

    -- Then take each variable of the file that is used to store choices the user makes as

    -- to checking, downloading and installing of updates and copy them to other variables.

    -- Then if each of the variables are TRUE get softwareupdate to perfrom that action

     

    tell application "Finder"

      set myfile to "/Library/preferences/com.apple.SoftwareUpdate.plist"

      set sourcepath to POSIX path of myfile

      do shell script "cp -r " & sourcepath's quoted form & " ~/Desktop/"

      do shell script "plutil -convert xml1 /Users/touchdown/Desktop/com.apple.SoftwareUpdate.plist"

      set myfile to "~/Desktop/com.apple.SoftwareUpdate.plist"

      set thetext to (read myfile)

     

      tell application "System Events"

      tell property list file myfile

      tell contents

      set automaticcheckenabledcopy to value of property list item "AutomaticCheckEnabled"

      if automaticcheckenabledcopy = true then do shell script "softwareupdate -l"

      set automaticdownloadcopy to value of property list item "AutomaticDownload"

      if automaticdownloadcopy = true then do shell script "softwareupdate -d"

      set configdatainstallcopy to value of property list item "ConfigDataInstall"

      if configdatainstallcopy = true then do shell script "softwareupdate -i --install -a"

      set criticalupdateinstallcopy to value of property list item "CriticalUpdateInstall"

      if criticalupdateinstallcopy = true then do shell script "softwareupdate -i --install -r"

      end tell

      end tell

      end tell

      do shell script "rm –Rf ~/Desktop/com.apple.SoftwareUpdate.plist"

     

    end tell

  • by Drew Reece,

    Drew Reece Drew Reece Jan 31, 2015 6:25 PM in response to ACCCEM
    Level 5 (7,480 points)
    Notebooks
    Jan 31, 2015 6:25 PM in response to ACCCEM

    In Terminal…

     

    osascript -e "tell application \"System Preferences\" to quit"
    sudo softwareupdate --schedule off
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool YES
    sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool YES
    


    The reason for quitting System Preferences & setting software update to off is because of how 10.10 caches the defaults system.

    See the note inside the description in the manual…

    https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/defaults.1.html

    For anyone messing with actual plist files see this tip or learn to live with failure…

    http://www.cnet.com/how-to/how-to-manually-edit-defaults-plist-files-in-maverick s/

     

    Basically don't mess with running apps & expect defaults write to work all the time, they may decide to flush their caches (I expect someone here can explain this in a more accurate way, or point to good docs - please step in).

    System Preferences or softwareupdated can overwrite your 'defaults writes', so the simplest way to make any changes is to ensure they cannot step on your toes.

     

    Does this help ACCCEM?

  • by Drew Reece,

    Drew Reece Drew Reece Jan 31, 2015 6:47 PM in response to Drew Reece
    Level 5 (7,480 points)
    Notebooks
    Jan 31, 2015 6:47 PM in response to Drew Reece

    Here are the other keys cover the checkboxes in the 'System Preferences > App Store Preferences', except I can't get 'Automatic download apps purchased on other Macs' working (it's always grey in System Preferences).

     

    com.apple.commerce.plist

    AutoUpdateRestartRequired - Install OS X updates

    AutoUpdate                           - Install App updates

    com.apple.SoftwareUpdate.plist

    AutomaticCheckEnabled      - Automatically check for updates

    AutomaticDownload             - Download Newly available updates in Background

    CriticalUpdateInstall             - Install System data files & security updates

    ConfigDataInstall                 - Automatically download apps purchased on other Macs ??? <- I can't get this working (it may be wrong)

     

     

    # TOGGLE ALL ON
    # before setting values quit system preferences & stop software update - stops deafults cache breaking 'AutomaticCheckEnabled'
    osascript -e "tell application \"System Preferences\" to quit"
    sudo softwareupdate --schedule off
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool YES
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload -bool YES
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall -bool YES
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall -bool YES
    sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool YES
    sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool NO
    sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdate -bool YES
    # See the results…
    open "/System/Library/PreferencePanes/AppStore.prefPane/"
    
    # TOGGLE ALL OFF (auto checking is on to show other prefs are toggled off)
    # before setting values quit system preferences & stop software update - stops deafults cache breaking 'AutomaticCheckEnabled'
    osascript -e "tell application \"System Preferences\" to quit"
    sudo softwareupdate --schedule off
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool YES
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload -bool NO
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall -bool NO
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall -bool NO
    sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool NO
    sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdate -bool NO
    # See the results…
    open "/System/Library/PreferencePanes/AppStore.prefPane/"
    

     

    Hope it helps someone.

  • by tetra89,

    tetra89 tetra89 Mar 10, 2015 6:12 PM in response to Drew Reece
    Level 1 (45 points)
    Mar 10, 2015 6:12 PM in response to Drew Reece

    Thanks for the info Drew. How does one retrieve such a list of relatively hidden plist commands?

  • by Drew Reece,

    Drew Reece Drew Reece Mar 10, 2015 6:39 PM in response to tetra89
    Level 5 (7,480 points)
    Notebooks
    Mar 10, 2015 6:39 PM in response to tetra89

    Either dig into the defaults command e.g.

    defaults domains

    (find the desired 'domain')

    defaults read /path/to/desired.plist

    (with lots of filtering via grep etc).

     

    Also search around for blogs & sites that list the defaults system 'hacks'… You need to figure out the reverse domain for the app in question, e.g com.apple.Finder.

     

    https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/defaults.1.html

    http://secrets.blacktree.com/

    http://www.defaults-write.com/

    http://osxdaily.com/tag/defaults/

     

    There are also quite a few server admin sites that also deal with this, since users who manage many systems usually want a way to set preferences en masse, or read/ search the scripts that crop up on github…

    https://github.com/mathiasbynens/dotfiles/blob/master/.osx

  • by macweb,

    macweb macweb Jul 6, 2016 5:57 AM in response to ACCCEM
    Level 1 (4 points)
    Jul 6, 2016 5:57 AM in response to ACCCEM

    Hi,

     

    Yosemite automatically download some updates and are ready to install.

    Can I copy those updates and use them in another Yosemite installation ?

    Where are located the updates files ?

    Thanks