Skip to content

Instantly share code, notes, and snippets.

@sdumetz
Last active June 10, 2020 14:00
Show Gist options
  • Save sdumetz/f0d73f6bd8c7c2f0cb8065fb81b96c72 to your computer and use it in GitHub Desktop.
Save sdumetz/f0d73f6bd8c7c2f0cb8065fb81b96c72 to your computer and use it in GitHub Desktop.
Install firefox official stable release on debian stretch and consorts
#!/bin/sh
#Install firefox official stable release on debian stretch and consorts
set -e
TMP="$(mktemp -d)"
install_base="/usr/local"
echo "downloading latest firefox release..."
wget -O "$TMP/FirefoxSetup.tar.bz2" "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=fr"
echo "removing old firefox binaries"
test -d "$install_base/lib/firefox" && rm -rf "$install_base/lib/firefox"
echo "extracting..."
tar -C "$install_base/lib" -xjf "$TMP/FirefoxSetup.tar.bz2"
rm -rf "$TMP"
echo "Creating executable..."
ln -f -s "$install_base/lib/firefox/firefox-bin" "$install_base/bin/firefox"
echo "Installing desktop entry..."
mkdir -p "$install_base/share/applications"
cat > "$install_base/share/applications/firefox.desktop" << EOF
[Desktop Entry]
Name=Firefox
Comment=Browse the World Wide Web
GenericName=Web Browser
X-GNOME-FullName=Firefox Upstream Browser
Exec=/usr/local/lib/firefox/firefox-bin %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=Network;WebBrowser;
MimeType=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;
StartupWMClass=Firefox
StartupNotify=true
EOF
echo "Installing icons"
#some dirs might not exist
icons_base="$install_base/share/icons/hicolor"
#usage : link_icon <src> <size>
copy_icon(){
local src="$1"
local size="$2"
local destdir="$icons_base/${size}x${size}/apps"
test -d "$destdir" || mkdir -p "$destdir"
echo "\tcopying $destdir/firefox.png"
test -f "$destdir/firefox.png" || cp "$src" "$destdir/firefox.png"
}
#default128.png default16.png default32.png default48.png default64.png
(
set -e
cd "$install_base/lib/firefox"
for icon in browser/chrome/icons/default/default*.png ; do
size="$(echo -n "$icon" | sed -e 's/^.*default\([[:digit:]]\+\).png/\1/')" #get size
copy_icon "$(pwd)/$icon" "$size"
done
)
update-alternatives --install /usr/bin/x-www-browser x-www-browser "$install_base/bin/firefox" 80
update-alternatives --set x-www-browser /usr/local/bin/firefox
@sdumetz
Copy link
Author

sdumetz commented Jun 10, 2020

It should not. /usr/local/bin is generally before /usr/bin in PATH so the local version will be used. It's even used as the default browser handler because it runs update-alternatives at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment