Silent Installation of Safari Plug-ins

spatters
New Contributor

It's pretty simple for a standard user to install plug-ins for themselves, but there might be situations when installing a needed plugin for all users might be more desirable, if only to eliminate a few calls to support. I recently worked this problem out by pushing a .safariextz file to each user's library and running a unix command to add an array to the existing Extensions.plist. When I place the command into a shell script and add it to Casper Admin, the shell script looks like this:

```

!/bin/sh

defaults write ~/Library/Safari/Extensions/Extensions.plist 'Installed Extensions' -array-add '<dict> <key>Added Non-Default Toolbar Items</key> <array/> <key>Archive File Name</key> <string>Okta Secure Web Authentication Plug-in.safariextz</string> <key>Bundle Directory Name</key> <string>Okta Secure Web Authentication Plug-in.safariextension</string> <key>Enabled</key> <true/> <key>Hidden Bars</key> <array/> <key>Removed Default Toolbar Items</key> <array/> </dict>'
```

Everything deploys properly in Casper, but the shell script doesn't actually run. It returns an exit code of 0, but the Extension.plist remains unchanged. However, if I take this same command and paste it into Unix field in Apple Remote Desktop, running it as a current user, the Extension.plist is modified perfectly and the plug-in shows up in Safari as desired. Ideally, I could use Casper instead and run this once per user at log in, which would ensure a smooth install for everyone. I see that some people have had issues installing plug-ins silently and I see others having issues running a script as the current console user. I guess I'm trying to solve both, but so far, I've been unsuccessful.

2 REPLIES 2

bentoms
Release Candidate Programs Tester

I use the below, triggered via a LaunchAgent so it runs @ every user login. (Which is great to make sure that your latest extension is installed).

I'm sure it could be modified for your needs: http://macmule.com/2012/08/01/deploying-installing-safari-toolbars/

This might help too: http://macmule.com/2012/07/31/enabling-extensions-in-safari-5-x-6-x/

jduvalmtb
Contributor

I know this has been open for a while, but for future reference - I've run into this, and most likely the defaults write is being applied to the root's plist files since the script is run as root from Casper. Start such a script with "sudo -u $3" to run as the logged in user instead of root. Just note $3 is a Casper-specific variable, so this wouldn't work in ARD or other applications.