Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to improve my unattended script adding some Firefox addon, however I cant find the way,

Can someone help to find out how to?

Example: (Want to install adblockPlus plugin and set a new default webpage)

wget https://addons.mozilla.org/firefox/downloads/latest/1865/addon-1865-latest.xpi
firefox -silent -install-global-extension addon-1865-latest.xpi -setDefaultBrowser www.google.es

Thanks in advance.

share|improve this question
    
Added instructions to automate the installation of an addon, if you need a script let me know, its possible. –  Bruno Pereira Oct 29 '11 at 14:30
    
This is a great question now since im now strugling to find way to CLI way install Adblock package as previously on 10.04 with just apt-get install adblock-plus witch doesnt exist in 11.10 :( AND YES- we need script :) –  Kangarooo Mar 3 '12 at 11:01
add comment

3 Answers

Using your method

gksudo firefox -install-global-extension addon-1865-latest.xpi seems to do the trick for you. That will install the extension to all users on your system.

To install the extension only for your user use the extension path as an argument

firefox addon-1865-latest.xpi

You still need to click the Install button tough!

Automating the installation

Firefox does not need the addon file name but the identifier from the addon as a package name. That means that if you are planning on installing an addon without user intervention you need to extract it to a folder with the name of the addon identifier string, not the name of the addon.

The identifier string can be found on the first lines of the addon install manifest file install.rdf and it looks like this: <em:id>{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}</em:id>. Everything within the {} is the identifier.

To get an addon to work you need to extract the package, rename the folder that contains the files to the addon identifier string and place it either on the global addon folder or within the user addon folder.

Global addon install

If you want to install an extension automatically to all users in your system you need to extract it, rename the folder that contains the addon to the addon's id string and copy it to the firefox global extensions folder /usr/share/mozilla/extentions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/, anything that you use there will be called up automatic when a user opens firefox.

User specific install

If you want to install an extension automatically to just one user in your system you need to extract it, rename the folder that contains the addon to the addon's id string and copy it to the firefox user extensions folder /home/user_name/.mozilla/extentions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/ (create it if it does not exist), anything that you use there will be called up automatic when a user opens firefox.

How-to prepare an addon for automatic install - Example

Make an extensions folder in your home and download the addon in to it

mkdir ~/extensions
cd ~/extensions
wget https://addons.mozilla.org/firefox/downloads/latest/1865/addon-1865-latest.xpi

Extract it and delete the original

unzip ~/extensions/addon-1865-latest.xpi
rm ~/extensions/addon-1865-latest.xpi

Read the first line in the install.rdf file to get the addon's id (in this case it will be {d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}). and create a folder with that name

mkdir ~/extensions/{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}

Move all the files in your extensions folder into the newly created ~/extensions/{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d} and you are ready to install by moving the {d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d} folder, as described, for a local install or for a global install.

How-to set the default home page

