Last active
December 10, 2019 20:46
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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