Skip to content

Commit dcb7f03

Browse files
committed
Updated ipm install script
1 parent d88f96c commit dcb7f03

File tree

1 file changed

+50
-16
lines changed

1 file changed

+50
-16
lines changed

install_ipm.sh

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,60 @@ APPNAME="ipm"
55
INSTALL_DIR="$HOME/.local/share/$APPNAME"
66
BIN_PATH="/usr/local/bin/$APPNAME"
77

8-
# Get latest version (info only)
9-
LATEST_VERSION=$(curl -s https://api.github.com/repos/HexmosTech/freeDevTools/releases/latest \
10-
| grep '"tag_name":' \
11-
| sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
8+
# Detect OS + ARCH
9+
OS="$(uname | tr '[:upper:]' '[:lower:]')"
10+
ARCH="$(uname -m)"
1211

13-
echo "==> Latest version available: $LATEST_VERSION"
12+
# Normalize architecture
13+
if [ "$ARCH" = "x86_64" ]; then
14+
ARCH="amd64"
15+
elif [ "$ARCH" = "aarch64" ]; then
16+
ARCH="arm64"
17+
fi
1418

15-
# Always download the latest asset
16-
DOWNLOAD_URL="https://github.com/HexmosTech/freeDevTools/releases/latest/download/ipm"
19+
EXT=""
20+
if [[ "$OS" == "mingw"* || "$OS" == "cygwin"* || "$OS" == "msys"* ]]; then
21+
OS="windows"
22+
EXT=".exe"
23+
fi
1724

18-
echo "==> Installing $APPNAME (latest) to $INSTALL_DIR ..."
19-
mkdir -p "$INSTALL_DIR"
25+
DOWNLOAD_URL="https://github.com/HexmosTech/freeDevTools/releases/latest/download/ipm-$OS-$ARCH$EXT"
26+
TARGET="$INSTALL_DIR/$APPNAME$EXT"
2027

21-
echo "==> Downloading from $DOWNLOAD_URL ..."
22-
curl -L "$DOWNLOAD_URL" -o "$INSTALL_DIR/$APPNAME"
28+
# Check if binary exists and is valid
29+
if [[ -f "$TARGET" ]]; then
30+
if [[ "$OS" != "windows" ]]; then
31+
if [[ -x "$TARGET" ]] && file "$TARGET" | grep -q 'ELF\|Mach-O'; then
32+
echo "==> $APPNAME already installed and valid at $TARGET, skipping installation."
33+
else
34+
echo "==> $APPNAME binary is invalid, re-downloading..."
35+
rm -f "$TARGET"
36+
NEED_INSTALL=true
37+
fi
38+
else
39+
echo "==> $APPNAME already exists at $TARGET, skipping installation."
40+
fi
41+
fi
2342

24-
chmod +x "$INSTALL_DIR/$APPNAME"
43+
if [[ ! -f "$TARGET" || "$NEED_INSTALL" == true ]]; then
44+
echo "==> Installing $APPNAME ($OS-$ARCH) to $INSTALL_DIR ..."
45+
mkdir -p "$INSTALL_DIR"
2546

26-
echo "==> Creating symlink at $BIN_PATH ..."
27-
sudo ln -sf "$INSTALL_DIR/$APPNAME" "$BIN_PATH"
47+
echo "==> Downloading from $DOWNLOAD_URL ..."
48+
curl -L "$DOWNLOAD_URL" -o "$TARGET"
2849

29-
echo "==> Installation complete!"
30-
echo "Run it using: $APPNAME"
50+
# Only chmod on Unix
51+
if [[ "$OS" != "windows" ]]; then
52+
chmod +x "$TARGET"
53+
echo "==> Creating symlink at $BIN_PATH ..."
54+
sudo ln -sf "$TARGET" "$BIN_PATH"
55+
fi
56+
57+
echo "==> Installation complete!"
58+
fi
59+
60+
if [[ "$OS" == "windows" ]]; then
61+
echo "Run it using: $INSTALL_DIR\\$APPNAME$EXT"
62+
else
63+
echo "Run it using: $APPNAME"
64+
fi

0 commit comments

Comments
 (0)