To change your homepage without using the preferences inside firefox you have to edit ~/.mozilla/firefox/*.default/prefs.js (where *.default is a folder inside ~/.mozilla/firefox created for your user) and add this line to the end of it

user_pref("browser.startup.homepage", "http://uptechtalk.com");

or using this command

echo "user_pref("browser.startup.homepage", "http://uptechtalk.com");" >> ~/.mozilla/firefox/*.default/prefs.js

You need to do it after closing firefox or the program will overwrite the setting on exit.

If your user has not used firefox yet and you want to set the homepage for all new users (set homepage globally) use this command

echo "user_pref("browser.startup.homepage", "http://uptechtalk.com");" >> /etc/xul-ext/ubufox.js

Comments about your question

-silent does not exist, you will be prompted to install that xpi extension anyways and you have to click the button to install it;

-setDefaultBrowser will not set your homepage, it will make firefox your default browser

share|improve this answer
    
gksudo firefox -install-global-extension addon-1865-latest.xpi makes only for all new users EXEPT Guest yes? Couse i did it and guest has still no plugins. –  Kangarooo May 18 '12 at 6:45
    
install-global-extension is deprecated. –  learner Jun 6 '13 at 11:18
1  
I've often wondered about the inner workings of the extensions system, a lot of good info here, thanks! –  Madd0g Jan 23 at 1:54
    
Cheers, hope its useful somehow! –  Bruno Pereira Jan 23 at 13:07
    
If you have bunch of addon, I suggest you to use FEBE addon, it will extract all your addons into one and simplify much of your code :D –  Ooker Apr 1 at 15:57
add comment

Firefox Addons one liner- Adblock Plus, FlashBlock, Download Helper Downloading in upper order && opened all found *.xpi in firefox && removing all *.xpi for feeling nothing different done

wget https://addons.mozilla.org/firefox/downloads/latest/1865/addon-1865-latest.xpi && wget https://addons.mozilla.org/firefox/downloads/latest/433/addon-433-latest.xpi && wget https://addons.mozilla.org/firefox/downloads/latest/3006/addon-3006-latest.xpi && firefox *.xpi && rm *.xpi
share|improve this answer
add comment

Global plugins are not enabled by default, and you need to add them to the list in the prefs.js file in their profile in order for them to be enabled. A major pain for mass deployments.

Here's a sample script for when we dumped a bunch of prefs.js files from client machines up to the network and changed from IETab to IETab2, migrated their preferences, etc.

Another way is to create a user profile you like on a box, upload it to the network, then clone it across machines in Firefox\defaults\profile and all new users will inherit that profile.

`

----------------------------------------------------------------------
#!/bin/bash

pjsbase="/data/M_drive/Temp/prefsjs"

for userf in `find ${pjsbase} -maxdepth 1 -type f -name *.prefs.js -printf "%f\n"` ; do
  echo ${userf}
# add in IETab2 GUID and remove IETab GUID
  cat ${pjsbase}/${userf} | grep extensions.enabledItems | /bin/sed 's/\")/\,\{1BC9BA34-1EED-42ca-A505-6D2F1A935BBB\}\:2\.12\.21\.1\")/' | /bin/sed 's/{77b819fa-95ad-4f2c-ac7c-486b356188a9}:1.5.20090525,//' > ${pjsbase}/tmp1
  cat ${pjsbase}/tmp1 | /bin/sed 's/0\.3\.8\.[0-9]*/0\.3\.8\.4/g' > ${pjsbase}/tmp
  /bin/sed /extensions.enabledItems/d ${pjsbase}/${userf} > ${pjsbase}/tmp2
  cat ${pjsbase}/tmp2 > ${pjsbase}/${userf}.new2
  cat ${pjsbase}/tmp >> ${pjsbase}/${userf}.new2
# add in IETab2 preferences
  echo user_pref\(\"extensions.ietab2.hasRun\"\,\ true\)\; >> ${pjsbase}/${userf}.new2
  echo user_pref\(\"extensions.ietab2.ietab2PrefsMigrated\"\,\ true\)\; >> ${pjsbase}/${userf}.new2
  echo user_pref\(\"extensions.ietab2.prefsMigrated\"\,\ true\)\; >> ${pjsbase}/${userf}.new2
  echo user_pref\(\"extensions.ietab2.version\"\,\ \"2.12.21.1\"\)\; >> ${pjsbase}/${userf}.new2
  echo user_pref\(\"extensions.update.notifyUser\"\,\ false\)\; >> ${pjsbase}/${userf}.new2
# if they have a preference list then migrate it
  if [ ! `cat ${pjsbase}/${userf} | grep user_pref\(\"ietab.filterlist\" | wc -l` -eq 0 ]; then
    echo "user_pref(\"extensions.ietab2.filterlist"`cat ${pjsbase}/${userf} | grep user_pref\(\"ietab.filterlist\" | sed 's/user\_pref(\"ietab\.filterlist//'`"" >> ${pjsbase}/${userf}.new2
  fi
# make sure prefs are alphabetised
  cat ${pjsbase}/${userf}.new2 | egrep -v ^u > ${pjsbase}/${userf}.new
  cat ${pjsbase}/${userf}.new2 | egrep ^u | sort >> ${pjsbase}/${userf}.new
done

`

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.