From cc8863664205b5d075fa3c0160f2e04419848f51 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Thu, 20 Mar 2025 09:04:00 +0200 Subject: [PATCH] snap-browsers.bash: script installing snapped browsers --- bash/snap-browsers.bash | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 bash/snap-browsers.bash diff --git a/bash/snap-browsers.bash b/bash/snap-browsers.bash new file mode 100755 index 0000000..f6da443 --- /dev/null +++ b/bash/snap-browsers.bash @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# I am not a fan of Snap in general due to issues such as one allowed +# repository allowed at a time, closed source server, issues when running +# without a desktop environment, but with web browsers it beats flatpak for +# respecting browser policies, thus this script which is kind of +# snap-workarounds.bash + +# WARNING: No KDE Desktop Integration for snap users + +# If snap isn't installed, exit +if ! hash snap 2> /dev/null; then + echo "This script is useless without snap installed." + exit 1 +fi + +# Require root or exit +if [ "$(id -u)" != "0" ]; then + echo "This script requires root." 1>&2 + exit 1 +fi + +# Ensure classic snap support is enabled +if [ ! -d "/snap" ]; then + ln -nsv /var/lib/snapd/snap /snap +fi + +# Init policy directories or quit if the script isn't available +if [ -f "../submodules/shell-things/etc/init-browser-policies.bash" ]; then + # TODO: That script has comments that might be more at home here! + ../submodules/shell-things/etc/init-browser-policies.bash +else + echo "Missing submodule shell-things, initializing submodules" + git submodule update --init + echo "Please run the script again!" + exit 1 +fi + +# If Firefox is already installed, switch to the ESR channel for distrust +# towards Mozilla and search engine policy support. Otherwise install Firefox +# This is officially supported/published by Mozilla. +if [ -f "/snap/bin/firefox" ]; then + snap refresh firefox --channel=esr/stable +else + snap install firefox --channel=esr/stable +fi + +# Difficult to test Chromium policies without Chromium. And for testing edge is fine. +# Published/supported by Canonical. +if [ -f "/snap/bin/chromium" ]; then + snap refresh chromium --channel=edge +else + snap install chromium --edge +fi + +# European/Norwegian freeware browser that I prefer to keep installed as an option. +# Official snap. +if [ -f "/snap/bin/vivaldi.vivaldi-stable" ]; then + snap refresh vivaldi +else + snap install vivaldi +fi