How to learn Shell Scripting by installing Mozilla Firefox

In this sixth (6th) delivery en desdelinux.net Series "Learn Shell Scripting" we will study a Bash Shell script that allows us to automate the operation of installing the famous and useful Internet browser Mozilla Firefox, while we learn about commands, variables, routes, symbolic links, creation of shortcuts in menus and desktops, and downloads of add-ons such as regional languages ​​via terminal.

Shell scripting

As many of us already know, most of the GNU / Linux distributions based on DEBIAN/Ubuntu already have a default browser based on Mozilla Firefox (such as Iceweasel) or the very Mozilla Firefox, although most likely a version 2 and up to 10 numbers older than the current one available on the website of the Mozilla Portal, and as we already know, sometimes this may not meet our requirements for high-priority work or research.

Recall that Mozilla Firefox is Web navigator free of the Mozilla Foundation that allows us surf the Internet safely and quickly. And the Mozilla Foundation is a non-profit organization that creates all Mozilla brand products.

In addition, Mozilla Firefox Apart from being faster and more secure, than most of the others it is a completely customizable browser.

And why install Mozilla Firefox in its latest version?

Mozilla Firefox is a flagship browser, emblematic, in terms of changes and trends in browsing and viewing the Web, that is, every approximately 3 months it implements notable changes in its user interface, compatible technology applied in new websites and add-ons applied to facilitate the navigation itself. Therefore, for many it is beneficial for test application developments based on modern languages, or be able to view the most modern websites in a functional and secure way. In short, it is very useful for very experienced programmers and users. And there are times for a normal or basic user, for simple things like a Modern online game or for medium or advanced users for things like Websites with many security implementations or special embedded micro-applications like java applets. Therefore, it is advisable to keep it as updated as possible so as not to miss a good part of the web.

Therefore, have the latest version of Mozilla Firefox or a well updated one based on it, like Iceweasel, can not miss in Operating system GNU / Linux in general!

You can install Mozilla Firefox, for example, if you use a Ubuntu distribution or based on it by adding the Repositories UMST PPA (Ubuntu Mozilla Security Team) by command commands:

add-apt-repository ppa:ubuntu-mozilla-security/ppa
apt-get update
apt-get upgrade
In case you don't have it installed, search for the package name with the command command:
sudo apt search firefox
sudo apt install nombre_paquete

If you use a DEBIAN distribution or based on it by adding the Official Repositories Linux DEBIAN Mint Edition by command commands:


#####################################################################
# REPOSITORIOS OFICIALES DE LMDE BETSY
# deb http://packages.linuxmint.com/ rafaela main upstream import backport # romeo
# deb http://packages.linuxmint.com/ debian main upstream import backport # romeo
deb http://packages.linuxmint.com/ betsy main upstream import backport # romeo
deb http://extra.linuxmint.com betsy main
#
#####################################################################
aptitude update ; aptitude install linuxmint-keyring ; aptitude update ; aptitude install firefox firefox-l10n-es

Or you can update the Iceweasel browser of your Distro by adding the Iceweasel official repositories and executing the following command lines:

####################################################################
# REPOSITORIOS OFICIALES PARA ICEWEASEL
deb http://mozilla.debian.net/ jessie-backports iceweasel-release
#
#####################################################################
aptitude update ; aptitude install pkg-mozilla-archive-keyring ; aptitude update ; aptitude upgrade

In case you don't have it installed:

aptitude install iceweasel iceweasel-l10n-es-es

Comment: This publication is not intended to recommend the installation and use of "Mozilla Firefox" but demonstrate how to use Shell scripting to reproduce the process that is performed stealthily when it is installed, that is, do reverse reengineering of the automated process that is carried out when we install it via repository. This is always useful to fully understand how an application, package, software is installed in a Free Operating Systemas GNU / Linux.

Next the content to insert in the Bash Shell script or that must be executed manually for this purpose:


