Announcement

Collapse
No announcement yet.

Script to install traditional Firefox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Script to install traditional Firefox

    Purpose of this script

    This is a little helper script for Kubuntu™ users who want to install the traditional Firefox from Mozilla.org like Debian suggests and use it complementary to / instead of the Firefox Snap OR for users who want to install the traditional Firefox from the Mozilla Team PPA like KDE neon does and use it INSTEAD of the Firefox Snap.​
    It has been tested many times with Kubuntu™ 22.04, 23.04 and 23.10.

    I hope you find the script useful! Yours respectfully, Schwarzer Kater

    Installation and usage of this script
    1. You can download the script from here: https://gitlab.com/scripts94/kubuntu...tional-firefox
      Click on its name in the file list and on the next page use the download button on the far right side of the script name.
      OR
      Copy and paste the code of the script into a blank Kate text editor document and save it as "Kubuntu_install_traditional_Firefox.sh" to e.g. your home directory.
    2. Make the file Kubuntu_install_traditional_Firefox.sh executable in the Dolphin file manager:
      go to the directory you downloaded/saved the script to, right-click on the file and choose Properties -> Permissions -> enable Is executable -> choose OK.
      OR
      Make the file Kubuntu_install_traditional_Firefox.sh executable in the Konsole terminal emulator:
      go to the directory you downloaded/saved the script to (cd [path to]/[name of directory], e.g. cd ~/Downloads) and enter:
      chmod +x Kubuntu_install_traditional_Firefox.sh.
    3. To run the script in the Konsole terminal emulator go to the directory you downloaded/saved the script to and enter:
      ./Kubuntu_install_traditional_Firefox.sh.

    Important

    It is advised to run this script after a full upgrade of the system (either with Discover or in Konsole with sudo apt update && sudo apt full-upgrade) AND a reboot.
    • Firefox from Mozilla.org can simply be used alternatively with or without the Firefox Snap and no further actions are to be taken.
      If you choose Firefox from Mozilla.org you are asked to select your preferred language first.
      This version of Firefox behaves roughly like the ones for macOS™ or Windows™ do and updates itself independently from Discover or APT package management (and can ask you before updating - if you would prefer being asked see the Firefox settings).
    • Firefox from the Mozilla Team PPA should be used INSTEAD of the Firefox Snap.
      This script will offer you to remove the Firefox Snap if it is installed. Alternatively you could also use the get_rid_of_Snap script to disable and block Snaps completely including the Firefox Snap.
      If you choose to use the Mozilla Team PPA additionally APT pinning is applied to prefer this Firefox to the Snap version e.g. during updates.
      Updates are handled by Discover or APT package management like for the rest of your system and you could ALSO get Thunderbird from this PPA.
      Sometimes the Firefox and Thunderbird versions from the Mozilla Team PPA are not yet officially released (kind of "release candidate" versions), but so far nobody has reported any problems with them AFAIK. Mostly these versions are officially released only a few hours or days later.
      The Mozilla Team PPA and appropriate APT pinning are both respected by the reinstall_Snap_for_release-upgrade and get_rid_of_Snap scripts.

    You will be asked to choose between Firefox from either [1] Mozilla.org OR [2] the Mozilla Team PPA before the download and installation is started, but if you choose [3] to cancel the installation no changes at all are made to your system.
    Personally I prefer and RECOMMEND to install Firefox from Mozilla.org due to its versatility regarding Snap and release-upgrades.

    For some more information about what is done in detail see the comments within the script itself.

    Known bugs / issues
    • If you choose the Mozilla Team PPA with this install_traditional_Firefox script, the system package management could also want to install Thunderbird from there.
    • When I chose Firefox from Mozilla.org in rare cases the compressed binary from Mozilla's server was corrupted and one could see corresponding error messages in Konsole.
      This only occurred once or twice and only with more "exotic" language version like "English (South African) lang=en-ZA".
      The solution is to immediately press [Ctrl] [z] to abort the script, to close Konsole, to open Konsole again and to run the script again, choosing a more "common" (but nonetheless fitting) language version like "English (US) lang=en-US" instead which then has always worked fine. Afterwards you can choose your preferred language in Firefox itself.


    Other Ubuntu™-based distributions

    No other Ubuntu™-based distributions/Flavors but Kubuntu™ are officially supported.

    Due to the amount of time it would take to test this script with other distributions/Flavors I will probably also not support them in the future.

    That said the script should work with other Ubuntu™-based distributions/Flavors so far.
    Last edited by Schwarzer Kater; Oct 17, 2023, 03:56 PM. Reason: updated for 23.10
    Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
    Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

    get rid of Snap scriptreinstall Snap for release-upgrade scriptinstall traditional Firefox script

    #2
    Changelog
    • Version 1.2.3, released 2024-03-28
      - CORRECTED BUG IN CODE (removed the link from /usr/local/bin/ for CLI usage of
      Firefox from Mozilla.org as there is a conflict when the Firefox Snap is also
      installed)
    • Version 1.2.2, released 2023-10-26
      - improved summary
    • Version 1.2.1, released 2023-06-21
      - improved code​
    • Version 1.2.0, released 2023-04-25
      - ADDED FEATURE to offer removing the Firefox Snap and strongly recommend to do
      so, if Firefox from the Mozilla Team PPA is to be installed
      - cleaned up code
      - improved summary
      - improved language
      - renamed the project
    • Version 1.1.2, released 2023-04-07
      - CORRECTED BUG IN CODE (now the "invisible" placeholder files for a former
      installation from the Mozilla Team PPA are removed, if the user installs Firefox
      from Mozilla.org instead after running the "reinstall_Snap_for_release-upgrade"
      script)
      - improved code
      - improved output
    • Version 1.1.1, released 2023-04-06
      - CORRECTED BUG IN CODE (now the firefox.desktop file for Firefox from
      Mozilla.org is created in /usr/local/share/applications instead of
      /usr/share/applications - otherwise in some situations the .desktop file could
      be removed when (re)installing the Firefox Snap or release-upgrading)
      - improved summary
      - improved comments
    • Version 1.1.0, released 2023-04-03
      - ADDED FEATURE to save summary as a text file for future reference, if the
      script had changed anything
      - changed version number to semantic versioning
    • Version 290323, released 2023-03-29
      - initial public release​


    Some questions have already been answered here: https://www.kubuntuforums.net/forum/...600#post669600

    The script has been tested extensively, but I appreciate it if you report any errors you come across (concerning the coding or the English language).


    Thank you very much!​

    Code:
    #!/bin/bash
    
    ################################################################################
    #                                                                              #
    #                                                                              #
    #         $$     $$                                                $$          #
    #         $$     $$  $$$$$$$$$  $$         $$          $$$$$$$     $$          #
    #         $$     $$  $$         $$         $$         $$     $$    $$          #
    #         $$$$$$$$$  $$$$$$$$   $$         $$         $$     $$    $$          #
    #         $$     $$  $$         $$         $$         $$     $$    $$          #
    #         $$     $$  $$         $$         $$         $$     $$                #
    #         $$     $$  $$$$$$$$$  $$$$$$$$$  $$$$$$$$$   $$$$$$$     $$          #
    #                                                                              #
    #                                                                              #
    # This is a little helper script for Kubuntu™ users who want to install the    #
    # traditional Firefox from Mozilla.org like Debian suggests and use it         #
    # complementary to / instead of the Firefox Snap OR for users who want to      #
    # install the traditional Firefox from the Mozilla Team PPA like KDE neon does #
    # and use it INSTEAD of the Firefox Snap.                                      #
    # It has been tested many times with Kubuntu™ 22.04, 23.04 and 23.10.          #
    #                                                                              #
    # -> IMPORTANT:                                                                #
    #    It is advised to run this script after a full upgrade of the system       #
    #    (either with Discover or in Konsole with "sudo apt update && sudo apt     #
    #    full-upgrade") AND a reboot.                                              #
    #                                                                              #
    # -> Firefox from Mozilla.org can simply be used alternatively with or without #
    #    the Firefox Snap and no further actions are to be taken.                  #
    #    If you choose Firefox from Mozilla.org you are asked to select your       #
    #    preferred language first.                                                 #
    #    This version of Firefox behaves roughly like the ones for macOS™ or       #
    #    Windows™ do and updates itself independently from Discover or APT package #
    #    management (and can ask you before updating - if you would prefer being   #
    #    asked see the Firefox settings).                                          #
    #                                                                              #
    # -> Firefox from the Mozilla Team PPA should be used INSTEAD of the Firefox   #
    #    Snap. This script will offer you to remove the Firefox Snap if it is      #
    #    installed. Alternatively you could also use the "get_rid_of_Snap" script  #
    #    to disable and block Snaps completely including the Firefox Snap.         #
    #    If you choose to use the Mozilla Team PPA additionally APT pinning is     #
    #    applied to prefer this Firefox to the Snap version e.g. during updates.   #
    #    Updates are handled by Discover or APT package management like for the    #
    #    rest of your system and you could ALSO get Thunderbird from this PPA.     #
    #    Sometimes the Firefox and Thunderbird versions from the Mozilla Team PPA  #
    #    are not yet officially released (kind of "release candidate" versions),   #
    #    but so far nobody has reported any problems with them AFAIK. Mostly these #
    #    versions are officially released only a few hours or days later.          #
    #    The Mozilla Team PPA and appropriate APT pinning are both respected by    #
    #    the "reinstall_Snap_for_release-upgrade" and "get_rid_of_Snap" scripts.   #
    #                                                                              #
    # You will be asked to choose between Firefox from either [1] Mozilla.org or   #
    # [2] the Mozilla Team PPA before the download and installation is started,    #
    # but if you choose [3] to cancel the installation no changes at all are made  #
    # to your system                                                               #.
    # Personally I prefer and RECOMMEND to install Firefox from Mozilla.org due to #
    # its versatility regarding Snap and release-upgrades.                         #
    #                                                                              #
    # For some more information about what is done in detail see the comments      #
    # within this script.                                                          #
    #                                                                              #
    # My scripts are in no way associated with Canonical™, Ubuntu™ or Kubuntu™.    #
    # This script comes with ABSOLUTELY NO WARRANTY OF ANY KIND.                   #
    # It may be used, shared, copied and modified freely.                          #
    #                                                                              #
    # You can download my scripts from here: https://gitlab.com/scripts94          #
    #                                                                              #
    # I hope you find the script useful! Yours respectfully, Schwarzer Kater       #
    #                                                                              #
    ################################################################################
    
    versionnr="1.2.3"
    
    ########
    ## During this session let's make sure no "exotic" or interfering aliases are
    ## set for commands used in this script
    ########
    unalias clear 2> /dev/null
    unalias echo 2> /dev/null
    unalias read 2> /dev/null
    unalias true 2> /dev/null
    unalias cat 2> /dev/null
    unalias grep 2> /dev/null
    unalias command 2> /dev/null
    unalias firefox 2> /dev/null
    unalias printf 2> /dev/null
    unalias sed 2> /dev/null
    unalias wget 2> /dev/null
    unalias tar 2> /dev/null
    unalias sudo 2> /dev/null
    unalias test 2> /dev/null
    unalias rm 2> /dev/null
    unalias ln 2> /dev/null
    unalias tee 2> /dev/null
    unalias kbuildsycoca5 2> /dev/null
    unalias update-alternatives 2> /dev/null
    unalias add-apt-repository 2> /dev/null
    unalias apt-get 2> /dev/null
    unalias snap 2> /dev/null
    
    ########
    ## Display purpose of this script
    ########
    clear
    echo -e "########"
    echo -e "## This is a little helper script for Kubuntu™ users who want to install the"
    echo -e "## traditional Firefox from Mozilla.org like Debian suggests and use it"
    echo -e "## complementary to / instead of the Firefox Snap OR for users who want to"
    echo -e "## install the traditional Firefox from the Mozilla Team PPA like KDE neon does"
    echo -e "## and use it INSTEAD of the Firefox Snap."
    echo -e "## It has been tested many times with Kubuntu™ 22.04, 23.04 and 23.10."
    echo -e "##"
    echo -e "## -> IMPORTANT:"
    echo -e "##    It is advised to run this script after a full upgrade of the system"
    echo -e "##    (either with Discover or in Konsole with \"sudo apt update && sudo apt"
    echo -e "##    full-upgrade\") AND a reboot."
    echo -e "## -> Firefox from Mozilla.org can simply be used alternatively with or without"
    echo -e "##    the Firefox Snap and no further actions are to be taken."
    echo -e "##    If you choose Firefox from Mozilla.org you are asked to select your"
    echo -e "##    preferred language first."
    echo -e "##    This version of Firefox behaves roughly like the ones for macOS™ or"
    echo -e "##    Windows™ do and updates itself independently from Discover or APT package"
    echo -e "##    management (and can ask you before updating - if you would prefer being"
    echo -e "##    asked see the Firefox settings)."
    echo -e "## -> Firefox from the Mozilla Team PPA should be used INSTEAD of the Firefox"
    echo -e "##    Snap. This script will offer you to remove the Firefox Snap if it is"
    echo -e "##    installed. Alternatively you could also use the \"get_rid_of_Snap\" script"
    echo -e "##    to disable and block Snaps completely including the Firefox Snap."
    echo -e "##    If you choose to use the Mozilla Team PPA additionally APT pinning is"
    echo -e "##    applied to prefer this Firefox to the Snap version e.g. during updates."
    echo -e "##    Updates are handled by Discover or APT package management like for the"
    echo -e "##    rest of your system and you could ALSO get Thunderbird from this PPA."
    echo -e "##    Sometimes the Firefox and Thunderbird versions from the Mozilla Team PPA"
    echo -e "##    are not yet officially released (kind of \"release candidate\" versions),"
    echo -e "##    but so far nobody has reported any problems with them AFAIK. Mostly these"
    echo -e "##    versions are officially released only a few hours or days later."
    echo -e "##    The Mozilla Team PPA and appropriate APT pinning are both respected by"
    echo -e "##    the \"reinstall_Snap_for_release-upgrade\" and \"get_rid_of_Snap\" scripts."
    echo -e "##"
    echo -e "## You will be asked to choose between Firefox from either [1] Mozilla.org or"
    echo -e "## [2] the Mozilla Team PPA before the download and installation is started,"
    echo -e "## but if you choose [3] to cancel the installation no changes at all are made"
    echo -e "## to your system."
    echo -e "## Personally I prefer and RECOMMEND to install Firefox from Mozilla.org due to"
    echo -e "## its versatility regarding Snap and release-upgrades."
    echo -e "## For some more information about what is done in detail see the comments"
    echo -e "## within the script itself."
    echo -e "##"
    echo -e "## This script comes with ABSOLUTELY NO WARRANTY OF ANY KIND."
    echo -e "## It may be used, shared, copied and modified freely."
    echo -e "##"
    echo -e "## I hope you find the script useful! Yours respectfully, Schwarzer Kater"
    echo -e "########\n"
    read -p "Press [Enter] to continue, press [Ctrl] [c] to exit. "
    
    ########
    ## Install the traditional Firefox from Mozilla.org like Debian suggests - see:
    ## https://wiki.debian.org/Firefox#From_Mozilla_binaries
    ## OR
    ## install the traditional Firefox from the Mozilla Team PPA like KDE neon does
    ## and give option to remove the Firefox Snap
    ########
    inff=0
    rmffsnap=0
    
    echo -e "\n########\n## Do you want to:\n## [1] Download and install the latest stable Firefox from Mozilla.org like\n##     Debian suggests?\n##     OR\n## [2] Add the Mozilla Team PPA and download and install the latest Firefox from\n##     there like KDE neon does (including APT pinning to prefer this Firefox)?"
    if snap list firefox &> /dev/null ; then echo -e "##     You will also be offered to remove the Firefox Snap which is strongly\n##     recommended for Firefox from the Mozilla Team PPA!" ; fi
    echo -e "##     OR\n## [3] Cancel the download and installation?\n########"
    
    while true
    do
        read -p "[1], [2] or [3] " choice
        if [[ "${choice}" = "1" ]]
        then
            # Test if traditional Firefox is still installed in 20.04
            if cat /etc/os-release | grep -Ei "(^|\s)VERSION=(|\s|\"|\s\")20.04" &> /dev/null && [[ -d "/usr/lib/firefox" ]] && command -v firefox &> /dev/null
            then
                echo -e "\n########\n## Traditional Firefox seems to already be installed -> not changing anything …\n########"
                break
            # Test if traditional Firefox is installed to /opt or from a PPA
            elif [[ -x "/opt/firefox/firefox" && $(command -v firefox) ]] || [[ -d "/usr/lib/firefox" && $(command -v firefox) ]]
            then
                echo -e "\n########\n## Traditional Firefox seems to already be installed to /opt or from a PPA\n## -> not changing anything …\n########"
                break
            else
                # Choose from a list of languages and download latest stable Firefox
                # in the chosen language to $HOME - see:
                # https://ftp.mozilla.org/pub/firefox/releases/latest/README.txt
                echo
                PS3="$(printf '\nChoose your preferred language for Firefox: ')"
                select languagesel in "Acholi lang=ach" "Afrikaans lang=af" "Albanian lang=sq" "Arabic lang=ar" "Aragonese lang=an" "Armenian lang=hy-AM" "Assamese lang=as" "Asturian lang=ast" "Azerbaijani lang=az" "Basque lang=eu" "Belarusian lang=be" "Bengali (Bangladesh) lang=bn-BD" "Bengali (India) lang=bn-IN" "Bosnian lang=bs" "Breton lang=br" "Bulgarian lang=bg" "Catalan lang=ca" "Chinese (Simplified) lang=zh-CN" "Chinese (Traditional) lang=zh-TW" "Croatian lang=hr" "Czech lang=cs" "Danish lang=da" "Dutch lang=nl" "English (British) lang=en-GB" "English (South African) lang=en-ZA" "English (US) lang=en-US" "Esperanto lang=eo" "Estonian lang=et" "Finnish lang=fi" "French lang=fr" "Frisian lang=fy-NL" "Fulah lang=ff" "Gaelic (Scotland) lang=gd" "Galician lang=gl" "German lang=de" "Greek lang=el" "Gujarati (India) lang=gu-IN" "Hebrew lang=he" "Hindi (India) lang=hi-IN" "Hungarian lang=hu" "Icelandic lang=is" "Indonesian lang=id" "Irish lang=ga-IE" "Italian lang=it" "Kannada lang=kn" "Kazakh lang=kk" "Khmer lang=km" "Korean lang=ko" "Latvian lang=lv" "Ligurian lang=lij" "Lithuanian lang=lt" "Lower Sorbian lang=dsb" "Macedonian lang=mk" "Maithili lang=mai" "Malay lang=ms" "Malayalam lang=ml" "Marathi lang=mr" "Norwegian (Bokmål) lang=nb-NO" "Norwegian (Nynorsk) lang=nn-NO" "Oriya lang=or" "Persian lang=fa" "Polish lang=pl" "Portuguese (Brazilian) lang=pt-BR" "Portuguese (Portugal) lang=pt-PT" "Punjabi (India) lang=pa-IN" "Romanian lang=ro" "Romansh lang=rm" "Russian lang=ru" "Serbian lang=sr" "Sinhala lang=si" "Slovak lang=sk" "Slovenian lang=sl" "Songhai lang=son" "Spanish (Argentina) lang=es-AR" "Spanish (Chile) lang=es-CL" "Spanish (Mexico) lang=es-MX" "Spanish (Spain) lang=es-ES" "Swedish lang=sv-SE" "Tamil lang=ta" "Telugu lang=te" "Thai lang=th" "Turkish lang=tr" "Ukrainian lang=uk" "Upper Sorbian lang=hsb" "Uzbek lang=uz" "Vietnamese lang=vi" "Welsh lang=cy" "Xhosa lang=xh"
                do
                    if [[ $REPLY -ge 1 && $REPLY -le 88 ]]
                    then
                        languagename="$(echo "${languagesel}" | sed 's/ lang.*$//')"
                        languagecode="$(echo "${languagesel}" | sed 's/^.* //')"
                        echo -e "\n########\n## -> Downloading ${languagename} version of Firefox from Mozilla.org …\n########\n" && wget -O "$HOME/firefox-latest-stable.tar.bz2" "https://download.mozilla.org/?product=firefox-latest&os=linux64&${languagecode}"
                        break
                    else
                        echo -e "\n-> Please enter a valid number [1-88]!"
                    fi
                done
                
                # Decompress the downloaded Firefox archive
                echo -e "########\n## -> Decompressing the Firefox archive …\n########\n" && tar xjf "$HOME/firefox-latest-stable.tar.bz2" -C "$HOME"
    
                # Install Firefox to /opt
                echo -e "########\n## -> Installing Firefox from Mozilla.org to /opt …\n########\n" && sudo mv "$HOME/firefox" /opt
    
                # Clean up: remove the dowloaded Firefox archive from $HOME again
                if test -e "$HOME/firefox-latest-stable.tar.bz2" ; then echo -e "\n########\n## -> Cleaning up …\n########\n" && rm -f "$HOME/firefox-latest-stable.tar.bz2" ; fi
    
                # Create firefox.desktop in /usr/local/share/applications to give
                # all users access to the new Firefox via application menu (don't
                # use /usr/share/applications - otherwise the .desktop file could be
                # removed when (re)installing the Firefox Snap or release-upgrading)
                echo -e "########\n## -> Writing .desktop file to /usr/local/share/applications/firefox.desktop :\n########\n"
                # Create /usr/local/share/applications before, if it doesn't exit
                if ! test -d "/usr/local/share/applications" ; then sudo mkdir /usr/local/share/applications ; fi
                echo -e "[Desktop Entry]\nName=Firefox from Mozilla.org\nComment=Browse the World Wide Web\nGenericName=Web Browser\nKeywords=Internet;WWW;Browser;Web;Explorer\nExec=/opt/firefox/firefox %u\nTerminal=false\nType=Application\nIcon=/opt/firefox/browser/chrome/icons/default/default128.png\nCategories=Network;WebBrowser;\nMimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;\nStartupNotify=true\nActions=Private;\n\n[Desktop Action Private]\nExec=/opt/firefox/firefox --private-window %u\nName=Open in private mode\n" | sudo tee /usr/local/share/applications/firefox.desktop
    
                # Rebuild the KDE Plasma application menu index as sometimes this
                # helps when the new Firefox does not show properly (if the Firefox
                # Snap is additionally installed)
                if command -v kbuildsycoca5 &> /dev/null ; then kbuildsycoca5 &> /dev/null ; fi
    
                # Make the new Firefox the main application for www-browser
                sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /opt/firefox/firefox 200 && sudo update-alternatives --set x-www-browser /opt/firefox/firefox
    
                # Remove the "invisible" placeholder files for a former installation
                # from the Mozilla Team PPA, if the user now wants to use
                # Mozilla.org instead after running the
                # "reinstall_Snap_for_release-upgrade" script.
                if [[ -x "/opt/firefox/firefox" && $(command -v firefox) ]] && test -f "$HOME/.mtppa-placeholder" ; then rm -f "$HOME/.mtppa-placeholder" ; fi
                if [[ -x "/opt/firefox/firefox" && $(command -v firefox) ]] && test -f "$HOME/.mtppa-ffpin-placeholder" ; then rm -f "$HOME/.mtppa-ffpin-placeholder" ; fi
                if [[ -x "/opt/firefox/firefox" && $(command -v firefox) ]] && test -f "$HOME/.mtff-placeholder" ; then rm -f "$HOME/.mtff-placeholder" ; fi
    
                inff=1
                break
            fi
        elif [[ "${choice}" = "2" ]]
        then
            # Test if traditional Firefox is still installed in 20.04
            if cat /etc/os-release | grep -Ei "(^|\s)VERSION=(|\s|\"|\s\")20.04" &> /dev/null && [[ -d "/usr/lib/firefox" ]] && command -v firefox &> /dev/null
            then
                echo -e "\n########\n## Traditional Firefox seems to already be installed -> not changing anything …\n########"
                break
            # Test if traditional Firefox is installed to /opt or from a PPA
            elif [[ -x "/opt/firefox/firefox" && $(command -v firefox) ]] || [[ -d "/usr/lib/firefox" && $(command -v firefox) ]]
            then
                echo -e "\n########\n## Traditional Firefox seems to already be installed to /opt or from a PPA\n## -> not changing anything …\n########"
                break
            else
                # Give option to remove the Firefox Snap, if it is installed
                if snap list firefox &> /dev/null
                then
                    echo -e "\n########\n## -> Do you want to remove the Firefox Snap as strongly recommended?\n########"
                    while true
                    do
                        read -p "[y/n] " ffsnap
                        if [[ "${ffsnap}" = [Yy] ]]
                        then
                            echo -e "\n########\n## -> Removing the Firefox Snap …\n########\n" && sudo snap remove --purge firefox && rmffsnap=1
                            break
                        elif [[ "${ffsnap}" = [Nn] ]]
                        then
                            break
                        fi
                    done
                fi
                # Add the Mozilla Team PPA
                echo -e "\n########\n## -> Adding the Mozilla Team PPA …\n########\n"
                sudo add-apt-repository -y ppa:mozillateam/ppa
    
                # Remove placeholder file from $HOME, if there is a leftover from
                # running the "reinstall_Snap_for_release-upgrade" script before
                if test -f "$HOME/.mtppa-placeholder" ; then rm -f "$HOME/.mtppa-placeholder" ; fi
    
                # Prioritise the new Firefox from the Mozilla Team PPA by APT
                # pinning in /etc/apt/preferences.d like KDE neon does
                echo -e "\n########\n## -> Writing the following to /etc/apt/preferences.d/mtppa-ffpin.pref :\n########\n"
                echo -e "# To prefer installing and updating Firefox from the Mozilla Team PPA to the\n# Snap version, this file prioritises those Firefox packages.\n\nPackage: firefox\nPin: release o=LP-PPA-mozillateam\nPin-Priority: 550\n\nPackage: firefox-*\nPin: release o=LP-PPA-mozillateam\nPin-Priority: 550\n\nPackage: firefox-locale-*\nPin: release o=LP-PPA-mozillateam\nPin-Priority: 550\n" | sudo tee /etc/apt/preferences.d/mtppa-ffpin.pref
    
                # Remove placeholder file from $HOME, if there is a leftover from
                # running the "reinstall_Snap_for_release-upgrade" script before
                if test -f "$HOME/.mtppa-ffpin-placeholder" ; then rm -f "$HOME/.mtppa-ffpin-placeholder" ; fi
                sudo apt-get update
    
                # Install Firefox from the Mozilla Team PPA
                echo -e "\n########\n## -> Installing Firefox from the Mozilla Team PPA …\n########\n"
                sudo apt-get install -t 'o=LP-PPA-mozillateam' -y firefox
    
                # Remove placeholder file from $HOME, if there is a leftover from
                # running the "reinstall_Snap_for_release-upgrade" script before
                if test -f "$HOME/.mtff-placeholder" ; then rm -f "$HOME/.mtff-placeholder" ; fi
    
                # Rebuild the KDE Plasma application menu index as sometimes this
                # helps when the new Firefox does not show properly (if the Firefox
                # Snap is additionally installed)
                if command -v kbuildsycoca5 &> /dev/null ; then kbuildsycoca5 &> /dev/null ; fi
    
                inff=2
                break
            fi
        elif [[ "${choice}" = "3" ]]
        then
            echo -e "\n########\n## You have canceled the download and installation of the traditional Firefox\n## -> not changing anything …\n########"
            break
        fi
    done
    
    ########
    ## Report what has been done
    ########
    summary_first="\n########\n## -> SUMMARY:"
    summary_snap="## -> Be aware that the Firefox Snap is still additionally installed!"
    summary_last="## Have a nice day and enjoy your new Firefox and Kubuntu™.\n########\n"
    savesummary=0
    
    if [[ ${inff} = 1 ]]
    then
        # Tell that Firefox has been installed from Mozilla.org
        echo -e "${summary_first}"
        echo -e "## Firefox has been installed from Mozilla.org to /opt."
        echo -e "## You can find it in your application menu under \"Internet\"."
        if snap list firefox &> /dev/null ; then echo -e "${summary_snap}" ; fi
        echo -e "${summary_last}"
        savesummary=1
    elif [[ ${inff} = 2 ]]
    then
        # Tell that Firefox has been installed from the Mozilla Team PPA
        echo -e "${summary_first}"
        echo -e "## Firefox has been installed from the Mozilla Team PPA and APT pinning to\n## prefer this Firefox has been applied."
        if [[ ${rmffsnap} = 1 ]] ; then echo -e "## The Firefox Snap has been removed from your system." ; fi
        if snap list firefox &> /dev/null ; then echo -e "${summary_snap}" ; fi
        if snap list firefox &> /dev/null ; then echo -e "##    (You SHOULD remove it with \"sudo snap remove firefox\".)" ; fi
        echo -e "## -> When you release-upgrade to the next main Kubuntu™ version (e.g. from"
        echo -e "##    22.04 LTS to 23.04) you SHOULD manually remove the APT pinning for Firefox"
        echo -e "##    from /etc/apt/preferences.d BEFORE - the file is named \"mtppa-ffpin.pref\"!"
        echo -e "## -> You will also have to reapply the APT pinning for this Firefox and add the"
        echo -e "##    Mozilla Team PPA again AFTER a release-upgrade as the *Ubuntu™"
        echo -e "##    release-upgrade automatically removes third party PPAs!"
        echo -e "## -> If you want to get rid of Snap entirely as well after as before a release-"
        echo -e "##    upgrade, the \"get_rid_of_Snap\" and \"reinstall_Snap_for_release-upgrade\""
        echo -e "##    scripts will take care of both of those Firefox-related necessities for"
        echo -e "##    you."
        echo -e "${summary_last}"
        savesummary=1
    else
        # Tell that nothing has changed
        echo -e "${summary_first}"
        echo -e "## The script has made no changes at all to your system!"
        echo -e "## Have a nice day and enjoy Kubuntu™.\n########\n"
    fi
    
    ########
    ## Give option to save the summary, if the script has changed anything
    ########
    appendix="$(date +"%Y-%m-%d_%H:%M")"
    
    if [[ ${savesummary} = 1 ]]
    then
        echo -e "########\n## -> Do you want to save this summary for future reference?\n########"
        while true
        do
            read -p "[y/n] " wantsave
            if [[ "${wantsave}" = [Yy] ]] && [[ ${inff} = 1 ]]
            then
                # Save to text file that Firefox has been installed from Mozilla.org
                echo -e "${summary_first}" > "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "## Firefox has been installed from Mozilla.org to /opt." >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "## You can find it in your application menu under \"Internet\"." >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                if snap list firefox &> /dev/null ; then echo -e "${summary_snap}" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt" ; fi
                echo -e "${summary_last}" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "Script version used: ${versionnr}" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "\n########\n## -> The summary of what has been done by this script was saved to:\n##    $HOME/install_traditional_Firefox-SUMMARY_${appendix}\n########\n"
                break
            elif [[ "${wantsave}" = [Yy] ]] && [[ ${inff} = 2 ]]
            then
                # Save to text file that Firefox has been installed from the Mozilla
                # Team PPA
                echo -e "${summary_first}" > "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "## Firefox has been installed from the Mozilla Team PPA and APT pinning to\n## prefer this Firefox has been applied." >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                if [[ ${rmffsnap} = 1 ]] ; then echo -e "## The Firefox Snap has been removed from your system." >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt" ; fi
                if snap list firefox &> /dev/null ; then echo -e "${summary_snap}" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt" ; fi
                if snap list firefox &> /dev/null ; then echo -e "##    (You SHOULD remove it with \"sudo snap remove firefox\".)" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt" ; fi
                echo -e "## -> When you release-upgrade to the next main Kubuntu™ version (e.g. from" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "##    22.04 LTS to 23.04) you SHOULD manually remove the APT pinning for Firefox" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "##    from /etc/apt/preferences.d BEFORE - the file is named \"mtppa-ffpin.pref\"!" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "## -> You will also have to reapply the APT pinning for this Firefox and add the" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "##    Mozilla Team PPA again AFTER a release-upgrade as the *Ubuntu™" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "##    release-upgrade automatically removes third party PPAs!" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "## -> If you want to get rid of Snap entirely as well after as before a release-" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "##    upgrade, the \"get_rid_of_Snap\" and \"reinstall_Snap_for_release-upgrade\"" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "##    scripts will take care of both of those Firefox-related necessities for" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "##    you." >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "${summary_last}" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "Script version used: ${versionnr}" >> "$HOME/install_traditional_Firefox-SUMMARY_${appendix}.txt"
                echo -e "\n########\n## -> The summary of what has been done by this script was saved to:\n##    $HOME/install_traditional_Firefox-SUMMARY_${appendix}\n########\n"
                break
            elif [[ "${wantsave}" = [Nn] ]]
            then
                echo
                break
            fi
        done
    fi
    Last edited by Schwarzer Kater; Yesterday, 05:18 AM. Reason: update to version 1.2.3
    Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
    Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

    get rid of Snap scriptreinstall Snap for release-upgrade scriptinstall traditional Firefox script

    Comment


    • GreyGeek
      GreyGeek commented
      Editing a comment
      The bash foo is strong in this one!
      ~Yoda

    #3
    I recommend De-Snapping your install prior to running this: https://www.kubuntuforums.net/forum/...et-rid-of-snap

    Please Read Me

    Comment


    • GreyGeek
      GreyGeek commented
      Editing a comment
      For sure!
      And even if you don't use the script!

    #4
    -> Firefox from Mozilla.org can be used with or without Snap easily, regardless the Kubuntu version or if you want to release-upgrade or not.


    -> For Firefox from the Mozilla Team PPA I indeed strongly recommend to remove Snap - either do it by the given option in this script or use the "get_rid_of_Snap" and "reinstall_Snap_for_release-upgrade" scripts (they will automatically take care of everything "Firefox from the Mozilla Team PPA"-related for you).

    But one could also use Firefox from the Mozilla Team PPA​ additionally to the Firefox Snap version or Snap in general.
    One of the problems then are the conflicting entries/.desktop files for the (KDE) application menu…
    Also it gets a bit more complicated when you do a release-upgrade (due to the necessary manual removal of APT pinning for Firefox before and re-enabling of the Mozilla Team PPA and reapplying of the Firefox APT pinning and reinstallation after the release-upgrade).

    If one wants to keep using Snap and manually removes the APT pinning for Firefox from the Mozilla Team PPA and deinstalls Firefox from the Mozilla Team PPA before the release-upgrade, the three necessary steps after the release-upgrade can be done with this "install_traditional_Firefox" script again.
    Last edited by Schwarzer Kater; Apr 26, 2023, 09:10 AM. Reason: language corrections and updated information for 1.2.0
    Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
    Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

    get rid of Snap scriptreinstall Snap for release-upgrade scriptinstall traditional Firefox script

    Comment


      #5
      During the past days I have tested the script with Kubuntu 23.10 and with upgrades from Kubuntu 22.04 -> 23.04 -> 23.10 both on "bare metal" and in virtual machines.
      Works.
      Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
      Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

      get rid of Snap scriptreinstall Snap for release-upgrade scriptinstall traditional Firefox script

      Comment

      Working...
      X