Skip to content

Instantly share code, notes, and snippets.

@wasdee
Last active October 13, 2024 15:13
Show Gist options
  • Save wasdee/c0cf5bbc715924ac3030c8f4e3589f2e to your computer and use it in GitHub Desktop.
Save wasdee/c0cf5bbc715924ac3030c8f4e3589f2e to your computer and use it in GitHub Desktop.
postman ubuntu 24 arm64 install script
#!/bin/bash
set -euo pipefail
# Directory setup
APP_DIR="${HOME}/Applications/Postman"
BIN_DIR="/usr/bin"
ICON_DIR="${HOME}/.local/share/icons"
DESKTOP_DIR="${HOME}/.local/share/applications"
# File paths
DOWNLOAD_URL="https://dl.pstmn.io/download/latest/linux_64"
ARCHIVE_NAME="postman.tar.gz"
ARCHIVE_PATH="/tmp/${ARCHIVE_NAME}"
LAUNCHER_SCRIPT="${BIN_DIR}/postman"
ICON_PATH="${ICON_DIR}/postman-icon.png"
DESKTOP_FILE_PATH="${DESKTOP_DIR}/postman.desktop"
# Utility functions
log() { printf '%s\n' "$*"; }
error() { printf 'Error: %s\n' "$*" >&2; exit 1; }
# Create necessary directories
mkdir -p "${ICON_DIR}" "${DESKTOP_DIR}"
# Download the latest Postman
log "Downloading Postman..."
curl -L "${DOWNLOAD_URL}" -o "${ARCHIVE_PATH}" || error "Failed to download Postman"
tar -xzf "${ARCHIVE_PATH}" -C /tmp || error "Failed to extract Postman"
rm "${ARCHIVE_PATH}"
log "Downloaded and extracted: ${ARCHIVE_PATH}"
log "Installing to ${APP_DIR}..."
if [ -d "${APP_DIR}" ]; then
sudo rm -rf "${APP_DIR}" || error "Failed to remove existing Postman directory"
fi
sudo mv /tmp/Postman "${APP_DIR}" || error "Failed to move Postman to ${APP_DIR}"
log "Installed to: ${APP_DIR}"
# Create symbolic link
log "Creating symbolic link..."
if [ -L "${LAUNCHER_SCRIPT}" ]; then
sudo rm -f "${LAUNCHER_SCRIPT}" || error "Failed to remove existing symbolic link"
fi
sudo ln -s "${APP_DIR}/Postman" "${LAUNCHER_SCRIPT}" || error "Failed to create symbolic link"
log "Created symbolic link: ${LAUNCHER_SCRIPT}"
# Copy the Postman icon
log "Copying Postman icon..."
sudo cp "${APP_DIR}/app/icons/icon_128x128.png" "${ICON_PATH}" || error "Failed to copy Postman icon"
# Create or update the .desktop file
cat > "${DESKTOP_FILE_PATH}" << EOF
[Desktop Entry]
Name=Postman
Exec=${LAUNCHER_SCRIPT} %F
Terminal=false
Type=Application
Icon=${ICON_PATH}
StartupWMClass=Postman
Comment=Postman API Platform
Categories=Development;Utility;
EOF
chmod +x "${DESKTOP_FILE_PATH}"
log "Created .desktop file at: ${DESKTOP_FILE_PATH}"
# Update the desktop database
update-desktop-database "${DESKTOP_DIR}" || log "Failed to update desktop database. You may need to restart your session."
# Update icon cache
gtk-update-icon-cache -f -t "${ICON_DIR}" || log "Failed to update icon cache. You may need to restart your session."
log "Installation completed successfully."
log "You can now find Postman in your application launcher or run it from the terminal with: postman"
log "You may need to log out and log back in for all changes to take effect."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment