#!/usr/bin/env bash # # ============================================================================= # ------------------------------------------------------------------ # Waterfox Installation Script for the Production version # ------------------------------------------------------------------ # # Author: Marcelo dos Santos Mafra # License: GNU v3 # Version 0.9.7 # Created: 2019 # # # # # # # Just installation here. SORRY! Uninstallation is a separated file. # ============================================================================= # set -o errexit set -o errtrace set -o nounset set -o pipefail #set -o xtrace ## Variables ## # The url of the download page readonly wfxpage="https://www.waterfox.net/releases/" # Gets the URL from the download page readonly wfxurl=$(\wget --quiet --output-document=- "${wfxpage}" | \grep --extended-regexp --only-matching "(http|https)://[a-zA-Z0-9./?=_-]*" | \sort --unique | \grep --max-count=1 ".bz2") # Gets the file name from the URL readonly wfxfile=$(printf "%s" "${wfxurl}" | \awk --field-separator "/" '{print $8}' | \tr --delete "\n") # Install destination readonly wfxdest="/usr/lib64/" # Symbolic link to main executable readonly wfxexec="/usr/bin/waterfox" # Desktop entry file readonly wfxdesktop="/usr/share/applications/waterfox.desktop" # Main executable readonly wfxbinpath="/usr/lib64/waterfox/waterfox" # Executable with a flag to enable high resolution screens readonly wfx_desktop_exec="env MOZ_ENABLE_WAYLAND=1 waterfox" # Desktop entry default icon. Available: default16.png default22.png default24.png default256.png default32.png default48.png readonly wfxiconpath="/usr/lib64/waterfox/browser/chrome/icons/default/default256.png" # Change to /tmp/ to automatically remove file or folders readonly tmpdir="/tmp/" ## Functions ## function wfx_available_versions() { # Gets the available versions local wfxver # Gets the production version of Waterfox from waterfox.net wfxver="$(\wget --quiet --output-document=- "${wfxpage}" | \grep --extended-regexp --only-matching "(http|https)://[a-zA-Z0-9./?=_-]*" | \grep --max-count=1 ".bz2" | \sort --unique | \awk --field-separator "/" '{print $8}' | \awk --field-separator "-" '{printf "%s %s\n", $2, $3}' | \awk '{print substr($0,1,15)}')" printf "%s" "${wfxver}" unset wfxver } function wfx_check_local_version() { local wfxwhere local message local wfxlver message="No installed version found in %s ${wfxdest}\n" # Obtains the local installed version if there is one wfxwhere=$( [[ -f "${wfxexec}" ]] && printf true || printf "" ) if [[ "${wfxwhere}" ]];then wfxlver=$( "${wfxbinpath}" --version | \grep -F "WaterfoxLimited " | \awk '{printf "%s", $3}' ) printf "The version %s of Waterfox is installed at %s" "${wfxlver}" "${wfxdest}" else printf "Waterfox is not installed on your system." fi } function wfx_get_the_drowned_fox() { local wfxfcheck # Downloads the .tar.bz2 file. Firstly, checks if file exists remotely. If file is not there or yet available to download (happened on version 56.2.10 release) exits wfxfcheck=$( \wget --spider --show-progress --quiet --server-response "${wfxurl}" 2>&1 | \head --lines=1 | \awk 'NR==1{print $2}' ) if [[ ! "${wfxfcheck}" = "200" ]];then printf "\nNo file is available for downloading! Or some other error. Leaving...\n" exit 1 else # If the file is there, it starts the download printf "\nStarting the download...\n" \wget --show-progress --continue "${wfxurl}" fi } function wfx_extract_it() { # Extracts the .tar.bz2 file to /tmp/ creating the subfolder named waterfox. # Next copies the resulting folder to /usr/lib64/ if [[ ! -d "${tmpdir}waterfox/" ]];then printf "\nExtracting: %s" "${wfxfile}" \tar --extract --verbose --file "${wfxfile}" --directory="${tmpdir}" else printf "\nDeleting: %s" "${tmpdir}waterfox/" \rm --recursive --force "${tmpdir}waterfox/" printf "\nExtracting: %s to %s" "${wfxfile}" "${tmpdir}" \tar --extract --verbose --file "${wfxfile}" --directory="${tmpdir}" fi printf "\nCopying %s to %s" "${wfxfile}" "${wfxdest}" \cp --recursive --force --update --verbose "${tmpdir}waterfox/" "${wfxdest}" } function wfx_create_desktop_file() { # Creates the waterfox.desktop file to be accessed system wide. If there is nothing already there, create one if [[ ! -f "${wfxdesktop}" ]];then printf "\nCreating the waterfox.desktop file...\n" \tee --ignore-interrupts "${wfxdesktop}" <