#!/bin/bash
#####################################################################
# MI PAÍS DE ORIGEN
#
# NOMBRE:
# VERSIÓN:
# TIPO DE PROGRAMA:
# FUNCIÓN:
# NOMBRE CÓDIGO:
# PAÍS ORIGEN:
# CREADO POR:
# EMAIL:
# NOMBRE FACEBOOK:
# PAGINA PERSONAL FACEBOOK:
# COMUNIDAD FACEBOOK:
# TWITTER:
# TELÉFONO:
# PROMOCIONADO POR:
# PAGINA WEB:
# FECHA DE LANZAMIENTO DE LA PRIMERA VERSIÓN (X.X):
# FECHA DE LANZAMIENTO DE LA VERSIÓN ACTUAL (X.X+X):
# FECHA DE ULTIMA ACTUALIZACIÓN: 24/01/2016
#####################################################################

#####################################################################
#
# Derechos de autor:
#
# Copyleft (C) 2015 Mi Nombre
#
# Licenciamiento:
#
# El Linux Post Install – Mozilla Firefox no viene con ninguna garantía. El
# Autor no se hace responsable si se al aplicarse el Sistema Operativo se
# corrompe, daña o inutiliza.
#
# El Linux Post Install – Mozilla Firefox es una aplicación de Software
# Libre, por lo tanto usted puede redistribuirlo y / o modificarlo bajo los
# términos de la Licencia Pública General de GNU publicada por la Free Software
# Foundation, ya sea la versión 3 o cualquier versión posterior, según sea de su
# preferencia.
#
# Este programa se distribuye con la esperanza de que sea útil, pero SIN NINGUNA
# GARANTÍA, incluso sin la garantía implícita de COMERCIALIZACIÓN o IDONEIDAD
# para un propósito particular. Vea la Licencia Pública General de GNU para más
# detalles.
#
# Procure obtener una copia de la Licencia Pública General de GNU para estar al
# tanto sobre lo estipulado por la misma.
#
# Consúltela en:
#
# <http://www.gnu.org/licenses/>.
######################################################################

######################################################################
# INICIO DEL MODULO DE MOZILLA FIREFOX
######################################################################
USER_NAME=`cat /etc/passwd | grep 1000 | cut -d: -f1`

HOME_USER_NAME=/home/$USER_NAME

cd $HOME_USER_NAME

rm -rf /opt/firefox*

rm -f /usr/bin/firefox*

rm -rf /usr/bin/firefox*

rm -f $HOME_USER_NAME/Escritorio/firefox.desktop

rm -f $HOME_USER_NAME/Desktop/firefox.desktop

rm -f $HOME_USER_NAME/.local/share/applications/firefox.desktop

rm -f /usr/share/applications/firefox.desktop

update-menus

######################################################################

# wget -c https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest/linux-i686/es-ES/firefox-43.0.4.tar.bz2

# wget -c https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest/linux-x86_64/es-ES/firefox-43.0.4.tar.bz2

# wget -c https://addons.mozilla.org/firefox/downloads/latest/11356/addon-11356-latest.xpi?src=dp-btn-primary
# mv addon-11356-latest.xpi?src=dp-btn-primary diccionario_en_espanol_para_venezuela-1.1.17-sm+an+tb+fn+fx.xpi

######################################################################

tar xvjf *firefox*.tar.bz2

mv -f firefox /opt/firefox

ln -f -s /opt/firefox/firefox /usr/bin/firefox

######################################################################

echo '
[Desktop Entry]
Name=Mozilla Firefox
GenericName=Web Browser
GenericName[es]=Navegador web
Comment=Navegador de Internet
Exec=/opt/firefox/firefox
Icon=/opt/firefox/browser/chrome/icons/default/default32.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Network;Application;
MimeType=x-scheme-handler/mozilla;
X-KDE-Protocols=mozilla
' > /opt/firefox/firefox.desktop

chown $USER_NAME:$USER_NAME -R /opt/firefox/

chmod 755 /opt/firefox/firefox.desktop

ln -s /opt/firefox/firefox.desktop $HOME_USER_NAME/Escritorio/firefox.desktop

chmod +x $HOME_USER_NAME/Escritorio/firefox.desktop

ln -s /opt/firefox/firefox.desktop $HOME_USER_NAME/Desktop/firefox.desktop

chmod +x $HOME_USER_NAME/Desktop/firefox.desktop

ln -s /opt/firefox/firefox.desktop $HOME_USER_NAME/.local/share/applications/firefox.desktop

ln -s /opt/firefox/firefox.desktop /usr/share/applications/firefox.desktop

su - $USER_NAME -c "firefox https://addons.mozilla.org/firefox/downloads/latest/11356/addon-11356-latest.xpi?src=dp-btn-primary" &

######################################################################

rm -f $HOME_USER_NAME/firefox*.*

rm -f $HOME_USER_NAME/.xpi

clear

su - $USER_NAME -c "xdg-open 'http://www.mi-pagina-de-prueba.com/'" &

clear

echo ''
echo ''
echo '#--------------------------------------------------------------#'
echo '#GRACIAS POR USAR ESTE SCRIPT DE INSTALACIÓN DE MOZILLA FIREFOX#'
echo '#--------------------------------------------------------------#'
echo ''
echo ''

sleep 3

######################################################################
# FINAL DEL MODULO DE MOZILLA FIREFOX
######################################################################

Note: I personally use Mozilla Firefox installed of the Linux Mint DEBIAN Edition (LMDE) 2 Repository o Iceweasel from the official repositories of the project.

In case of creating a Script (Example: mid-script-firefox.sh) with this code, I recommend manually downloading the file from Mozilla Firefox updated manually, so you should keep commented wget download lines, and place it in the path / home / my_user together with the file tar.gz de Mozilla Firefox downloaded and run it with the command command $ bash mid-script-firefox.sh . And in less than 30 seconds you will have everything functional. After this you can navigate any Website with your chosen version of your Mozilla Firefox browser.

Remember, the idea is to understand how each line by line, command by command, variable by variable works, to understand and learn Shell Scripting. So with this new post I leave you with an exciting new research assignment.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   dayane qua said

    Good title and first class content, you have taken into account the opinions of the humble users of the blog 😉
    I don't know about you but I would have a great time writing each command generating the sh script that it suggests at the end of the article or downloading and double-clicking in the pure Canonical, Inc. style of Spy-buntu or Malware Windows 10 Big Brother edition.
    Regards!

  2.   Jose Albert said

    hahahaha, that of "Spy-buntu or Malware Windows 10 Big Brother edition" you are deluxe ...

    What country are you from Dayane Qu?

  3.   tired already said

    shell scripting strips it for me. Stop screwing around with this.

  4.   Angel said

    What if the uid of the current user is not 1000?

  5.   Angel said

    Okay, but what if the current user's UID is not 1000?

  6.   dayane qua said

    Thank you? They are the names of those businesses, I think.
    I am Mexican. Excellent articles, nurturing the world of free software.
    Regards!

  7.   Carlos said

    Since when is executing commands sequentially in a text file with the sh extension considered "shell scripting"?

  8.   Jose Albert said

    Angel, if it is not 1000 it is surely 1001. Replace the last digit and that's it!

    Whatever, manually check the output of reading your created users file with the command: cat / etc / passwd.

  9.   Jose Albert said

    Carlos, so as not to get into controversy with your question in this post, my next post is to clarify your doubt and there we can talk. It will be called: Shell, Bash and Scripts: All about Shell Scripting.

    I hope that clarifies your questions about it! And then I will continue with "How to automatically install the latest version of LibreOffice from its Sources using Shell Scripting".

  10.   nosferatuxx said

    Wow .. !! This script does have more things ... !!

    Some time ago I found one that Novatila Sku posted from a site that had a post installation script for xfce with colors.
    So I took it to make myself one for Mint KDE, basically pure
    [sudo apt-get install -y package_name]
    I think mine needs to add the authoring, version control and license section.

  11.   Jose Albert said

    And look at this what I'm doing!

    LPI-SB8 Test ScreenCast (LINUX POST INSTALL - SCRIPT BICENTENARIO 8.0.0)
    (lpi_sb8_adaptation-audiovisual_2016.sh / 43Kb)

    See Screencast: https://www.youtube.com/watch?v=cWpVQcbgCyY

    1.    tr said

      Ing. Tell the owners to let you post links that we don't spam.

  12.   Jose Albert said

    Thank you all for your comments and contributions, many more advanced will come soon!