LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-17-2010, 11:33 AM   #1
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Rep: Reputation: 17
How to install firefox extensions for all users


Hello,

I am wondering the "new way" to install firefox extensions for all users.

From https://developer.mozilla.org/En/Command_Line_Options we can see that the "old way" is no longer available.

Quote:
-install-global-extension and -install-global-theme have been removed from Gecko 1.9.2 and upwards.
I'm using the Lucid UNE to write this and note that it has these extensions installed for every user:

Quote:
Ubuntu Firefox Modifications
webfav
I have several users on many computers and would like to have certain extensions installed for them, such as xmarks, add bookmark here, coolpreview, etc.

I searched the entire root filesystem and didn't find any .xpi files.

Can someone give me an idea on how to do this? How does Ubuntu do it?

With thanks,
Narnie

Last edited by narnie; 05-22-2010 at 04:26 PM.
 
Old 05-17-2010, 04:50 PM   #2
Elv13
Member
 
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 129Reputation: 129
Look for a directory similar to this one, it may be located elsewhere, every distributions seem to name it with their own conventions. Sometime it will be mozilla/, sometime firefox/ or iceweasel/
Code:
/usr/lib/mozilla-firefox/extensions/
 
Old 05-18-2010, 01:38 PM   #3
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
A user at unix.com helped me on this one.

Take a look at
This says to unzip xpi to /usr/lib/firefox-addons/extentions.

Make sure permissions are 755 to 775 for dirs and 644 to 664 for files (recommend just setting umask to 0022 while installing).

The trick is to name the directory as the extention ID is called, which is usually something like {2JBUJUB2J4BJ262B42J2} "jibberish"

This can be found in the install.js file if there is one.

Otherwise, you have to look in the install.rdf (which is harder to parse using the shell as it is in xml).

I have a shell script that automates this process for those with install.js written, but am working on a quick learning of python xml parsing for those that don't have install.js to return the extension ID from install.rdf.

I'll post the finish product back here.[/QUOTE]
 
Old 05-22-2010, 04:22 PM   #4
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Here is a script I wrote to install extensions for all users.

Hope it helps some.

Save the script to a file (I called it add_firefox_extensions).

Place it in a directory found with

Code:
echo $PATH
My system is set up to look in $HOME/bin, so I put mine there.

make it executable with:

Code:
chmod +x add_firefox_extensions
now run it for the instructions (all you need to do is pass the xpi file) and it will do all the grunt work.

Yours,
Narnie

ps, let me know if you run into any problems.

Code:
#! /bin/bash
#


USAGE () {
    USG=\
"
___________________________________________________________________

${0##*/} [-h] XPI_FILE_TO_INSTALL

installs the xpi file to /usr/lib/firefox-addons/extensions which
will inable installation the next time the user runs firefox

-h    print help
___________________________________________________________________
"
    LC=1
    echo "$USG"
    exit
}

if [ $# -lt 1 -o "$1" = -h ] ; then USAGE ; fi 

setUp () {
    if [ ! -f $EXT ] ; then
        echo "File doesn't exist"
        exit 1
    fi
    umask 0022
    if [ -d $TMPDIR ] ; then
        (cd $TMPDIR ; sudo rm -rf *)
    else
        sudo mkdir -p "$TMPDIR"
    fi
    echo -e "\n\nworking . . .\n\n"
    sudo unzip "$EXT" -d "$TMPDIR" &> /dev/null
}

getID () {
    local IFS="
"
    FILE="`cat $TMPDIR/install.rdf`"
    for i in $FILE ; do
        if echo "$i"|grep "urn:mozilla:install-manifest" &> /dev/null ; then
            GET=true
        fi
        if [ "$GET" = true ] ; then
            if echo "$i"|grep "<em:id>" ; then
                ID=`echo "$i" | sed 's#.*<em:id>\(.*\)</em:id>.*#\1#'`
            elif echo "$i"|grep "em:id=\"" ; then
                ID=`echo "$i" | sed 's/.*em:id="\(.*\)".*/\1/'`
            fi
            if [ -n "$ID" ] ; then
                return
            fi
        fi
    done
    return 1
}

installExtention () {
    if [ -d "$EXTDIR/$ID" ] ; then
        sudo rm -rvf "$EXTDIR/$ID"
    fi
    sudo mv -vv "$TMPDIR" "$EXTDIR/$ID"
    if [ $? = 0 ] ; then
        echo -e "\n\nExtension was installed\n\n"
    else
        echo -e "\n\nError installing extension\n\n"
    fi
}

getPath () {
    (
    cd ${1%%/*}
    pwd
    )
}

cleanUp () {
    if [ -d $TMPDIR ] ; then
        sudo rm -rf $TMPDIR
    fi
    exit $1
}

EXT="$1"

EXTDIR="/usr/lib/firefox-addons/extensions"
TMPDIR="/tmp/ext"

trap "cleanUp 1" 1 2 3 15

setUp

getID

installExtention

cleanUp
 
1 members found this post helpful.
Old 07-25-2010, 11:37 AM   #5
Maelvon
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Rep: Reputation: 1
For FF 3.6.8 on Osx, file diff

Code:
diff -c add_firefox_extensions /usr/local/bin/add_firefox_extensions 
*** add_firefox_extensions	Sun Jul 25 18:13:55 2010
--- /usr/local/bin/add_firefox_extensions	Sun Jul 25 18:13:19 2010
***************
*** 1,6 ****
  #! /bin/bash
  #
! 
  
  USAGE () {
      USG=\
--- 1,8 ----
  #! /bin/bash
  #
! # http://www.linuxquestions.org/questions/linux-software-2/how-to-install-firefox-extensions-for-all-users-808367/
! # 05-22-2010, 04:22 PM
! # Narnie
  
  USAGE () {
      USG=\
***************
*** 87,93 ****
  
  EXT="$1"
  
! EXTDIR="/usr/lib/firefox-addons/extensions"
  TMPDIR="/tmp/ext"
  
  trap "cleanUp 1" 1 2 3 15
--- 89,96 ----
  
  EXT="$1"
  
! #EXTDIR="/usr/lib/firefox-addons/extensions"
! EXTDIR="/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
  TMPDIR="/tmp/ext"
  
  trap "cleanUp 1" 1 2 3 15
 
Old 07-26-2010, 02:29 PM   #6
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by Maelvon View Post
Code:
diff -c add_firefox_extensions /usr/local/bin/add_firefox_extensions 
*** add_firefox_extensions	Sun Jul 25 18:13:55 2010
--- /usr/local/bin/add_firefox_extensions	Sun Jul 25 18:13:19 2010
***************
*** 1,6 ****
  #! /bin/bash
  #
! 
  
  USAGE () {
      USG=\
--- 1,8 ----
  #! /bin/bash
  #
! # http://www.linuxquestions.org/questions/linux-software-2/how-to-install-firefox-extensions-for-all-users-808367/
! # 05-22-2010, 04:22 PM
! # Narnie
  
  USAGE () {
      USG=\
***************
*** 87,93 ****
  
  EXT="$1"
  
! EXTDIR="/usr/lib/firefox-addons/extensions"
  TMPDIR="/tmp/ext"
  
  trap "cleanUp 1" 1 2 3 15
--- 89,96 ----
  
  EXT="$1"
  
! #EXTDIR="/usr/lib/firefox-addons/extensions"
! EXTDIR="/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
  TMPDIR="/tmp/ext"
  
  trap "cleanUp 1" 1 2 3 15
Maelvon brings up a great point. My code above is platform dependent. I just double-checked that Firefox on linux (at least Ubuntu/Debian derivs) still use the folder I define above and it still is the same, so FF 3.6 shouldn't break my code.

First, I'm so pleased that someone besides myself is finding use for my code.

Secondly, many thanks to Maelvon for taking the extra step for our OS X brothers so that they might benefit. It would be nice to modify my code to test for platform (specifically OS X) and do this automatically for the user. I don't have OS X access to see what "uname -s" or "uname -o."

Would implement on Windows, too, but DOS shell is so impotent I'm not sure the same is possible.

Thanks again for the help.

Narnie
 
Old 07-27-2010, 04:39 AM   #7
Maelvon
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Rep: Reputation: 1
Version 0.2

I've done a version-0.2, based on Narnie's code. Used on Osx and Linux, don't have the time to do that for Win... It seems to work.

I've found an other great Extension that can help to deploy extension on multiples computers : http://www-archive.mozilla.org/projects/cck/firefox/

Code:
#! /bin/bash
#
# Version 0.1
#   http://www.linuxquestions.org/questions/linux-software-2/how-to-install-firefox-extensions-for-all-users-808367/
#   05-22-2010, 04:22 PM
#   Narnie
# Version 0.2
#   24-07-2010
#   Maelvon
# FF-3.6.*


function Usage()
{
  echo ""
  echo "Usage: "
  echo "    add_global_firefox_extension.sh [-hof]"
  echo ""
  echo "OPTIONS:"
  echo "    -o  linux|osx"
  echo "        Operating system (mandatory)"
  echo "    -f  /path/xpi_filename"
  echo "        path to the original xpi file to install in the operating system's global directory (mandatory)"
  echo "    -h  this usage information"
  echo ""
  echo "EXAMPLE:"
  echo "    add_global_firefox_extension.sh -o osx -f ./thesupergood.xpi"
  echo ""
  ## Usage always exits
  exit $E_OPTERROR
}

function CheckForFile()
{
  if [ ! -f ${FILENAME} ]
  then
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    echo "  Error: the file:"
    echo "      ${FILENAME}"
    echo "  Does not exist"
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    Usage
  fi
  FILE=$(basename ${FILENAME}) 
  EXTENSION=${FILE##*.} 
  XPI=${FILE%.*}
  #echo "EXTENSION = ${EXTENSION}"
  if [ "${EXTENSION}" = xpi ]
  then
    continue
  else
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    echo "  Error: ${FILENAME} is not a *.xpi file"
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    Usage
  fi
}

function CheckForOs()
{
  ## most importantly, the file must exist
  if [ "${OSNAME}" = osx ]
  then
    EXTDIR="/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
  elif [ "${OSNAME}" = linux ]
  then
    EXTDIR="/usr/lib/firefox-addons/extensions"
  else
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    echo "  Error: the operating system:"
    echo "      ${OSNAME}"
    echo "  Is not implemented, the defaults are \"osx\" or \"linux\"."
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    Usage
  fi
}

function CheckArgs()
{
  ## Process the arguments passed in
  while getopts ":o:f:h" Option
  do
    case $Option in
    o    ) OSNAME=$OPTARG ## mandatory
           #echo "OSNAME = $OSNAME"
           CheckForOs
           ;;
    f    ) FILENAME=$OPTARG ## mandatory
           ## make sure the file exists
           #echo "FILENAME = $FILENAME"
           CheckForFile
           ;;
           ## show Usage, do not use ?
           ## an unsupported/invalid option will set ? so the switch statement would
           ## never reach the default case. in order to use a default case to explain
           ## that an unsupported/invalid option was used set the "help" switch as -h
           ## or something other than -?
    h    ) Usage
           ;;
           ## default if an invalid option was entered
    *    ) echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
           echo "  Error: invalid option selected"
           echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
           Usage
    esac
  done
  ## Must at least have a file name using the -f switch
  ## check here in case only optional arguments were used
  if [ ! ${OSNAME} ]
  then
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    echo "  Error: the \"-o linux|osx\" option is mandatory"
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    Usage
  elif [ ! ${FILENAME} ]
  then
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    echo "  Error: the \"-f /path/filename\" option is mandatory"
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    Usage
  fi
}

setUp () {
    if [ ! -f ${FILENAME} ] ; then
        echo "File doesn't exist"
        exit 1
    fi
    umask 0022
    if [ -d $TMPDIR ] ; then
        (cd $TMPDIR ; sudo rm -rf *)
    else
        sudo mkdir -p "$TMPDIR"
        #cd $TMPDIR
    fi
    echo -e "\n\nworking . . .\n\n"
    sudo unzip "${FILENAME}" -d "$TMPDIR" &> /dev/null
}

getID () {
    local IFS="
"
    FILE="`cat $TMPDIR/install.rdf`"
    for i in $FILE ; do
        if echo "$i"|grep "urn:mozilla:install-manifest" &> /dev/null ; then
            GET=true
        fi
        if [ "$GET" = true ] ; then
            if echo "$i"|grep "<em:id>" ; then
                ID=`echo "$i" | sed 's#.*<em:id>\(.*\)</em:id>.*#\1#'`
            elif echo "$i"|grep "em:id=\"" ; then
                ID=`echo "$i" | sed 's/.*em:id="\(.*\)".*/\1/'`
            fi
            if echo "$i"|grep "<em:name>" ; then
                NAME=`echo "$i" | sed 's#.*<em:name>\(.*\)</em:name>.*#\1#'`
            elif echo "$i"|grep "em:name=\"" ; then
                NAME=`echo "$i" | sed 's/.*em:name="\(.*\)".*/\1/'`
            fi
            if echo "$i"|grep "<em:version>" ; then
                VERSION=`echo "$i" | sed 's#.*<em:version>\(.*\)</em:version>.*#\1#'`
            elif echo "$i"|grep "em:version=\"" ; then
                VERSION=`echo "$i" | sed 's/.*em:version="\(.*\)".*/\1/'`
            fi
            if [ -n "$ID" ] && [ -n "$NAME" ] && [ -n "$VERSION" ] ; then
                return
            fi
        fi
    done
    return 1
}

installExtension () {
    if [ -d "$EXTDIR/$ID" ] ; then
        sudo rm -rvf "$EXTDIR/$ID"
    fi
    sudo mv -vv "$TMPDIR" "$EXTDIR/$ID"
    if [ $? = 0 ] ; then
        echo -e "\n\nThe extension \"$XPI.$EXTENSION\" ($NAME - $VERSION) was globally installed\n\n"
    else
        echo -e "\n\nError installing \"$XPI.$EXTENSION\" extension\n\n"
    fi
}

getPath () {
    (
    cd ${1%%/*}
    pwd
    )
}

cleanUp () {
    if [ -d $TMPDIR ] ; then
        sudo rm -rf $TMPDIR
    fi
    exit $1
}

TMPDIR="/tmp/ff_global_xpi"

trap "cleanUp 1" 1 2 3 15

CheckArgs "${@}"

setUp

getID

installExtension

cleanUp

Last edited by Maelvon; 07-27-2010 at 08:02 AM. Reason: code
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Five Firefox Extensions for Mobile Users LXer Syndicated Linux News 0 12-11-2008 09:11 AM
Firefox 2.0.0.3 extensions for all-users elfoozo Linux - Software 1 04-08-2007 02:16 AM
Cannot install extensions in firefox ! wearetheborg Linux - Software 1 09-17-2006 10:55 AM
Cannot install Firefox Extensions adam-red Linux - Software 3 04-26-2006 04:32 PM
Preinstall Firefox Extensions for Users? CoolAJ86 Linux - Software 0 02-16-2005 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration