2024-06-16 14:55:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Script for use as a hook in Debian Live-Build
|
2024-06-16 18:27:16 +00:00
|
|
|
# to install Firefox with all available language packs
|
2024-06-16 18:36:44 +00:00
|
|
|
# Supports both 32-bit and 64-bit architectures
|
2024-06-16 14:55:55 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Function to download and install Firefox
|
|
|
|
install_firefox() {
|
|
|
|
local architecture="$1"
|
|
|
|
local default_locale="en-US"
|
2024-06-16 14:55:55 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Determine the appropriate URL and file paths based on architecture
|
|
|
|
if [ "$architecture" == "32bit" ]; then
|
|
|
|
arch_url="linux"
|
|
|
|
lang_pack_arch="linux-i686"
|
|
|
|
else
|
|
|
|
arch_url="linux64"
|
|
|
|
lang_pack_arch="linux-x86_64"
|
|
|
|
fi
|
2024-06-16 14:55:55 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# URL to download the latest Firefox
|
|
|
|
firefox_url="https://download.mozilla.org/?product=firefox-latest&os=${arch_url}&lang=${default_locale}"
|
2024-06-16 14:55:55 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Get the latest version number
|
|
|
|
firefox_version=$(curl -sL ${firefox_url} | grep -o 'firefox-[0-9.]*.tar.bz2' | sed 's/firefox-//g' | sed 's/.tar.bz2//g')
|
2024-06-16 14:55:55 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Construct the filename for download
|
|
|
|
firefox_filename="firefox-${firefox_version}.tar.bz2"
|
2024-06-16 14:55:55 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Download the latest version of Firefox
|
|
|
|
wget -O /tmp/${firefox_filename} ${firefox_url}
|
|
|
|
|
|
|
|
# Extract and install Firefox to /opt/firefox
|
|
|
|
tar -C /opt -xvf /tmp/${firefox_filename}
|
|
|
|
|
|
|
|
# Create a symbolic link for Firefox in /usr/bin
|
|
|
|
ln -sf /opt/firefox/firefox /usr/bin/firefox
|
|
|
|
|
|
|
|
# Set permissions to allow automatic updates
|
|
|
|
chmod -R 775 /opt/firefox
|
|
|
|
chown -R root:users /opt/firefox
|
|
|
|
|
|
|
|
# Create a .desktop entry for Firefox
|
|
|
|
echo "[Desktop Entry]
|
2024-06-16 14:55:55 +00:00
|
|
|
Name=Firefox
|
|
|
|
Comment=Web Browser
|
|
|
|
GenericName=Web Browser
|
|
|
|
Exec=/usr/bin/firefox
|
|
|
|
Icon=firefox
|
|
|
|
Terminal=false
|
|
|
|
Type=Application
|
|
|
|
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;
|
|
|
|
StartupNotify=true" > /usr/share/applications/firefox.desktop
|
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Download and install all available language packs
|
|
|
|
lang_pack_base_url="https://archive.mozilla.org/pub/firefox/releases/${firefox_version}/${lang_pack_arch}/xpi"
|
|
|
|
tmp_dir="/tmp/firefox-languages"
|
|
|
|
|
|
|
|
# Create a temporary directory for language packs
|
|
|
|
mkdir -p ${tmp_dir}
|
2024-06-16 18:27:16 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# List of all language codes available for Firefox
|
|
|
|
lang_codes=$(curl -sL ${lang_pack_base_url}/ | grep -oP 'href="\K[^"]+?\.xpi' | sed 's/\.xpi//')
|
2024-06-16 18:27:16 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Loop through each language code and download the language pack
|
|
|
|
for lang_code in ${lang_codes}; do
|
|
|
|
wget -O ${tmp_dir}/${lang_code}.xpi ${lang_pack_base_url}/${lang_code}.xpi
|
|
|
|
done
|
2024-06-16 18:27:16 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Create the directory for language packs in the Firefox installation
|
|
|
|
lang_pack_dir="/opt/firefox/browser/extensions"
|
2024-06-16 18:27:16 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Move all language packs to the Firefox extensions directory
|
|
|
|
mkdir -p ${lang_pack_dir}
|
|
|
|
mv ${tmp_dir}/*.xpi ${lang_pack_dir}
|
2024-06-16 18:27:16 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Clean up the temporary directory
|
|
|
|
rm -rf ${tmp_dir}
|
2024-06-16 18:27:16 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
echo "Firefox latest ${architecture} installed successfully with all language packs and is ready for auto-updates."
|
|
|
|
}
|
2024-06-16 18:27:16 +00:00
|
|
|
|
2024-06-16 18:36:44 +00:00
|
|
|
# Detect system architecture and install the appropriate version
|
|
|
|
if [ "$(uname -m)" == "x86_64" ]; then
|
|
|
|
echo "Installing Firefox for 64-bit architecture"
|
|
|
|
install_firefox "64bit"
|
|
|
|
else
|
|
|
|
echo "Installing Firefox for 32-bit architecture"
|
|
|
|
install_firefox "32bit"
|
|
|
|
fi
|
2024-06-16 18:27:16 +00:00
|
|
|
|