Photo Mechanic (PM) has long been the software of choice for photojournalists worldwide. It has unrivaled speed for downloading, sorting and captioning images on deadline. I have been using PM for almost 17 years and it is an essential part in the workflow of our photographers here at the newspaper.
As our staff has grown so has the need to automate installations of software. In the past we simply emailed the registration information for PM to staff as needed. Of course this is an awful practice in regards to securing our paid licenses.
Thankfully we can programmatically activate and deactivate Photo Mechanic when employees install or uninstall the program via Managed Software Center (MSC). Read on for the details.
Camera Bits added the ability to activate, deactivate and query activation status from the command line to Photo Mechanic back in March of 2014 with the release of Build 15419. I had no need for the feature at that time and forgot it existed until it came up in a forum post last year. I immediately knew I wanted to incorporate the capability into Munki.
Automating the activation and deactivation as part of the installation and removal of PM through MSC allows us to keep the registration information private as well keeping our staff from having to do it manually. It also insures that a computer is deactivated when the software is removed so we don’t exceed our license limit and run into activation failures on reinstallation.
To accomplish this we use both a postinstall_script and a preuninstall_script in the Munki PkgInfo file for Photo Mechanic.
First the postinstall_script will get executed after PM is installed by Munki. This script queries the activation status and then applies the registration if needed. Edit the parameters to substitute your company’s registration information, making sure to escape spaces.
#!/bin/bash if "/Applications/Photo Mechanic 5.app/Contents/MacOS/Photo Mechanic 5" --activated then /bin/echo "Photo Mechanic 5 is already activated, no action needed." else /bin/echo "Photo Mechanic 5 is not activated, applying registration." "/Applications/Photo Mechanic 5.app/Contents/MacOS/Photo Mechanic 5" --activate --name=Galveston\ Newspapers,\ Inc. --department=Photography --license=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX fi
Alternatively you can just run the one-line activation command on every installation/upgrade without the logic. Senior Software Engineer Kirk Baker confirmed to me that, “Activating a system that has already been activated does not increase the activation count.”
There is also an undocumented optional parameter which can be used in the activation:
--description="Description of computer"
When this parameter isn’t specified it will be automatically generated and defaults to, “Computer Name – Model – Serial Number.” This description information will be used by Camera Bits support when working with users to find older activations that can be removed from the system.
Last is the preuninstall_script which will get executed by Munki before PM is uninstalled. This script deactivates the computer before the application is removed from disk and can be used as-is.
#!/bin/bash if "/Applications/Photo Mechanic 5.app/Contents/MacOS/Photo Mechanic 5" --deactivate then /bin/echo "Photo Mechanic 5 has been deactivated." else /bin/echo "There was a problem deactivating Photo Mechanic 5." fi
Let me know if you have any questions and I’ll be happy to help.
UPDATE 1/9/20: I’ve written a new post with details on the changes needed for Photo Mechanic 6.
Pingback: Weekly News Summary for Admins — 2019-03-01 – Scripting OS X