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 have 5 users on an ubuntu box and I want each user to have AdBlock+ (and a few others) for both FireFox and Chrome.

Is there a way to avoid logging in as each one with GUI and starting both browsers and installing the plugins by hand?

share|improve this question

2 Answers 2

Firefox:

There is a clean way to do this by simply copying the Firefox profile from the ~/.mozilla/firefox directory of user1, which has made the profile ready (e.g. this is the account with Adblock, etc. installed) to the accounts of user2, user3, ... :

sudo mkdir -p /home/user2/.mozilla/firefox 
sudo mkdir -p /home/user3/.mozilla/firefox
sudo cp -rv /home/user1/.mozilla/firefox /home/user2/.mozilla
sudo cp -rv /home/user1/.mozilla/firefox /home/user3/.mozilla
sudo chown -R user2 /home/user2/.mozilla
sudo chown -R user3 /home/user3/.mozilla

I tested this, and it worked. An alternative is to use Firefox Sync. However, that will keep all the Bookmarks and History the same if anything changes.

Chromium:

The same technique can be used with Chromium:

sudo mkdir -p /home/user2/.config/chromium 
sudo mkdir -p /home/user3/.config/chromium
sudo cp -rv /home/user1/.config/chromium/Default/ /home/user2/.config/chromium
sudo cp -rv /home/user1/.config/chromium/Default/ /home/user3/.config/chromium
sudo chown -R user2 /home/user2/.config/chromium
sudo chown -R user3 /home/user3/.config/chromium

Chromium also has an option where you can sign in with your Google account and have all your settings, Bookmarks, and History sunc across your Chromium installations. However, as with Firefox, this might not be applicable to your needs.

share|improve this answer
    
(Before you accept that answer, do try the bit about Chromium - I tested it and had a bit of extra trouble with it, but you might not have to deal with that.) –  Richard Aug 19 '13 at 2:48
    
What would happen to the existing data in the profiles - saved passwords, bookmarks &c? –  sds Aug 19 '13 at 3:35
1  
@sds They would be overwritten, I guess searchfgold assumed the accounts were new. –  guntbert Aug 19 '13 at 9:13
    
no good then. can I copy over just some files instead of the whole profile? –  sds Aug 19 '13 at 13:45
    
If you only want addons, maybe @rajagenupula's answer would work better. –  Richard Aug 19 '13 at 16:46

There is a script which will make you to install Firefox-Add ons for all users of Ubuntu. You must read this & thats where the credit goes to.

#! /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

What you have to do means , you just have to send the required firefox xpi as input to the script.

share|improve this answer

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.