Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to install firefox extensions for all users Post 302423828 by Narnie on Saturday 22nd of May 2010 05:16:01 PM
Old 05-22-2010
Attached (at the bottom) is a script I wrote to install extensions for all users.

Save the script (or just untarball the attachment) 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.
Hope it helps some.

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


Last edited by Narnie; 05-22-2010 at 06:24 PM..
 
All times are GMT -4. The time now is 07:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy