Advertisement
vonschutter

Untitled

Mar 22nd, 2021
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.72 KB | None | 0 0
  1. ensure_snap_package_managment ()
  2. {
  3. # Description: Function to ensure that snap is installed.
  4. # Globals: none
  5. # Dependencies: [distro pakcage managment] [function: check_dependencies] [Internet access]
  6. # Arguments: None
  7. # Outputs: stdout
  8. # Returns: Standard return codes 1/0
  9. # Usage: Call the function with no arguments
  10. # NOTE: https://www.fosslinux.com/42410/snap-vs-flatpak-vs-appimage-know-the-differences-which-is-better.htm
  11. #
  12. # Like Snap, Flatpak is another distribution independent package format aimed to simplify overall
  13. # app distribution and usage in Linux systems. Previously known as xdg-app, the framework was based
  14. # on the concept of running applications in a secure virtual sandbox without requiring root privileges
  15. # or posing a security threat to the system.
  16. # Flatpak was officially released in 2015 with a reliable backup from Red Hat, Endless Computers, and
  17. # Collabora. It targeted primarily three Desktop Environments. That is FreeDesktop, KDE, and GNOME. The
  18. # Linux distributions currently having this framework are arch Linux, Debian, Fedora, Mageia,
  19. # Solus, and Ubuntu.The Flatpak framework itself is developed in C programming and released under the
  20. # LGPL license. The lead developer is Alexander Larsson – a Red Hat employee. Like Snapcraft for Snap,
  21. # Flatpak also has the Flathub app store where users can find and install all Flatpak packages.
  22. # Initially, Flathub only allowed open-source publishing applications on the website but
  23. # has recently approved the publishing of proprietary apps.
  24. # Additionally, unlike Snap, where we have a single repository controlled by Canonical to install and update
  25. # software packages, Flatpak supports the use of multiple repos. The one significant disadvantage with this
  26. # package is the lack of support for Servers.
  27. #
  28. #   *   ---       PREFFERRED Software install (Security + Control)           ----       *
  29. #
  30. #  CAPABILITY TABLE:
  31. # +-----------------------------------------------------+----------------+-------------+-----------------+
  32. # | Features                                            | Snap           | Flatpak     | AppImage        |
  33. # +-----------------------------------------------------+----------------+-------------+-----------------+
  34. # | Permission Controls Toggles                         | Yes            | Yes         | No              |
  35. # | Sandboxing Support                                  | Yes            | Yes         | Yes             |
  36. # | Sandboxing Mandatory                                | Yes            | Yes         | No              |
  37. # | App Portability                                     | Yes            | Yes         | No              |
  38. # | Native Theme Support                                | Yes (with      | Yes (with c | Yes (with cav   |
  39. # | Support for Bundled Libraries                       | Yes            | Yes         | Yes             |
  40. # | Fully Contained Single Executable Support           | No             | No          | Yes             |
  41. # | Online App Store                                    | Yes            | Yes         | Yes             |
  42. # | Multi-version Parallel Apps Support                 | Yes            | Yes         | Yes             |
  43. # | Automatic Updates                                   | Yes            | Yes         | Yes(with cave   |
  44. # | Support for Chrome OS (through Crostini containers) | Yes            | Yes         | Yes             |
  45. # | App Size                                            | higher than    | higher than | Lowest          |
  46. # | Number of Applications Available in the App Store   | Highest        | Lowest      | Somewhere in  n |
  47. # | Plugins for Desktop App Store Software              | Yes            | Yes         | No              |
  48. # +-----------------------------------------------------+----------------+-------------+-----------------+
  49. # End of documentation
  50.  
  51.  
  52.     if [[ $(echo "$OSTYPE" |grep "linux") ]]; then
  53.  
  54.         if hostnamectl |grep "SUSE" 2>/dev/null ; then
  55.             # Special case for suse
  56.             zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_$(cat /etc/os-release |grep VERSION_ID |cut -d= -f2|cut -d\" -f2) snappy
  57.             write_information "${FUNCNAME[0]}: Ensuring SNAP software distribution system is available..."
  58.             check_dependencies snapd || write_error "${FUNCNAME[0]}: Failed to satisfy dependecy SNAP!"
  59.             systemctl enable snapd ; systemctl start snapd ; systemctl status snapd
  60.             systemctl is-active --quiet snapd || return 1
  61.            
  62.             if [[ -e /snap ]]; then
  63.                 write_information "SNAP classic support present... "
  64.             else
  65.                 ln -s /var/lib/snapd/snap /snap
  66.             fi
  67.             return $?
  68.         elif hostnamectl |grep "Solus" 2>/dev/null ; then
  69.             write_information "${FUNCNAME[0]}: Solus has snap support built in..." ;return 0
  70.         elif hostnamectl |grep "Ubuntu" 2>/dev/null ; then
  71.             write_information "${FUNCNAME[0]}: Ubuntu has snap support built in..." ;return 0
  72.         elif hostnamectl |grep "Zorin" 2>/dev/null ; then
  73.             write_information "${FUNCNAME[0]}: Zoring has snap support built in..." ;return 0
  74.         elif hostnamectl |grep "Manjaro" 2>/dev/null ; then
  75.             write_information "${FUNCNAME[0]}: Manjaro has snap support built in..." ;return 0
  76.         else
  77.             # For distributions that do not need to add a repository to install snap
  78.             # But would need to install it from their standard reopsitory....
  79.             write_information "${FUNCNAME[0]}: Ensuring SNAP software distribution system is available..."
  80.             check_dependencies snapd || write_error "${FUNCNAME[0]}: Failed to satisfy dependecy SNAP!"
  81.             systemctl enable snapd ; systemctl start snapd ; systemctl status snapd
  82.             systemctl is-active --quiet snapd || return 1
  83.            
  84.             if [[ -e /snap ]]; then
  85.                 write_information "SNAP classic support present... "
  86.             else
  87.                 ln -s /var/lib/snapd/snap /snap
  88.             fi
  89.             return $?
  90.         fi
  91.  
  92.     elif [[ "$OSTYPE" == "darwin"* ]]; then
  93.         write_error "${FUNCNAME[0]}: Mac OSX is currently not supported with snap..."  ; return 1
  94.     elif [[ "$OSTYPE" == "cygwin" ]]; then
  95.         write_error "${FUNCNAME[0]}: CYGWIN is currently unsupported with snap..."  ; return 1
  96.     elif [[ "$OSTYPE" == "msys" ]]; then
  97.         write_error "${FUNCNAME[0]}: Lightweight shell is currently unsupported with snap... "  ; return 1
  98.     elif [[ "$OSTYPE" == "freebsd"* ]]; then
  99.         write_error "${FUNCNAME[0]}: Free BSD is currently unsupported with snap... " ; return 1
  100.     else
  101.         echo "I have no Idea what this system is" ; return 1
  102.     fi
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement