Help with editing a plist file
Hello,
I'm new to scripting and would appreciate any help I can get.
I need to create a shell script that will modify one part of an AD plugin plist file in 10.7. The plist file contains, among other things, this part which is supposed to contain GUID's for AD security groups:
<dict>
<key>ActiveDirectory</key>
<dict>
<key>network admin groups</key>
<array/>
</dict>
I need the file to be modified to contain this, instead:
<dict>
<key>ActiveDirectory</key>
<dict>
<key>network admin groups</key>
<array>
<string>exampleGUID-1</string>
<string>exampleGUID-2</string>
</array>
</dict>
I need to modify it through a shell script or unix command so that it can be automated and run on many machines, without modifying the rest of the file that contains other data unique to each machine.
Here's what I've been playing around with... it will remove the existing entry, and create a string with value "test" properly, but I am stuck on how to create an array containing multiple strings.
#!/bin/bash
#Deletes the existing network admin groups entry
/usr/libexec/PlistBuddy -c "Delete :ActiveDirectory:'network admin groups'" /path/to/file/ourdomain.plist
#Adds entry and sets string to "test"
/usr/libexec/PlistBuddy -c "Add :ActiveDirectory:'network admin groups' string test" /path/to/file/ourdomain.plist
Anybody have suggestions for how this could be done? I'm sure this is simple for somebody out there 🙂
Thanks!
Xserve, Mac OS X (10.7.2)