Get the latest version of Mozilla Firefox via script

0

I was doing a script that looks 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="\([^"]*\).*//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 looking like this:

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

when should I get:

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

How do I get the last folder of the link's version?

    
asked by anonymous 14.03.2018 / 13:00

1 answer

1

Responding to your question, the following script uses the URL scheme, available at URL link , which defines how to download the latest beta of firefox in the operating system and desired 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 just a starting point and should be improved according to your needs.

    
21.03.2018 / 17:37