Installing and removing addons from command line?

Hi,
I would like to add and remove addons to Firefox from the command line in an automated fashion. I am an admin and have to do this over 400 times, and I can’t do this by hand.

The first thing I need to do is to remove all addons. Am I right that it’s enough to just remove everything under $profile/extensions (e.g. ~/.mozilla/firefox/nogdglqv.myprofile/extensions) and then all the extensions will be gone? I mean normal addons, not stuff like flash or java.

Then I need to install the right extensions. How do I do this? Guides online are a bit old and there’s no official guide. Will it be ok to just drop the xpi in $profile/extensions? Some guides say you have to unpack the xpi to $profile/extensions/$gid where $gid is the gid in the xpi’s manifest. But when I look at extensions that have been installed manually (by clicking in the GUI), they’re just xpi files. What’s the right way to do this?

Other than modify what’s under $profile/extensions, do I need to do any other changes to the profile in order for the extension to become installed properly?

Thanks!

1 Like

I guess that you have already seen this Linux section (with the red alert near the head of the page):

Hi Graham,

I haven’t read this. But it goes partly in line with what I experienced. There are some missing parts i describe below. But mainly i am missing a good description of how to remove an extension. I’ll probably end up just deleting the xpi (or dir).

When you copy an addon into a profile it will start out disabled (FF says “it was installed by an external application”) and you need to enable it manually. This is pretty bad and I need to find a way to do this automatically. I’ll probably do it by modifying extensions.json. (note this behaviour might be only because i installed an extension through the gui, restarted, then removed the xpi, restarted, then moved it back in, and restarted).

Btw, it seems that WebExtensiom addons also come in xpi form and the red warning you mention doesn’t apply. (The warning says “Add-ons using the techniques described in this document are considered a legacy technology in Firefox. Don’t use these techniques to develop new add-ons. Use WebExtensions instead. If you maintain an add-on which uses the techniques described here, consider migrating it to use WebExtensions.” etc)

I was wondering if I could bring this topic up again? It’s an issue I encounter very often.