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 does) and now want to release-upgrade to the next main Kubuntu™ version (e.g. from 22.04 LTS to 23.04).
    It has been tested many times with Kubuntu™ 20.04, 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...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 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!

    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.

    It has been designed to be run in combination with the get_rid_of_Snap script.
    It WILL ALSO REMOVE Firefox if that has been installed from the Mozilla Team PPA before (your Firefox user data is left entirely untouched) - but the get_rid_of_Snap script will then reinstall both the Mozilla Team PPA and Firefox from there when run again after the release-upgrade to the next main Kubuntu™ version.


    You will be asked for confirmation twice before the removal of relevant APT pinning and the reinstallation of snapd 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 bugs / issues
    • If you had enabled the Mozilla Team PPA prior to running this reinstall_Snap_for_release-upgrade script, you might get update messages regarding Thunderbird and/or because of the "dummy" Firefox APT packages from Ubuntu's™ repositories afterwards as this script removes the Mozilla Team PPA for the release-upgrade.
      The solution is​ that you will have to install these ("dummy") packages like the system package management suggests or you will not be able to release-upgrade your Kubuntu™ to the next main version.


    Other Ubuntu™-based distributions

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

    In its current state my script does not work with Ubuntu™ (Gnome) or other GTK/Gnome based Flavors 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 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; Oct 17, 2023, 03:52 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"

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

    #2
    Changelog
    • 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 does) and now want to release-upgrade #
    # to the next main Kubuntu™ version (e.g. from 22.04 LTS to 23.04).            #
    # It has been tested many times with Kubuntu™ 20.04, 22.04, 23.04 and 23.10.   #
    #                                                                              #
    # -> IMPORTANT:                                                                #
    #    This script SHOULD be run 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!   #
    #                                                                              #
    #    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.                                 #
    #                                                                              #
    #    It has been designed to be run in combination with the "get_rid_of_Snap"  #
    #    script. It WILL ALSO REMOVE Firefox if that has been installed from the   #
    #    Mozilla Team PPA before (your Firefox user data is left entirely          #
    #    untouched) - but the "get_rid_of_Snap" script will then reinstall both    #
    #    the Mozilla Team PPA and Firefox from there when run again after the      #
    #    release-upgrade to the next main Kubuntu™ version.                        #
    #                                                                              #
    # You will be asked for confirmation twice before the removal of relevant APT  #
    # pinning and the reinstallation of snapd 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="1.1.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 snap 2> /dev/null
    unalias sudo 2> /dev/null
    unalias rm 2> /dev/null
    unalias tee 2> /dev/null
    unalias apt-get 2> /dev/null
    unalias dpkg 2> /dev/null
    unalias apt-cache 2> /dev/null
    unalias add-apt-repository 2> /dev/null
    unalias pkcon 2> /dev/null
    unalias reboot 2> /dev/null
    
    ########
    ## 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 does) and now want to release-upgrade"
    echo -e "## to the next main Kubuntu™ version (e.g. from 22.04 LTS to 23.04)."
    echo -e "## It has been tested many times with Kubuntu™ 20.04, 22.04, 23.04 and 23.10."
    echo -e "##"
    echo -e "## -> IMPORTANT:"
    echo -e "##    This script SHOULD be run before release-upgrading Kubuntu™ to the next"
    echo -e "##    main version if you have removed and blocked Snap entirely before, OR"
    echo -e "##    ELSE A RELEASE-UPGRADE TO THE NEXT KUBUNTU™ VERSION WILL PROBABLY FAIL!"
    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 "##    It has been designed to be run in combination with the \"get_rid_of_Snap\""
    echo -e "##    script. It WILL ALSO REMOVE Firefox if that has been installed from the"
    echo -e "##    Mozilla Team PPA before (your Firefox user data is left entirely"
    echo -e "##    untouched) - but the \"get_rid_of_Snap\" script will then reinstall both"
    echo -e "##    the Mozilla Team PPA and Firefox from there when run again after the"
    echo -e "##    release-upgrade to the next main Kubuntu™ version."
    echo -e "##"
    echo -e "## You will be asked for confirmation twice before the removal of relevant APT"
    echo -e "## pinning and the reinstallation of snapd is started - and if you answer \"n\""
    echo -e "## or \"N\" no changes at all are made to your system."
    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. "
    
    ########
    ## Remove relevant APT-pinning like "block installation of snapd" or "block
    ## installation of the Firefox Snap" or "prefer Firefox from the Mozilla Team
    ## PPA" (write a placeholder file for the latter instead), reinstall snapd and
    ## Snap support libraries/tools, remove the Mozilla Team PPA (write a
    ## placeholder file for the latter instead), remove Firefox from the Mozilla
    ## Team PPA (write a placeholder file for the latter instead) and for Kubuntu™
    ## from 22.04 onwards reinstall the Firefox Snap
    ########
    rmaptpin=0
    rmmtppa=0
    rmmtff=0
    insnap=0
    inffsnap=0
    
    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########"
    
    while true
    do
        read -p "[y/n] " answer
        if [[ "${answer}" = [Yy] ]]
        then
            # Test if there is relevant APT pinning in
            # /etc/apt/preferences.d
            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 rmaptpin=1 ; fi ; done
            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 rmaptpin=1 ; fi ; done
            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 rmaptpin=1 ; fi ; done
    
            # Only continue if snapd is not installed OR if there is found relevant
            # APT pinning in /etc/apt/preferences.d
            if ! command -v snap &> /dev/null || [[ ${rmaptpin} = 1 ]]
            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 snappin in /etc/apt/preferences.d/* ; do if cat "${snappin}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)snapd($|\s)|(^|\s)Package:(|\s)snapd\*($|\s)" &> /dev/null && cat "${snappin}" 2> /dev/null | grep -Ei "(^|\s)Pin-Priority:(|\s)-" &> /dev/null ; then echo -e "\n########\n## -> Removing \"block installation of snapd\" APT pinning :\n##    ${snappin}\n########\n" && sudo rm -f "${snappin}" ; fi ; done
    
                            # Remove "block installation of the Firefox Snap" APT
                            # pinning from /etc/apt/preferences.d, if it exists
                            for ffsnappin in /etc/apt/preferences.d/* ; do if cat "${ffsnappin}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)firefox($|\s)|(^|\s)Package:(|\s)firefox\*($|\s)" &> /dev/null && cat "${ffsnappin}" 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##    ${ffsnappin}\n########" && sudo rm -f "${ffsnappin}" ; fi ; done
    
                            # Remove "prefer Firefox from the Mozilla Team PPA" APT
                            # pinning from /etc/apt/preferences.d, if it exists and
                            # write an "invisible" placeholder file to $HOME instead
                            # for reapplying when using the "get_rid_of_Snap" script
                            # again
                            for ffpin in /etc/apt/preferences.d/* ; do if cat "${ffpin}" 2> /dev/null | grep -Ei "(^|\s)Package:(|\s)firefox($|\s)|(^|\s)Package:(|\s)firefox\*($|\s)" &> /dev/null && cat "${ffpin}" 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##    ${ffpin}\n########" && sudo rm -f "${ffpin}" && echo -e "\n########\n## -> Writing placeholder file to $HOME/.mtppa-ffpin-placeholder :\n########\n" && echo -e "# This is an \"invisible\" placeholder file created by the\n# \"reinstall_Snap_for_release-upgrade\" script.\n# DO NOT REMOVE OR RENAME IT if you want to automatically reapply APT pinning\n# for Firefox from the Mozilla Team PPA when using the \"get_rid_of_Snap\" script\n# after the release-upgrade of Kubuntu™ to the next main version!" | tee "$HOME/.mtppa-ffpin-placeholder" ; fi ; done
                        fi
    
                        # 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 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 plasma-discover-snap-backend …\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 plasma-discover-backend-snap …\n########\n" && sudo apt-get install -y plasma-discover-backend-snap ; fi
    
                        # Remove the Mozilla Team PPA, if it is enabled and write an
                        # "invisible" placeholder file to $HOME instead for
                        # re-enabling when using the "get_rid_of_Snap" script again
                        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 && echo -e "\n########\n## -> Writing placeholder file to $HOME/.mtppa-placeholder :\n########\n" && echo -e "# This is an \"invisible\" placeholder file created by the\n# \"reinstall_Snap_for_release-upgrade\" script.\n# DO NOT REMOVE OR RENAME IT if you want to automatically re-enable the Mozilla\n# Team PPA for Firefox when using the \"get_rid_of_Snap\" script after the\n# release-upgrade of Kubuntu™ to the next main version!" | tee "$HOME/.mtppa-placeholder" && 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 and write
                        # an "invisible" placeholder file to $HOME instead for
                        # reinstalling (the correct Ubuntu™ release version) Firefox
                        # from the Mozilla Team PPA when using the "get_rid_of_Snap"
                        # script again
                        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 && echo -e "\n########\n## -> Writing placeholder file to $HOME/.mtff-placeholder :\n########\n" && echo -e "# This is an \"invisible\" placeholder file created by the\n# \"reinstall_Snap_for_release-upgrade\" script.\n# DO NOT REMOVE OR RENAME IT if you want to automatically reinstall Firefox from\n# the Mozilla Team PPA when using the \"get_rid_of_Snap\" script after the\n# release-upgrade of Kubuntu™ to the next main version!" | tee "$HOME/.mtff-placeholder" && rmmtff=1 ; fi
    
                        # Reinstall the Firefox Snap, if it is not installed and
                        # Kubuntu™ release version is not 20.04
                        if ! snap list firefox &> /dev/null && ! cat /etc/os-release | grep -Ei "(^|\s)VERSION=(|\s|\"|\s\")20.04" &> /dev/null ; then echo -e "\n########\n## -> Reinstalling the Firefox Snap …\n########\n" && sudo snap install firefox && inffsnap=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
            else
                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########"
                break
            fi
        elif [[ "${answer}" = [Nn] ]]
        then
            echo -e "\n########\n## You canceled the reinstallation of Snap -> not changing anything …\n########"
            break
        fi
    done
    
    ########
    ## 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 and will be re-enabled by the\n## \"get_rid_of_Snap\" script when run after the Kubuntu™ release-upgrade to the\n## next main version."
    summary_rmmtff="## Firefox from the Mozilla Team PPA has been removed and will be reinstalled by\n## the \"get_rid_of_Snap\" script when run after the Kubuntu™ release-upgrade to\n## the next main version (your Firefox user data has been left entirely\n## untouched)."
    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 has been reinstalled and recommend system reboot
        echo -e "${summary_first}"
        echo -e "## Snap including the Firefox 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_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_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 22.04 LTS to"
        echo -e "##    23.04)!"
        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"
                echo -e "## Snap including the Firefox 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_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_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; Oct 17, 2023, 03:42 PM. Reason: tested for 23.10
    Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
    Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13"

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

    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"

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

      Comment

      Working...
      X