Announcement

Collapse
No announcement yet.

Script to reinstall Snap for release-upgrade

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

    Script to reinstall Snap for release-upgrade

    Purpose of this script

    This is a little helper script for Kubuntu™ users who have gotten rid of and blocked Snap entirely (like Linux Mint and TUXEDO OS do) and now want to release-upgrade to the next main Kubuntu™ version (e.g. from 23.10 to 24.04 LTS).
    It has been tested many times with Kubuntu™ 20.04 LTS up to 24.04 LTS.

    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...elease-upgrade
      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_reinstall_Snap_for_release-upgrade.sh" to e.g. your home directory.
    2. Make the file Kubuntu_reinstall_Snap_for_release-upgrade.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_reinstall_Snap_for_release-upgrade.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_reinstall_Snap_for_release-upgrade.sh.
    3. To run the script in the Konsole terminal emulator go to the directory you downloaded/saved the script to and enter:
      ./Kubuntu_reinstall_Snap_for_release-upgrade.sh.

    Important
    • This script SHOULD be run directly before release-upgrading Kubuntu™ to the next main version, if you have removed and blocked Snap entirely before, OR ELSE A RELEASE-UPGRADE TO THE NEXT KUBUNTU™ VERSION WILL PROBABLY FAIL!
      It has been designed to be run in combination with the get_rid_of_Snap script.
    • A full upgrade of the system (either with Discover or in Konsole with sudo apt update && sudo apt full-upgrade) AND a reboot is strongly recommended prior to running this script!
    You will be asked twice for confirmation before the removal of relevant APT pinning and the reinstallation of snapd and default Snaps is started - and if you answer "n" or "N" no changes at all are made to your system.​

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

    Known issues / bugs
    • For Kubuntu™ 24.04 LTS this script also installs snapd and the Firefox, Thunderbird and Firmware Updater Snaps (therefore matching the "Normal Installation" option), even if you used the "Minimal Installation" option during installation.
      This is a "saftely measure" and may change when it is known how the release-upgrade to Kubuntu™ 24.10 will work and what this exactly will require to be installed before.


    Other Ubuntu™-based distributions

    No other Ubuntu™-based distributions/flavours but Kubuntu™ 20.04 LTS & later are officially supported.

    In its current state my script does not work with Ubuntu™ (GNOME) or other GTK/GNOME-based flavours like Xubuntu™, Ubuntu MATE™, etc. as they use the Snap Store or the GNOME Software Center instead of Discover - to name just one example.
    Due to the amount of time it would take to change and thoroughly test this script accordingly I will probably also not support them in the future.
    But by all means feel free to use my script as a template to do so.

    That said the script does work with Lubuntu™ and Ubuntu Studio™ (KDE Plasma) so far.
    Last edited by Schwarzer Kater; May 09, 2024, 08:30 AM.
    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 script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
    install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

    #2
    Changelog
    • Version 2.0.5, released 2024-05-12
      - improved code (now the script tests first if the computer has established an
      internet connection)​
    • Version 2.0.4, released 2024-05-09
      - improved code
      - improved summary regarding simultaneous usage of traditional programs and
      Snaps​
    • Version 2.0.3, released 2024-04-26
      - improved summary​
    • Version 2.0.2, released 2024-04-21
      - improved code (removed unnecessary question whether to install and/or unblock
      Snap, if it is already installed and/or it is not blocked by APT pinning)​
      - improved comments
    • Version 2.0.1, released 2024-04-07
      - improved code for Kubuntu 20.10 up to 21.10​
    • Version 2.0.0, released 2024-04-05
      - REMOVED FEATURE: the Mozilla Team PPA is not supported any longer!
      - ADDED FEATURE to reinstall the Thunderbird and Firmware Updater Snaps in
      Kubuntu 24.04 LTS
      - improved code
      - improved language
      - improved comments​
    • Version 1.1.3, released 2023-06-21
      - improved code​
    • Version 1.1.2, released 2023-04-25
      - improved language
    • Version 1.1.1, released 2023-04-06
      - removed confirmation (unnecessary second question) to reinstall Snap, if it is
      already installed OR no relevant APT pinning is found in /etc/apt/preferences.d
      - improved code
      - cleaned up code
      - language corrections in 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
      - CORRECTED BUG IN CODE (removed unnecessary "sudo")
      - improved summary
      - 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 have gotten rid of and #
    # blocked Snap entirely (like Linux Mint and TUXEDO OS do) and now want to     #
    # release-upgrade to the next main Kubuntu™ version (e.g. from 23.10 to        #
    # 24.04 LTS).                                                                  #
    # It has been tested many times with Kubuntu™ 20.04 LTS up to 24.04 LTS.       #
    #                                                                              #
    # -> IMPORTANT:                                                                #
    #    This script SHOULD be run directly before release-upgrading Kubuntu™ to   #
    #    the next main version, if you have removed and blocked Snap entirely      #
    #    before, OR ELSE A RELEASE-UPGRADE TO THE NEXT KUBUNTU™ VERSION WILL       #
    #    PROBABLY FAIL!                                                            #
    #    It has been designed to be run in combination with the "get_rid_of_Snap"  #
    #    script.                                                                   #
    #                                                                              #
    # -> A full upgrade of the system (either with Discover or in Konsole with     #
    #    "sudo apt update && sudo apt full-upgrade") AND a reboot is strongly      #
    #    recommended prior to running this script!                                 #
    #                                                                              #
    # You will be asked twice for confirmation before the removal of relevant APT  #
    # pinning and the reinstallation of snapd and default Snaps is started - and   #
    # if you answer "n" or "N" no changes at all are made to your system.          #
    #                                                                              #
    # 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="2.0.5"
    
    ########
    ## During this session let's make sure no "exotic" or interfering aliases can be
    ## used in this script
    ########
    shopt -u expand_aliases
    
    ########
    ## Display purpose of this script
    ########
    clear
    echo -e "########"
    echo -e "## This is a little helper script for Kubuntu™ users who have gotten rid of and"
    echo -e "## blocked Snap entirely (like Linux Mint and TUXEDO OS do) and now want to"
    echo -e "## release-upgrade to the next main Kubuntu™ version (e.g. from 23.10 to"
    echo -e "## 24.04 LTS)."
    echo -e "## It has been tested many times with Kubuntu™ 20.04 LTS up to 24.04 LTS."
    echo -e "##"
    echo -e "## -> IMPORTANT:"
    echo -e "##    This script SHOULD be run directly before release-upgrading Kubuntu™ to"
    echo -e "##    the next main version, if you have removed and blocked Snap entirely"
    echo -e "##    before, OR ELSE A RELEASE-UPGRADE TO THE NEXT KUBUNTU™ VERSION WILL"
    echo -e "##    PROBABLY FAIL!"
    echo -e "##    It has been designed to be run in combination with the \"get_rid_of_Snap\""
    echo -e "##    script."
    echo -e "## -> A full upgrade of the system (either with Discover or in Konsole with"
    echo -e "##    \"sudo apt update && sudo apt full-upgrade\") AND a reboot is strongly"
    echo -e "##    recommended prior to running this script!"
    echo -e "##"
    echo -e "## You will be asked twice for confirmation before the removal of relevant APT"
    echo -e "## pinning and the reinstallation of snapd and default Snaps is started - and"
    echo -e "## if you answer \"n\" or \"N\" no changes at all are made to your system."
    echo -e "##"
    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. "
    
    ########
    ## Make sure the computer has established an internet connection with IP and DNS
    ## before running the rest of the script
    ########
    if ! ping -c1 -W1 ubuntu.com &> /dev/null && ! ping -c1 -W1 kde.org &> /dev/null && ! ping -c1 -W1 kernel.org &> /dev/null
    then
        echo -e "\n###############################################################################\n## -> AN ERROR OCCURED! <-                                                   ##\n## An Internet connection is required to run this script.                    ##\n## -> Please connect your Kubuntu™ to the Internet and run the script again! ##\n###############################################################################\n"
        exit 1
    fi
    
    ########
    ## If applicable, do the following:
    ## - remove relevant APT-pinning like "block installation of snapd" or "block
    ## installation of the Firefox Snap" or "prefer Firefox from the Mozilla Team
    ## PPA"
    ## - reinstall snapd
    ## - reinstall Discover's support for Snap
    ## - remove the Mozilla Team PPA, remove Firefox from the Mozilla Team PPA
    ## - for Kubuntu 22.04 & later reinstall the Firefox Snap
    ## - for Kubuntu 24.04 reinstall the Thunderbird and Firmware Updater Snaps
    ########
    rmaptpin=0
    rmmtppa=0
    rmmtff=0
    insnap=0
    inffsnap=0
    intbsnap=0
    infusnap=0
    
    # Test if the operating system is Kubuntu 20.04 or later / Ubuntu 20.04 or
    # later-based with KDE Plasma
    if ! cat /etc/os-release | grep -Ei "(^|\s)VERSION=(|\s|\"|\s\")(20.04|20.10|21.04|21.10|22.04|22.10|23.04|23.10|24.04)" &> /dev/null || ! echo "$XDG_CURRENT_DESKTOP" | grep -i KDE &> /dev/null
    then
        echo -e "\n######################################################################\n## This script is meant to be used with Kubuntu™ 20.04 LTS or later ##\n## -> PROCEED AT YOUR OWN RISK!                                     ##\n######################################################################"
    fi
    
    # Test if there is relevant APT pinning in /etc/apt/preferences.d
    for snappincounter in /etc/apt/preferences.d/* ; do if cat "${snappincounter}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)snapd($|\s)|(^|\s)Package:(|\s)snapd\*($|\s)" &> /dev/null && cat "${snappincounter}" 2> /dev/null | grep -Ei "(^|\s)Pin-Priority:(|\s)-" &> /dev/null ; then rmaptpin=1 ; fi ; done
    for ffsnappincounter in /etc/apt/preferences.d/* ; do if cat "${ffsnappincounter}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)firefox($|\s)|(^|\s)Package:(|\s)firefox\*($|\s)" &> /dev/null && cat "${ffsnappincounter}" 2> /dev/null | grep -Ei "(^|\s)Pin-Priority:(|\s)-" &> /dev/null ; then rmaptpin=1 ; fi ; done
    for ffpincounter in /etc/apt/preferences.d/* ; do if cat "${ffpincounter}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)firefox($|\s)|(^|\s)Package:(|\s)firefox\*($|\s)" &> /dev/null && cat "${ffpincounter}" 2> /dev/null | grep -Ei "=(|\s)LP-PPA-mozillateam($|\s)" &> /dev/null ; then rmaptpin=1 ; fi ; done
    # Only continue if snapd is not installed or if there is relevant APT pinning in
    # /etc/apt/preferences.d
    if ! command -v snap &> /dev/null || [[ ${rmaptpin} = 1 ]]
    then
        echo -e "\n########\n## Do you want to UNBLOCK and REINSTALL Snap (e.g. to release-upgrade your\n## Kubuntu™ to the next main version)?\n########"
    
        # Give option to cancel
        while true
        do
            read -p "[y/n] " answer
            if [[ "${answer}" = [Yy] ]]
            then
                # Ask for confirmation
                echo -e "\n########\n## Are you sure you want to REINSTALL Snap?\n########"
                while true
                do
                    read -p "[y/n] " confirm
                    if [[ "${confirm}" = [Yy] ]]
                    then
                        if [[ ${rmaptpin} = 1 ]]
                        then
                            # Remove "block installation of snapd" APT pinning from
                            # /etc/apt/preferences.d, if it exists
                            for snappincount in /etc/apt/preferences.d/* ; do if cat "${snappincount}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)snapd($|\s)|(^|\s)Package:(|\s)snapd\*($|\s)" &> /dev/null && cat "${snappincount}" 2> /dev/null | grep -Ei "(^|\s)Pin-Priority:(|\s)-" &> /dev/null ; then echo -e "\n########\n## -> Removing \"block installation of snapd\" APT pinning :\n##    ${snappincount}\n########\n" && sudo rm -f "${snappincount}" ; fi ; done
    
                            # Remove "block installation of the Firefox Snap" APT
                            # pinning from /etc/apt/preferences.d, if it exists
                            for ffsnappincount in /etc/apt/preferences.d/* ; do if cat "${ffsnappincount}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)firefox($|\s)|(^|\s)Package:(|\s)firefox\*($|\s)" &> /dev/null && cat "${ffsnappincount}" 2> /dev/null | grep -Ei "(^|\s)Pin-Priority:(|\s)-" &> /dev/null ; then echo -e "\n########\n## -> Removing \"block installation of the Firefox Snap\" APT pinning :\n##    ${ffsnappincount}\n########" && sudo rm -f "${ffsnappincount}" ; fi ; done
    
                            # Remove "prefer Firefox from the Mozilla Team PPA" APT
                            # pinning from /etc/apt/preferences.d, if it exists
                            for ffpincount in /etc/apt/preferences.d/* ; do if cat "${ffpincount}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)firefox($|\s)|(^|\s)Package:(|\s)firefox\*($|\s)" &> /dev/null && cat "${ffpincount}" 2> /dev/null | grep -Ei "=(|\s)LP-PPA-mozillateam($|\s)" &> /dev/null ; then echo -e "\n########\n## -> Removing \"prefer Firefox from the Mozilla Team PPA\" APT pinning :\n##    ${ffpincount}\n########" && sudo rm -f "${ffpincount}" ; fi ; done
                        fi
    
                        # Preventively resynchronize the package index files
                        echo -e "\n########\n## -> Updating package informations …\n########\n" && sudo apt-get update
    
                        # Reinstall snapd, if it is not installed
                        if ! command -v snap &> /dev/null ; then echo -e "\n########\n## -> Reinstalling snapd …\n########\n" && sudo apt-get install -y snapd ; fi
    
                        # If Discover is installed also reinstall Discover's support
                        # for Snap, if it is not installed
                        if dpkg -l plasma-discover 2> /dev/null | grep "^ii" &> /dev/null && ! dpkg -l plasma-discover-snap-backend 2> /dev/null | grep "^ii" &> /dev/null && apt-cache show plasma-discover-snap-backend &> /dev/null ; then echo -e "\n########\n## -> Reinstalling Discover's support for Snap …\n########\n" && sudo apt-get install -y plasma-discover-snap-backend ; fi
                        if dpkg -l plasma-discover 2> /dev/null | grep "^ii" &> /dev/null && ! dpkg -l plasma-discover-backend-snap 2> /dev/null | grep "^ii" &> /dev/null && apt-cache show plasma-discover-backend-snap &> /dev/null ; then echo -e "\n########\n## -> Reinstalling Discover's support for Snap …\n########\n" && sudo apt-get install -y plasma-discover-backend-snap ; fi
    
                        # Remove the Mozilla Team PPA, if it is enabled
                        for mtppacount in /etc/apt/sources.list.d/mozillateam-ubuntu-ppa* ; do if cat "${mtppacount}" 2> /dev/null | grep -Ei "(^|\s)deb https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu" &> /dev/null ; then echo -e "\n########\n## -> Removing the Mozilla Team PPA …\n########\n" && sudo add-apt-repository --remove -y ppa:mozillateam/ppa && rmmtppa=1 ; fi ; done
    
                        # Deinstall Firefox from the Mozilla Team PPA before
                        # installing the Firefox Snap to avoid other minor problems
                        # due to e.g. Ubuntu's Firefox "dummy" packages
                        if [[ ${rmmtppa} = 1 ]] && ! snap list firefox &> /dev/null && dpkg -l firefox 2> /dev/null | grep "^ii" &> /dev/null && dpkg -l firefox 2> /dev/null | grep "~mt" &> /dev/null ; then echo -e "\n########\n## -> Deinstalling Firefox from the Mozilla Team PPA …\n########\n" && sudo pkcon remove --autoremove -y firefox && rmmtff=1 ; fi
    
                        # Reinstall the Firefox Snap, if it is not installed and
                        # Kubuntu release version is 22.04 or later
                        if ! snap list firefox &> /dev/null && cat /etc/os-release | grep -Ei "(^|\s)VERSION=(|\s|\"|\s\")(22.04|22.10|23.04|23.10|24.04)" &> /dev/null ; then echo -e "\n########\n## -> Reinstalling the Firefox Snap …\n########\n" && sudo snap install firefox && inffsnap=1 ; fi
    
                        # Reinstall the Thunderbird Snap, if it is not installed and
                        # Kubuntu release version is 24.04
                        if ! snap list thunderbird &> /dev/null && cat /etc/os-release | grep -Ei "(^|\s)VERSION=(|\s|\"|\s\")24.04" &> /dev/null ; then echo -e "\n########\n## -> Reinstalling the Thunderbird Snap …\n########\n" && sudo snap install thunderbird && intbsnap=1 ; fi
    
                        # Reinstall the Firmware Updater Snap, if it is not
                        # installed and Kubuntu release version is 24.04
                        if ! snap list firmware-updater &> /dev/null && cat /etc/os-release | grep -Ei "(^|\s)VERSION=(|\s|\"|\s\")24.04" &> /dev/null ; then echo -e "\n########\n## -> Reinstalling the Firmware Updater Snap …\n########\n" && sudo snap install firmware-updater && infusnap=1 ; fi
    
                        insnap=1
                        break 2
                    elif [[ "${confirm}" = [Nn] ]]
                    then
                        echo -e "\n########\n## You canceled the reinstallation of Snap -> not changing anything …\n########"
                        break 2
                    fi
                done
            elif [[ "${answer}" = [Nn] ]]
            then
                echo -e "\n########\n## You canceled the reinstallation of Snap -> not changing anything …\n########"
                break
            fi
        done
    elif command -v snap &> /dev/null && [[ ${rmaptpin} = 0 ]]
    then
        echo -e "\n########\n## Snap seems to already be installed and there seems to be no relevant APT\n## pinning in /etc/apt/preferences.d -> not changing anything …\n########"
    fi
    
    ########
    ## Report what has been done
    ########
    summary_first="\n########\n## -> SUMMARY:"
    summary_rmaptpin="## Relevant APT pinning has been removed from /etc/apt/preferences.d ."
    summary_rmmtppa="## The Mozilla Team PPA has been removed."
    summary_rmmtff="## Firefox from the Mozilla Team PPA has been removed (your Firefox user data\n## has been left entirely untouched)."
    summary_tradff="## -> Be aware that the traditional Firefox is still additionally installed.\n##    DON'T START AND USE BOTH the traditional Firefox AND the Firefox Snap\n##    SIMULTANEOUSLY - this can lead to problems!"
    summary_tradtb="## -> Be aware that the traditional Thunderbird is still additionally installed.\n##    DON'T START AND USE BOTH the traditional Thunderbird AND the Thunderbird\n##    Snap SIMULTANEOUSLY - this can lead to problems!"
    summary_desnap="## -> You can remove Snap again later with the \"get_rid_of_Snap\" script."
    summary_releaseup="## With regards to the above, it is safe to release-upgrade to the next main\n## Kubuntu™ version henceforth."
    summary_reboot="## -> It is strongly recommended that you reboot your computer now!"
    summary_nochanges="## The script has made no changes at all to your system!"
    summary_last="## Have a nice day and enjoy Kubuntu™.\n########\n"
    savesummary=0
    
    if [[ ${insnap} = 1 ]] && [[ $inffsnap = 1 ]]
    then
        # Tell that Snap including the Firefox Snap (and Thunderbird and Firmware
        # Updater Snaps) has been reinstalled and recommend system reboot
        echo -e "${summary_first}"
        if [[ ${intbsnap} = 0 ]] && [[ $infusnap = 0 ]]
        then
            echo -e "## Snap including the Firefox Snap has been reinstalled to your system."
        elif [[ ${intbsnap} = 1 ]] && [[ $infusnap = 1 ]]
        then
            echo -e "## Snap including the Firefox, Thunderbird and Firmware Updater Snaps has been\n## reinstalled to your system."
        fi
        if [[ ${rmaptpin} = 1 ]] ; then echo -e "${summary_rmaptpin}" ; fi
        if [[ ${rmmtppa} = 1 ]] ; then echo -e "${summary_rmmtppa}" ; fi
        if [[ ${rmmtff} = 1 ]] ; then echo -e "${summary_rmmtff}" ; fi
        if [[ -d "/usr/lib/firefox" && $(command -v firefox) && $(snap list firefox) ]] || [[ -x "/opt/firefox/firefox" && $(snap list firefox) ]]
        then
            echo -e "${summary_tradff}"
        fi
        if [[ -d "/usr/lib/thunderbird" && $(command -v thunderbird) && $(snap list thunderbird) ]] || [[ -x "/opt/thunderbird/thunderbird" && $(snap list thunderbird) ]]
        then
            echo -e "${summary_tradtb}"
        fi
        echo -e "${summary_desnap}"
        echo -e "${summary_releaseup}"
        echo -e "${summary_reboot}"
        echo -e "${summary_last}"
        savesummary=1
    elif [[ ${insnap} = 1 ]] && [[ $inffsnap = 0 ]]
    then
        # Tell that Snap has been reinstalled and recommend system reboot
        echo -e "${summary_first}"
        echo -e "## Snap has been reinstalled to your system."
        if [[ ${rmaptpin} = 1 ]] ; then echo -e "${summary_rmaptpin}" ; fi
        if [[ ${rmmtppa} = 1 ]] ; then echo -e "${summary_rmmtppa}"; fi
        if [[ ${rmmtff} = 1 ]] ; then echo -e "${summary_rmmtff}" ; fi
        echo -e "${summary_desnap}"
        echo -e "${summary_releaseup}"
        echo -e "${summary_reboot}"
        echo -e "${summary_last}"
        savesummary=1
    elif command -v snap &> /dev/null
    then
        # Tell that nothing has changed
        echo -e "${summary_first}"
        echo -e "${summary_nochanges}"
        echo -e "${summary_last}"
    else
        # Tell that nothing has changed
        echo -e "${summary_first}"
        echo -e "${summary_nochanges}"
        echo -e "## -> Be sure to remove any relevant APT pinning and reinstall Snap BEFORE a"
        echo -e "##    release-upgrade to the next main Kubuntu™ version (e.g. from 23.10 to"
        echo -e "##    24.04 LTS)!"
        echo -e "##    You can do both with this \"reinstall_Snap_for_release-upgrade\" script."
        echo -e "## Have a nice day and enjoy a snap-free 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] ]] && [[ ${insnap} = 1 ]] && [[ $inffsnap = 1 ]]
            then
                # Save to text file that Snap including the Firefox Snap has been
                # reinstalled and system reboot is recommended
                echo -e "${summary_first}" > "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                if [[ ${intbsnap} = 0 ]] && [[ $infusnap = 0 ]]
                then
                    echo -e "## Snap including the Firefox Snap has been reinstalled to your system." >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                elif [[ ${intbsnap} = 1 ]] && [[ $infusnap = 1 ]]
                then
                    echo -e "## Snap including the Firefox, Thunderbird and Firmware Updater Snaps has been\n## reinstalled to your system." >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                fi
                if [[ ${rmaptpin} = 1 ]] ; then echo -e "${summary_rmaptpin}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt" ; fi
                if [[ ${rmmtppa} = 1 ]] ; then echo -e "${summary_rmmtppa}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt" ; fi
                if [[ ${rmmtff} = 1 ]] ; then echo -e "${summary_rmmtff}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt" ; fi
                if [[ -d "/usr/lib/firefox" && $(command -v firefox) && $(snap list firefox) ]] || [[ -x "/opt/firefox/firefox" && $(snap list firefox) ]]
                then
                    echo -e "${summary_tradff}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                fi
                if [[ -d "/usr/lib/thunderbird" && $(command -v thunderbird) && $(snap list thunderbird) ]] || [[ -x "/opt/thunderbird/thunderbird" && $(snap list thunderbird) ]]
                then
                    echo -e "${summary_tradtb}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                fi
                echo -e "${summary_desnap}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "${summary_releaseup}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "${summary_reboot}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "${summary_last}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "Script version used: ${versionnr}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "\n########\n## -> The summary of what has been done by this script was saved to:\n##    $HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}\n########\n"
                break
            elif [[ "${wantsave}" = [Yy] ]] && [[ ${insnap} = 1 ]] && [[ $inffsnap = 0 ]]
            then
                # Save to text file that Snap has been reinstalled and system reboot
                # is recommended
                echo -e "${summary_first}" > "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "## Snap has been reinstalled to your system." >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                if [[ ${rmaptpin} = 1 ]] ; then echo -e "${summary_rmaptpin}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt" ; fi
                if [[ ${rmmtppa} = 1 ]] ; then echo -e "${summary_rmmtppa}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt" ; fi
                if [[ ${rmmtff} = 1 ]] ; then echo -e "${summary_rmmtff}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt" ; fi
                echo -e "${summary_desnap}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "${summary_releaseup}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "${summary_reboot}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "${summary_last}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "Script version used: ${versionnr}" >> "$HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}.txt"
                echo -e "\n########\n## -> The summary of what has been done by this script was saved to:\n##    $HOME/reinstall_Snap_for_release-upgrade-SUMMARY_${appendix}\n########\n"
                break
            elif [[ "${wantsave}" = [Nn] ]]
            then
                echo
                break
            fi
        done
    fi
    
    ########
    ## Give option to reboot, if this has been recommended
    ########
    if [[ ${insnap} = 1 ]]
    then
        echo -e "########\n## -> Do you want to reboot your system now as recommended?\n########"
        while true
        do
            read -p "[y/n] " rebootpc
            if [[ "${rebootpc}" = [Yy] ]]
            then
                reboot
                break
            elif [[ "${rebootpc}" = [Nn] ]]
            then
                echo
                break
            fi
        done
    fi
    ​
    Last edited by Schwarzer Kater; May 12, 2024, 10:46 AM. Reason: update to version 2.0.5
    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 script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
    install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

    Comment


      #3
      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 script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
      install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

      Comment


        #4
        I updated the script - it now does not support the Mozilla Team PPA any longer!

        This version has been prepared and pretested for Kubuntu 24.04 LTS - I will keep testing it until the official release of 24.04, of course.​
        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 script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
        install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

        Comment


          #5
          Re-tested dozens of times with Kubuntu 24.04 LTS (development branch, Beta and final release): 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 script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
          install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

          Comment


            #6
            Update to version 2.0.4:
            amongst others I improved the summary regarding simultaneous usage of "traditional" programs and Snaps.​​
            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 script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
            install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

            Comment


              #7
              Update to version 2.0.5:
              better late than never - now all scripts test first if the computer has established an internet connection as this is needed.​​
              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 script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
              install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

              Comment

              Working...
              X