Modifying plist in ByHost folder.

ts85
New Contributor III

Hello,

I'm trying to push out Harmonic MediaGrid drivers to a number of workstations. After reboot we have to manually go into the user account and adjust two settings in the System Preferences > Harmonic MediaGrid.

I've found the plist file this is modifying when making the changes located under ~/Library/Preferences/ByHost/com.harmonicinc.MediaGrid.Preferences.5F46341C-07F2-5E51-95A7-BBA09D6B365E.plist.

What I need to add is the following:

<plist>
<dict> <key>noopendelete</key> <false/> <key>readAhead</key> <integer>12</integer> <key>singlewriter</key> <false/> <key>useInterfaces</key> <integer>1</integer>
</dict>
</plist>

Is there a way to inject or create this plist? I know the UUID comes into play also so it's probably not as easy as a drag and drop.

Thanks for any insight!

8 REPLIES 8

ts85
New Contributor III

I think I could accomplish this with the script posted here: https://jamfnation.jamfsoftware.com/discussion.html?id=4319. I guess my confusion is the plist content itself as that script should rename with the proper UUID for all users though I'm not sure how to insert those XML key/pairs.

athompson
New Contributor

I have done this with the defaults command before. Use the eval command in front of it to pass the variables correctly.

Example:
eval defaults write /Users/<user name>/Library/.../<domain UDID combo> key value

gregneagle
Valued Contributor

Don't muck about with trying to generate the UUID in the name.

Use the -currentHost option to defaults:

/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences noopendelete -bool NO
/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences readAhead -int 12
/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences singlewriter -bool NO
/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences ruseInterfaces -int 1

ts85
New Contributor III

Amazing! For some reason I didn't receive an alert to this response. This is much easier.. I had been generating a script to grab the UUID and copy it in with a for loop to the plist. This saves a lot of headache..

ts85
New Contributor III

Actually, this doesn't appear to be working when entering each manually. Should the -currentHost pull the UUID automatically?

/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences noopendelete -bool NO
/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences readAhead -int 12
/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences singlewriter -bool NO
/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences ruseInterfaces -int 1

However when scripted, Casper runs everything at the root level it doesn't modify all users, only the root account, I'd like to run it at login when a new editor signs in to a Mac Pro. They are AD bound and have an account generated under /Users/. Any ideas?

If I go on the local machine and type:

/usr/bin/defaults -currentHost write ~/Library/Preferences/ByHost/com.harmonicinc.MediaGrid.Preferences readAhead -int 12

or

/usr/bin/defaults -currentHost write com.harmonicinc.MediaGrid.Preferences readAhead -int 12

I receive an error of "Could not write domain; Exiting"

ts85
New Contributor III

I feel like I could be on the right path with this? However after running the .plist still is showing a non-current last modified date and the System Preferences do not reflect either.

#!/bin/sh

/usr/bin/defaults -currentHost write /Users/$(ls -l /dev/console | awk '{print $3}')/Library/Preferences/ByHost/com.harmonicinc.MediaGrid.Preferences noopendelete -bool NO
/usr/bin/defaults -currentHost write /Users/$(ls -l /dev/console | awk '{print $3}')/Library/Preferences/ByHost/com.harmonicinc.MediaGrid.Preferences readAhead -int 12
/usr/bin/defaults -currentHost write /Users/$(ls -l /dev/console | awk '{print $3}')/Library/Preferences/ByHost/com.harmonicinc.MediaGrid.Preferences singlewriter -bool NO
/usr/bin/defaults -currentHost write /Users/$(ls -l /dev/console | awk '{print $3}')/Library/Preferences/ByHost/com.harmonicinc.MediaGrid.Preferences ruseInterfaces -int 1

ts85
New Contributor III

Even if I make changes on one station, copy the plist, replace UUID with the new workstation UUID, replace file into ~/Library/Preferences/ByHost and kill cfprefsd the System Preferences do not seem to pick up the changes and adjust the settings.

ts85
New Contributor III

So.. I've been really digging into this for the past couple of hours...

If I run:

Casper-Test:~ admin$ defaults -currentHost write com.harmonicinc.MediaGrid.Preferences readAhead 2

I receive

Casper-Test:~ admin$ defaults -currentHost read com.harmonicinc.MediaGrid.Preferences
{
    interfaceList = "";
    readAhead = 2;
}

I then run the value I want the readAhead to be:

Casper-Test:~ admin$ defaults -currentHost write com.harmonicinc.MediaGrid.Preferences readAhead 12

And it then reflects when reading the plist:

Casper-Test:~ admin$ defaults -currentHost read com.harmonicinc.MediaGrid.Preferences
{
    interfaceList = "";
    readAhead = 12;
}

However... the changes under System Preferences remain unchanged (see attached Image).
a079fb4b48b14762ada133d99ef11456

So I reboot, and now there are two new plist files labeled:
com.harmonicinc.MediaGrid.Preferences.32001da68000.plist
com.harmonicinc.MediaGrid.Preferences.d0e1408d315a.plist
Though I'm not sure what the values 32001da68000 and d0e1408d315a relate to.. but they contain my original defaults write values.

It then keeps the original plist with the values reflecting that of what is in System Preferences..

com.harmonicinc.MediaGrid.Preferences.{UUID}.plist

It's as if it refuses to accept changes via the plist which is odd.. no other harmonicinc plists exist in /Library/Preferences or in /System. When rebooting it just assigns what I want to some random files and replaces the original settings as if nothing happened.