Skip to content

Instantly share code, notes, and snippets.

@exiguus
Created November 18, 2024 19:52
Show Gist options
  • Save exiguus/fba335b0546052a1794cd011c89e26bc to your computer and use it in GitHub Desktop.
Save exiguus/fba335b0546052a1794cd011c89e26bc to your computer and use it in GitHub Desktop.
Install and Update Firefox Nightly on Linux (Debian) parallel to Firefox ESR
#!/bin/bash
# Variables
NIGHTLY_DIR="$HOME/firefox-nightly"
NIGHTLY_PROFILE_DIR="$HOME/.mozilla/firefox-nightly-profile"
DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os=linux64&lang=en-US"
DESKTOP_FILE="$HOME/.local/share/applications/firefox-nightly.desktop"
BIN_DIR="$HOME/.local/bin"
EXECUTABLE="$BIN_DIR/firefox-nightly"
TEMP_FILE="$HOME/Downloads/firefox-nightly.tar.bz2"
# Function to handle early failures
fail() {
echo -e "\e[31m😞 Error: $1\e[0m" >&2
exit 1
}
# Function to log success messages
log() {
echo -e "\e[32m🚀 [INFO] $1\e[0m"
}
# Step 1: Create directories
log "Creating necessary directories..."
mkdir -p "$NIGHTLY_DIR" "$NIGHTLY_PROFILE_DIR" "$BIN_DIR" || fail "Failed to create required directories"
log "Directories created: $NIGHTLY_DIR, $NIGHTLY_PROFILE_DIR, and $BIN_DIR"
# Step 2: Download Firefox Nightly
log "Downloading Firefox Nightly..."
if wget -q --show-progress -O "$TEMP_FILE" "$DOWNLOAD_URL"; then
log "Download completed."
else
fail "Failed to download Firefox Nightly"
fi
# Step 3: Extract Firefox Nightly
log "Extracting Firefox Nightly..."
rm -rf "$NIGHTLY_DIR" || fail "Failed to remove old Firefox Nightly directory"
mkdir -p "$NIGHTLY_DIR" || fail "Failed to recreate $NIGHTLY_DIR"
tar xjf "$TEMP_FILE" -C "$NIGHTLY_DIR" || fail "Failed to extract Firefox Nightly"
log "Extraction completed."
# Step 4: Create a symbolic link in ~/.local/bin
log "Creating symbolic link for Firefox Nightly executable..."
ln -sf "$NIGHTLY_DIR/firefox/firefox" "$EXECUTABLE" || fail "Failed to create symbolic link"
log "Symbolic link created at $EXECUTABLE."
# Step 5: Create a separate profile for Nightly if not exists
log "Ensuring a separate profile for Firefox Nightly..."
if [ ! -d "$NIGHTLY_PROFILE_DIR" ]; then
if "$NIGHTLY_DIR/firefox/firefox" --no-remote --CreateProfile "nightly-profile $NIGHTLY_PROFILE_DIR"; then
log "Profile created at $NIGHTLY_PROFILE_DIR."
else
fail "Failed to create a profile for Firefox Nightly"
fi
else
log "Profile already exists at $NIGHTLY_PROFILE_DIR."
fi
# Step 6: Create Desktop Launcher
log "Creating a desktop launcher..."
mkdir -p "$(dirname "$DESKTOP_FILE")" || fail "Failed to create desktop launcher directory"
cat > "$DESKTOP_FILE" <<EOF
[Desktop Entry]
Name=Firefox Nightly
Exec=$EXECUTABLE --no-remote --profile "$NIGHTLY_PROFILE_DIR"
Terminal=false
Type=Application
Icon=$NIGHTLY_DIR/firefox/browser/chrome/icons/default/default128.png
Categories=Network;WebBrowser;
EOF
if [ $? -eq 0 ]; then
log "Desktop launcher created at $DESKTOP_FILE."
else
fail "Failed to create desktop launcher"
fi
# Step 7: Clean up
log "Cleaning up temporary files..."
rm -f "$TEMP_FILE" || fail "Failed to clean up temporary files"
log "Temporary files cleaned up."
# Step 8: Instructions for updates
log "Firefox Nightly has been successfully installed and configured!"
echo -e "\n- You can launch it from your application menu (search for \"Firefox Nightly\")."
echo -e "- You can also run it directly from the command line with 'firefox-nightly'."
echo -e "- Firefox Nightly will automatically update itself, but you can also manually update it by running this script again."
echo -e "- Your existing Firefox ESR installation remains unaffected.\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment