Recently I needed to update our deployed Extension Bar & like a daft person I didn’t follow Apple’s advised Extension update method..
However, past me was not that daft & had already discovered that all that is needed to “update” an existing Extension is to replace it. Which is pretty much what the below script does.
This script will search /Users/*/Library/Safari/Extensions/ for an Extension matching the regex specified at $4 & then replace with the Extension specified at $5.
This below is to be run as root & as mentioned, all that is needed is to replace the existing Extension with the new. However this Extension may be suffixed with a number, (this may have been due to my deployment methods though).
Below is example output & the script is below that:
Script result: Replacing extensions with a name matching: macmule Toolbar with extension located at /private/var/tmp/macmule Toolbar.safariextz... /private/var/tmp/macmule Toolbar.safariextz -> /Users/Administrator/Library/Safari/Extensions/macmule Toolbar-2.safariextz /private/var/tmp/macmule Toolbar.safariextz -> /Users/Administrator/Library/Safari/Extensions/macmule Toolbar.safariextz /private/var/tmp/macmule Toolbar.safariextz -> /Users/btoms/Library/Safari/Extensions/macmule Toolbar.safariextz /private/var/tmp/macmule Toolbar.safariextz -> /Users/jdoe/Library/Safari/Extensions/macmule Toolbar-2.safariextz /private/var/tmp/macmule Toolbar.safariextz -> /Users/jbloggs/Library/Safari/Extensions/macmule Toolbar.safariextz Extensions updated in 4 Home folders...