Skip to content

Instantly share code, notes, and snippets.

@loopyd
Created February 7, 2026 06:39
Show Gist options
  • Select an option

  • Save loopyd/baf66760d5efed05f9313b1c1609af8e to your computer and use it in GitHub Desktop.

Select an option

Save loopyd/baf66760d5efed05f9313b1c1609af8e to your computer and use it in GitHub Desktop.
[bash] Install Blender 3D
#!/usr/bin/env bash
set -eo pipefail
C_RED=$(tput setaf 1)
C_GREEN=$(tput setaf 2)
C_RESET=$(tput sgr0)
fail() {
echo "${C_RED}Error: $1${C_RESET}" >&2
exit 1
}
BLENDER_VERSION="5.0.1"
BLENDER_TAR="blender-${BLENDER_VERSION}-linux-x64.tar.xz"
BLENDER_URL="https://download.blender.org/release/Blender${BLENDER_VERSION%.*}/${BLENDER_TAR}"
INSTALL_DIR="/usr/local/blender"
SYMLINK_PATH="/usr/bin/blender"
sudo apt-get update || fail "Failed to update package lists"
sudo apt-get install -y libxi6 libxrender1 libxrandr2 libxcursor1 libxinerama1 libfreetype6 xz-utils || fail "Failed to install dependencies"
if [ -f "/tmp/${BLENDER_TAR}" ]; then
echo "${C_GREEN}Blender archive already downloaded.${C_RESET}"
else
echo "Downloading Blender ${BLENDER_VERSION}..."
wget "${BLENDER_URL}" -O "/tmp/${BLENDER_TAR}" || fail "Failed to download Blender from ${BLENDER_URL}"
fi
[ ! -d "${INSTALL_DIR}" ] && {
sudo mkdir -p "${INSTALL_DIR}" || fail "Failed to create installation directory at ${INSTALL_DIR}"
}
if [ "$(ls -A ${INSTALL_DIR})" ]; then
echo "${C_GREEN}Blender is already installed in ${INSTALL_DIR}.${C_RESET}"
exit 0
fi
echo "Extracting Blender to ${INSTALL_DIR}..."
sudo tar -xf "/tmp/${BLENDER_TAR}" -C "${INSTALL_DIR}" --strip-components=1 || fail "Failed to extract Blender to ${INSTALL_DIR}"
if [ ! -L "${SYMLINK_PATH}" ] && [ ! -e "${SYMLINK_PATH}" ]; then
sudo ln -sf "${INSTALL_DIR}/blender-launcher" "${SYMLINK_PATH}" || fail "Failed to create symbolic link for Blender at ${SYMLINK_PATH}"
echo "${C_GREEN}Created symlink for Blender at ${SYMLINK_PATH}.${C_RESET}"
else
echo "${C_GREEN}Blender symlink already exists at ${SYMLINK_PATH}.${C_RESET}"
fi
if [ -f "/usr/share/applications/blender.desktop" ]; then
echo "${C_GREEN}Blender desktop entry already exists.${C_RESET}"
else
cat <<EOF | sudo tee /usr/share/applications/blender.desktop
[Desktop Entry]
Name=Blender
Comment=3D modeling, animation, rendering and post-production
Exec=${SYMLINK_PATH}
Icon=${INSTALL_DIR}/blender.svg
Terminal=false
Type=Application
Categories=Graphics;3DGraphics;
EOF
if [ $? -ne 0 ]; then
fail "Failed to create Blender desktop entry"
fi
sudo chmod +x /usr/share/applications/blender.desktop || fail "Failed to set executable permission on Blender desktop entry"
echo "${C_GREEN}Created Blender desktop entry.${C_RESET}"
fi
if command -v update-desktop-database >/dev/null 2>&1; then
sudo update-desktop-database /usr/share/applications/ || fail "Failed to update desktop database"
echo "${C_GREEN}Updated desktop database.${C_RESET}"
fi
[ -f "/tmp/${BLENDER_TAR}" ] && {
rm "/tmp/${BLENDER_TAR}" || fail "Failed to remove temporary Blender archive"
}
echo "${C_GREEN}Blender ${BLENDER_VERSION} installed successfully!${C_RESET}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment