Get the latest version of Mozilla Firefox by script

Asked

Viewed 75 times

0

I was making a script that searches for the latest version of Mozilla Firefox in the URL

#!/bin/bash

base_url="https://download-installer.cdn.mozilla.net/pub/firefox/releases/"
href_pattern='s/.*href="\([^"]*\).*/\1/p'

last_version=$(curl -s $base_url | sed -n $href_pattern | sort -V | tail -n 1)

echo last_url=$base_url$last_version

he is seeking as follows:

last_url=https://download-installer.cdn.mozilla.net/pub/firefox/releases//pub/firefox/releases/stub/

when you should take:

last_url=http://download-installer.cdn.mozilla.net/pub/firefox/releases/60.0b3/`

how I get the latest version folder from the same link?

  • 1

    Whenever you place code in one of your questions select it and format it with the shortcut Ctrl+K or with the button {} question editor

  • Hello. You want to know the latest version, in this case 60.B3, or just download the latest version of firefox?

  • I was first trying to get him to get the last version of Mozilla for later download..

1 answer

1


Answering your question, the following script uses the URL schema, available at the URL https://ftp.mozilla.org/pub/firefox/releases/latest-beta/README.txt, which defines how to download the latest beta version of firefox on the desired operating system and language.

The script accepts three optional arguments, operating system, language and version (stable or beta):

#!/bin/bash
# Programa para baixar ultima versao do firefox utilizando
# o esquema de URL https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest/README.txt
# uso: baixafirefox [SISTEMA_OPERACIONAL] [LINGUAGEM] [TIPO]
#      Valores das opcoes :
#               SISTEMA_OPERACIONAL = win (default), win64, osx, linux e linux64
#               LINGUAGEM = pt-BR (default), en-US, fr, es-AR etc
#               TIPO = firefox-beta-latest (default) firefox-latest
#
# exemplo 1: baixar versao beta, para linux 64 bits, em ingles:
#            $ baixafirefox linux64 en-US 
# exemplo 2: baixar versao beta, para windows em portugues (valores padrao)
#            $ baixafirefox
# exemplo 3: baixar versao estável, para windows em portugues (valores padrao)
#            $ baixafirefox win pt-BR firefox-latest
#
### VARIAVEIS
os=$1
linguagem=$2
produto=$3

### PRINCIPAL
# popular variaveis com valores padrao de sistema operacional e 
# linguagem, caso argumentos nao tenham sido passados 
[ -z $os ] && os=win
[ -z $linguagem ] && linguagem=pt-BR
[ -z $produto ] && produto=firefox-beta-latest
echo "https://download.mozilla.org/?product=$produto&os=$os&lang=$linguagem"
wget --content-disposition https://download.mozilla.org/?product=$produto\&os=$os\&lang=$linguagem

The above script is only a starting point and should be improved according to your need.

  • I tested your program and it is downloading version 59.0.1 and the current version is 60.0b5. the script I tried to show above should always look for the last available version in the url. for this reason I used that url..

  • Ok. The above link takes the latest stable version. If you want to get the latest beta, just replace the product=firefox-Latest parameter with product=firefox-beta. I will update the script and add this option

Browser other questions tagged

You are not signed in. Login or sign up in order to post.