Skip to content

Instantly share code, notes, and snippets.

@grahampugh
Last active December 10, 2019 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahampugh/7433aec860e3a6e4a8139c20f64fc5b8 to your computer and use it in GitHub Desktop.
Save grahampugh/7433aec860e3a6e4a8139c20f64fc5b8 to your computer and use it in GitHub Desktop.
Postinstall script to set configurations for Prism via Jamf Pro. Parameter 4 is the license key.
#!/usr/bin/python
import sys
import xml.etree.cElementTree as ET
'''
This is a postinstall script for Prism. It is used to generate the
prism-config.xml file that stores the serial number and other settings
ready for silent activation.
By Graham R Pugh
'''
def main():
'''Do the main thing'''
# path to the prism-config.xml
config_file = '/Applications/Prism.app/Contents/SharedSupport/prism-config.xml'
# Serial number is inputted as parameter 4 in Jamf
serial_number = sys.argv[4]
print "Serial number entered: %s" % serial_number
root = ET.Element("configuration")
ET.SubElement(root, "silent-activation").text = 'true'
ET.SubElement(root, "serial-number").text = serial_number
ET.SubElement(root, "check-for-updates").text = 'false'
ET.SubElement(root, "measure-units").text = 'metric'
tree = ET.ElementTree(root)
try:
tree.write(config_file, encoding="UTF-8", xml_declaration=True)
except IOError:
print "Could not write file. Is Prism installed?"
exit(-1)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment