|
#!/usr/bin/env bash |
|
set -euo pipefail |
|
IFS=$'\n\t' |
|
|
|
# --- 0) Check/install dependencies --- |
|
deps=(curl jq tar libfuse2) |
|
for pkg in "${deps[@]}"; do |
|
if [[ "$pkg" == "libfuse2" ]]; then |
|
if ! dpkg -s libfuse2 &> /dev/null; then |
|
read -rp "Package libfuse2 is missing. Install? [y/N] " ans |
|
if [[ "$ans" =~ ^[Yy] ]]; then |
|
sudo apt update |
|
sudo apt install -y libfuse2 |
|
else |
|
echo "libfuse2 is required. Exiting." |
|
exit 1 |
|
fi |
|
fi |
|
else |
|
if ! command -v "$pkg" &> /dev/null; then |
|
read -rp "Command '$pkg' is missing. Install? [y/N] " ans |
|
if [[ "$ans" =~ ^[Yy] ]]; then |
|
sudo apt update |
|
sudo apt install -y "$pkg" |
|
else |
|
echo "'$pkg' is required. Exiting." |
|
exit 1 |
|
fi |
|
fi |
|
fi |
|
done |
|
|
|
# --- 1) Define download URL and install directory --- |
|
POSTMAN_URL="https://dl.pstmn.io/download/latest/linux_64" |
|
INSTALL_DIR="$HOME/.local/share/Postman" |
|
|
|
# --- 2) Create the installation directory --- |
|
mkdir -p "$INSTALL_DIR" |
|
|
|
# --- 3) Download and extract Postman --- |
|
curl -fsSL "$POSTMAN_URL" \ |
|
| tar xz --strip-components=1 -C "$INSTALL_DIR" |
|
|
|
# --- 4) (Optional) Symlink into ~/bin if it exists --- |
|
if [[ -d "$HOME/bin" ]]; then |
|
ln -sf "$INSTALL_DIR/Postman" "$HOME/bin/Postman" |
|
fi |
|
|
|
# --- 5) Create Desktop Entry in the applications folder --- |
|
DESKTOP_FILE="$HOME/.local/share/applications/Postman.desktop" |
|
cat > "$DESKTOP_FILE" <<EOF |
|
[Desktop Entry] |
|
Version=1.0 |
|
Name=Postman |
|
Comment=API Development Environment |
|
Exec=$INSTALL_DIR/Postman %U |
|
Icon=$INSTALL_DIR/app/icons/icon_128x128.png |
|
Terminal=false |
|
Type=Application |
|
Categories=Development;IDE; |
|
EOF |
|
|
|
chmod +x "$DESKTOP_FILE" |
|
|
|
# --- 6) Confirm installation --- |
|
echo "Postman installed to $INSTALL_DIR" |
|
echo "Desktop entry created at $DESKTOP_FILE" |